#includemain(){int a =15, b =20;if(b & gt; a){printf("b is greater");}}
C
نفس الكود السابق لكن باستخدام If-Else :
main(){int a, b;printf("Please enter the value for a:");scanf("%d",& amp; a);printf("\nPlease enter the value for b:");scanf("%d",& amp; b);if(a & gt; b){printf("\n a is greater");}else{printf("\n b is greater");}}
C
كود ايجاد القيمة المطلقة لعدد مدخل من الكيبورد :
#includemain(){int number;printf(& quot; Type a number:& quot;);scanf(& quot;% d & quot;,& amp; number);/* check whether the number is negative number */if(number & lt;0){/* If it is a negative then convert it into positive. */
number =-number;printf(& quot; The absolute value is % d\ n & quot;, number);}grtch();}
C
كود عن Nested if-else :
#includemain(){int x=20,y=30;if(x==20){if(y==30){printf("value of x is 20, and value of y is 30.");}}}
C
اختبار هل عدد معين زوجي ام فردي :
#include#includeintmain(int argc,char*argv[]){int number;printf("Enter a nuber to check even or odd");scanf("%d",&number);// returns true if number is divisible by 2: evenif(number %2==0)printf("%d is even.", number);elseprintf("%d is odd.", number);getch();}