# Dropdowns

/*Program to find biggest number from three given numbers*/ #include<stdio.h> int main(void) { int a,b,c,big; printf(“Enter three numbers : “); scanf(“%d%d%d”, &a, &b, &c); if(a>b) { if(a>c) big=a; else big=c; } else { if(b>c) big=b; else big=c; } printf(“Biggest number is %d\n”,big); return 0; }/*End of main()*/ Output: Enter three numbers : 5 10 14 […]

c language tutorial learn c language study c language

/*Program to find quotient and remainder*/ #include<stdio.h> int main(void) { int x,y,quo,rem; printf(“Enter two numbers : “); scanf(“%d%d”,&x,&y); if(y) /*if y is non-zero*/ { quo=x/y; rem=x%y; printf(“Quotient=%d, Remainder=%d\n”,quo,rem); } else printf(“Divide by zero error\n”); return 0; } Output: Enter two numbers : 25 7 Quotient=3, Remainder=4

c language tutorial learn c language study c language

/*Program to print a message if negative number is entered */ #include<stdio.h> int main(void) { int num; printf(“Enter a number : “); scanf(“%d”,&num); if(num<0) { printf(“Number entered is negative\n”); num=-num; } printf(“Value of num is : %d\n”, num); return 0; } Output: Enter a number : -15 Number entered is negative Value of num is […]

c language tutorial learn c language study c language

/*Program to print whether a number is even or odd */ #include<stdio.h> int main(void) { int num; printf(“Enter a number : “); scanf(“%d”,&num); if(num%2 == 0) /*test for even */ printf(“Number is even\n”); else { printf(“Number is odd\n”); num*=2; printf(“Now the number is %d\n”,num); } return 0; } Output: Enter a number : 15 Number […]

c language tutorial learn c language study c language

/*Program to print the bigger number*/ #include<stdio.h> int main(void) { int a,b; printf(“Enter two numbers : “); scanf(“%d%d”,&a,&b); if(a>b) printf(“Bigger number=%d\n”,a); else printf(“Bigger number=%d\n”,b); return 0; } Output: Enter two numbers : 5 15 Bigger number=15

c language tutorial learn c language study c language

/*P4.12 Program to evaluate some expressions*/ int main(void) { int a,b,c,d,e,f,g,h,k; a=8, b=4, c=2, d=1, e=5, f=20; printf(“%d\t”, a+b-(c+d)*3%e+f/9); a=17, b=5, c=6, d=3, e=5; printf(“%d\t”,a%6-b/2+(c*d-5)/e); a=4, b=5, c=6, d=3, e=5, f=10; printf(“%d\t”,a*b-c/d

c language tutorial learn c language study c language

/*P4.11 Program to illustrate the use of cast operator*/ #include<stdio.h> int main(void) { int x=5,y=2; float p,q; p=x/y; printf(“p=%f\n”,p); q=(float)x/y; printf(“q=%f\n”,q); return 0; } Output: p=2.000000 q=2.500000

c language tutorial learn c language study c language

/*P4.10 Program to understand type conversion in assignment*/ #include<stdio.h> int main(void) { char c1,c2; int i1,i2; float f1,f2; c1=’H’; i1=80.56; /*float converted to int, only 80 assigned to i1 */ f1=12.6; c2=i1; /*int converted to char */ i2=f1; /*float converted to int */ /*Now c2 has the character with ASCII value 80, i2 is assigned […]

c language tutorial learn c language study c language

/*Program to understand the sizeof operator*/ #include<stdio.h> int main(void) { int var; printf(“Size of int=%u\n”,sizeof(int)); printf(“Size of float=%u\n”,sizeof(float)); printf(“Size of var=%u\n”,sizeof(var)); printf(“Size of an integer constant=%u\n”,sizeof(45)); return 0; } Output: Size of int=4 Size of float=4 Size of var=4 Size of an integer constant=4

c language tutorial learn c language study c language

/*Program to understand the use of comma operator*/ #include<stdio.h> int main(void) { int a,b,c,sum; sum = (a=8,b=7,c=9,a+b+c); printf(“Sum=%d\n”,sum); return 0; } Output: Sum=24

c language tutorial learn c language study c language