Skip to main content

Posts

Take a 5 Digit Integer Number & Print It in Reverse Order [C Programming]

#include<stdio.h> int main() {     int i, a, b, c, d, e, f, g, h, rev;     printf("Enter a 5 digit integer number: ");     scanf("%d", &i);     a = i/10000;     b = i%10000;     c = b/1000;     d = b%1000;     e = d/100;     f = d%100;     g = f/10;     h = f%10;     rev = h*10000+g*1000+e*100+c*10+a;     printf("Reverse number: %d", rev);     return 0; }

Program That Reads & Sums Data Values Until A Negative Value Is Read [C Programming]

#include<stdio.h> int main() {     int i, sum=0;     while(1)     {         printf("Enter a number: ");         scanf("%d", &i);         if(i>=0)         {             sum += i;         }         else         {             break;         }     }     printf("Sum : %d", sum);     return 0; }

Program to Read The Age of n Persons & Count The Number of Persons Who Are Not in The Age Group 50-60 [C Programming]

#include<stdio.h> int main() {     int i, n, age, count=0;     printf("How many person's age do you want to insert?\n");     scanf("%d", &n);     for(i=1; i<=n; i++)     {         printf("Enter age of person %d: ", i);         scanf("%d", &age);         if(age < 50 || age > 60)         {             count++;         }     }     printf("\nNumber of person(s) who are not in age group 50 - 60 is: %d", count);     return 0; }

Factorial of A Number [C Programming]

#include<stdio.h> int main() {     int i, n, factorial=1;     printf("Enter an integer: ");     scanf("%d", &n);     if(n<0)     {         printf("Factorial of a negative number doesn't exist!");     }     else     {         for(i=1; i<=n; i++)         {             factorial *= i;         }         printf("Factorial of %d is: %d", n, factorial);     }     return 0; }

Classroom Numbers of AIUB [C Programming]

Problem description:  Consider the room numbers of our campus - 423, 432, 441, 234, 534, 132. Here first digit represents campus number, second digit represents floor number and the third number represents room number in that floor. Write a program that will take a three digit number (like 423) and output the Campus, Floor, and Room Number according to the input. INPUT: 423 OUTPUT: Campus 4, Floor 2, Room 3 Code: #include <stdio.h> int main() {     int n, campus, floor, room;     printf("Enter a room number: ");     scanf("%d", &n);     room = n%10;     floor = ((n - room)%100)/10;     campus = n/100;     printf("Campus %d, Floor %d, Room %d", campus, floor, room);     return 0; }

Write A Program That Receives 5 Numbers & Output The Sum & Average of These Numbers [C Programming]

#include <stdio.h> int main() {     float i, n, sum=0, avg;     for(i=0; i<5; i++)     {         printf("Enter a number: ");         scanf("%f", &n);         sum = sum + n;     }     avg = sum / 5;     printf("Sum: %0.2f\n", sum);     printf("Average: %0.2f", avg);     return 0; }

Currency Converter - USD & BDT [C Programming]

#include <stdio.h> void main() {     int i;     float usd, bdt;     printf("Press 1 to convert USD to BDT\nPress 2 to convert BDT to USD\n");     printf("Enter your choice: ");     scanf("%d", &i);     switch(i)     {         case 1:             printf("Enter amount in USD: ");             scanf("%f", &usd);             bdt = usd * 80;             printf("1 USD = 80 BDT\n");             printf("%0.3f USD = %0.3f BDT", usd, bdt);             break;         case 2:   ...

Positive Or Negative Number? [C Programming]

#include <stdio.h> void main() {     int i;     printf("Enter an integer: ");     scanf("%d", &i);     if(i == 0)     {         printf("%d is Zero", i);     }     else if(i>0)     {         printf("%d is Positive", i);     }     else     {         printf("%d is Negative", i);     } }