Find bigger of 4 numbers when other 3 are equal in C

int main() { int a, b, c, d, K, M; printf(“Enter 4 numbers (A, B, C, D) : \n”) ; scanf(“%d%d%d%d”, &a, &b,&c, &d) ; K=a+b; M=c+d; printf(“\nThe bigger number is “) ; if(K>M) (a>b) ?printf(“A. \n”) : printf(“ B.\n”) ; else (c>d) ?printf(“C. \n”) : printf(“ D.\n”) ; return 0; }
Continue reading…

Enjoyed this post? Share it!

 
 

Program to test a number for positive, negative or zero value in C

#include <stdio. h> int main() { int x; printf("Enter the number to test: \n") ; scanf("%d",&x) ; if(x) { printf(" \nThe input is a non-zero value. \n") ; if(x<0) printf("The number is negative. \n"); else printf("The number is positive. \n") ; } else printf("\nThe number is zero. \n") ; return 0; }
Continue reading…

Enjoyed this post? Share it!

 
 

Program to calculate grade based on marks in C

#include <stdio. h> int main( ) { int m1,m2, m3, Total; char Grade; printf("Enter three marks: \n") ; scanf( "%d%d%d", &m1, &m2,&m3) ; Total=m1+m2+m3; if( m1<=40 || m2<=40 || m3<=40) { Grade=’F’ ; } if( m1<=60 && m2<=60 && m3<=60 && Total>120) { Grade=’C’ ; } if( m1<=80 && m2<=80 && m3<=80 && Total>180) { […]
Continue reading…

Enjoyed this post? Share it!