#include <stdio.h> int main() { int a=10, b=20; float c; c=a/b; printf("Answer = %f \n",c); return 0; } |
if (.....) {statement 1; statement 2; statement 3;} else statement4; |
#include <stdio.h> int main() { int a; printf("Enter an integer ="); scanf("%d", &a); if (a%3==0) printf("The number you entered is a multiple of 3.\n"); else printf("The number you entered is NOT a multiple of 3.\n"); return 0; } |
for (initial value; condition ; counter increment) statement; |
#include <stdio.h> int main() { int i; for (i=5;i<11;i++) printf("%d\n", i+10); return 0; } |
int i; for (i=0;i<=10;i++) print (2 times i + 1) ..... |
|
#include <stdio.h> #include <math.h> int main() { int i, n; float sum=0; printf("Enter # of terms ="); scanf("%d", &n); for (i=0; i<= n ; i++) sum = sum + 1/pow(2,i); printf("Sum = %f \n",sum); return 0; } |
|