if(condition) { if(condition) { statements ---------- } } next statements
#include⁢stdio.h> main() { int a; int x , y ; printf("Enter a Number ") ; scanf("%d",&a) ; if(a>=10 && a<=99) { printf("It is a 2 digit number") ; x =a%10; y =a/10; if(x==y) printf("Both digits are same") ; else printf("Both digits are not same") ; } else printf("It is not a 2 digit number") ; }
Enter a Number 26 It is a 2 digit Number Both digits are not same
#include⁢stdio.h> main() { int a; int n1,n2,n3,n4; printf("Enter a Number "); scanf("%d",&a); if(a>=1000 && a<=9999) { printf("It is a 4 digit number"); n1=a%10; n2=a/10%10; n3=a/100%10; n4=a/1000; if(n1+n2==n3+n4) printf("Sum is same") ; else printf("Sum is not same") ; } else printf("It is not a 4 digit number"); }
Enter a Number 2653 It is a 4 digit Number Sum is same
#include⁢stdio.h> main() { int a,b,c; printf("Enter 3 Angles "); scanf("%d %d %d",&a,&b,&c); if(a+b+c==180) { printf("Triangle can be formed"); if(a==b || b==c || c==a) printf("\nIso. Triangle"); if(a==b && b==c) printf("\nEq. Triangle"); if(a==90 || b==90 || c==90) printf("\nRightAngled Triangl"); } else printf( "Triangle cannot be formed" ); }
Enter a Angles 45 90 45 Triangle can be formed Iso. Triangle