Posts

Showing posts from March, 2021

Find average of three numbers in c

 #include<stdio.h> float  average(int a, int b, int c); int main() {     int a, b, c;//it is completely different from below a b c      printf("Enter the value of a\n");     scanf("%d", &a);         printf("Enter the value of b\n");     scanf("%d", &b);         printf("Enter the value of c\n");     scanf("%d", &c);         printf("The value of average is %f", average(a, b, c));     return 0; } float average(int a, int b, int c){ float  result; result = (float)(a + b + c)/3; return result;   }

Make a number game in C

#include<stdio.h> #include<stdlib.h> #include<time.h> int main() {     int number, guess, nguesses = 1;     srand(time(0));     number = rand()%100 + 1;     //printf("The number is %d\n",number);     do{    printf("Guess the number between 1 to 100\n");    scanf("%d", &guess);    if(guess>number){     printf("Lower number please!\n");    }    else if(guess<number){    printf("Higher number please!\n"); } else{ printf("You gussed it in %d attempts\n",nguesses); } nguesses++;    }while(guess!=number); return 0; }     

calculate factorial in c

 #include<stdio.h> int main() { int i, n, factorial=1; printf("Enter the value of n"); scanf("%d", &n); for(i=1;i<=n;i++){ factorial*=i; } printf("The value of factorial is %d is %d",n,factorial); return 0; }

The sum of n natural numbers in C

 #include<stdio.h> int main() { int i,sum=0,n; printf("Enter the value of n"); scanf("%d", &n); for(i=0; i<=n; i++){      sum+=i; } printf("The sum of n natural numbers is %d", sum); return 0; }

print numbers with DO WHILE loop in C

#include<stdio.h> int main() {   int i=0;   int n;      printf("Enter the value of n\n");   scanf("%d", &n);      do{   printf("The number is %d\n",i);   i++;   } while(i<n); return 0; } 

print 1-99 numbers with loop in c

 #include<stdio.h> int main() {    int a;    printf("Enter the number\n");    scanf("%d",&a);     while(a<100){                                                      printf("%d\n",a);    a++; } return 0; }

Find the Greatest Between Four Number in c

 #include<stdio.h> int main() { int num1, num2, num3, num4; printf("Enter the numbers\n"); scanf("%d %d %d %d", &num1, &num2,&num3, &num4); if((num1>num2) && (num1>num3) && (num1>num4)) printf("num1 is big %d",num1); if((num2>num1) && (num2>num3) && (num2>num4)) printf("num2 is big %d",num2); if((num3>num1) && (num3>num2) && (num3>num4)) printf("num3 is big %d",num3); if((num4>num1) && (num4>num2) && (num4>num3)) printf("num4 is big %d",num4); return 0; }

check a year is Leap year or not in C

 #include<stdio.h> int main() { int year; printf("Enter the year\n"); scanf("%d", &year); if (((year % 4 == 0) && (year % 100!= 0 )) || (year%400 == 0)) printf("This year is Leap year %d\n", year);     else  printf("This year is not Leap year %d\n", year);     return 0; }

calculate income tax in C

 #include<stdio.h> int main() { float tax = 0, income; printf("Enter your income\n"); scanf("%f", &income); if(income>=250000 && income<=500000){ tax = tax +0.05*(income - 250000); } if (income>=500000 && income<=1000000){ tax = tax + 0.20*(income - 500000); } if(income>=1000000 && income<=10000000){ tax = tax + 0.30*(income - 1000000); } printf("Your net income tax to be paid by on 25th on this month is %f", tax); return 0; }

check weather you pass or fail in c

 #include<stdio.h> int main() {     int Physics, Math, Chemistry; float Total; printf("Enter Physic markes\n"); scanf("%d", &Physics); printf("Enter Math markes\n"); scanf("%d", &Math); printf("Enter Chemistry markes\n"); scanf("%d", &Chemistry); Total = (Physics + Math + Chemistry)/3; if ((Total<40) || Physics<33 || Math<33 || Chemistry<33){ printf("Your total persentage is %f and You are Fail\n", Total); } else { printf("Your total persentage is %f and You are Pass\n", Total); } return 0; }

makin a grading system in c

 #include<stdio.h> int main() { int num; printf("Enter the number of the student:\n"); scanf("%d", &num); if(num>=91 && num<=100) printf("Grade O: Outstanding"); else if(num>=81 && num<=90) printf("Grade E: Excelent");         else if(num>=71 && num<=80) printf("Grade A: Very Good"); else if(num>=61 && num<=70) printf("Grade B: Good"); else if(num>=51 && num<=60) printf("Grade C: Saisfactory"); else if(num>=41 && num<=50) printf("Grade D: Standard"); else printf("Grade F: Fail"); return 0;      }

Find you can drive or not in c

 #include<stdio.h> int main() {    int age;        printf("Enter the age\n");    scanf("%d", &age);        if(age <= 90 && age >= 18)    printf("You can drive\n");        else    printf("You can't drive\n");     return 0; }

Check weather a number is even or odd in c

#include<stdio.h> int main() { int a, b; printf("Enter the number\n",a); scanf("%d", &a); if(a%2==0) printf("The number is Even\n"); else printf("The number is Odd\n"); return 0; }

how to make a simple calculator in c

 #include<stdio.h> int main() { int a, b, s, i; printf("Enter the first number: \n");    scanf("%d", &a);        printf("Enter the seacond number: \n");    scanf("%d", &b);        printf("......Menu.....\n 1 for addiction \n 2 for substraction \n 3 for multipliction \n 4 for divition \n enter your choice:");    scanf("%d", &i);        if(i==1)    s = a+b;        else if (i==2)    s = a-b;        else if (i==3)    s = a*b;        else if (i==4)    s = a/b;        else ("You entered the wrong input");    printf("The result is %d", s);        return 0; }

calculate simple interest in c

 #include<stdio.h> int main() {     int principal, rate, years;     printf("Enter the principal\n");     scanf("%d", &principal);     printf("Enter the rate\n");     scanf("%d", &rate);     printf("Enter the years\n");     scanf("%d", &years);     printf("The value of simple interest is %d",(principal*rate*years)/100); return 0; }

convert celsius to fahrenheit in c

 #include<stdio.h> int main() { float celsius, fahrenheit; printf("Enter the temperature in celsius\n"); scanf("%f", &celsius); fahrenheit = (celsius * 9/5) + 32; printf("The value of the celsius temperature in fahrenheit is %f", fahrenheit); return 0; }

Calculate the radious of a circle in c

 #include<stdio.h> int main() { int radious; float pi = 3.14; printf("Enter the value of radious\n"); scanf("%d", &radious); printf("The radious of thr circle is %f\n", radious*radious*pi); return 0; }

Calculate the volume of a cylinder in c

 #include<stdio.h> int main() { int radious; int hight; float pi = 3.14; printf("Enter the value of radious\n"); scanf("%d", &radious); printf("Enter the value of hight\n"); scanf("%d", &hight);         printf("Voluem of the cylender is %f\n", pi*radious*radious*hight); return 0; }

Calculate the value of a area in c

 #include<stdio.h> int main() { int lenth, breadth;     printf("Enter the lenth\n"); scanf("%d", &lenth); printf("Enter the  breadth\n"); scanf("%d", &breadth); int area =  lenth*breadth; printf("The value of the area is %d", area); return 0; }

Addition of two numbers in C

#include<stdio.h> int main() { int a, b; printf("Enter the value of a\n"); scanf("%d", &a); printf("Enter the value of b\n"); scanf("%d", &b); printf("The sum of a and b is %d", a + b); return 0; }

usage of %d, %f, %c in c programming

 #include<stdio.h> void main() {      int a = 4;    float b = 4.5;    char c = 'p';    int d  =50;    int e = 55+85;    printf("The value of a is %d \n ",a);    printf("The value of b is %f \n",b);     printf("The value of c is %c \n",c);    printf(" the sum of a and d is %d \n",a+d);    printf(" The value of e is %d \n",e);    return 0;  }

print a line with c programming

 #include<stdio.h> int main() { printf("Hellol I am Learning C with nilabhru"); return 0; }