if(condition) { statements ---------- } else if(condition) { statements ---------- } else if(condition) { statements ---------- } else ---------
#include⁢stdio.h> main() { int a; printf("Enter a Number"); scanf("%d",&a); if(a>0) printf("Number is Positive"); else if(a>0) printf("Number is Negative"); else printf("Number is Zero"); }
Enter a Number 56 Number is positive
#include⁢stdio.h> main() { int a,b,c; printf("Enter 3 different Numbers "); scanf("%d %d %d",&a,&b,&c); if(a>b && a>c) printf("%d is Greatest",a); else if(b>c) printf("%d is Greatest",b); else printf("%d is Greatest",c); }
Enter 3 different Numbers 31 7 78 Greatest number is 78
#include⁢stdio.h> main() { char a; printf("Enter Color code "); scanf("%c",&a); if(a=='r'||a=='R') printf("Red"); else if(a=='g'||a=='G') printf("Green"); else if(a=='b'||a=='B') printf("Blue"); else printf("White"); }
Enter Color Code B Blue