fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. int main(void) {
  5. int a,b,c;
  6. bool d=true;
  7. //sequential structure example (default structure)
  8. b=10;
  9. b=15;
  10. b=20;
  11. printf("b= %d\n",b);
  12. //Selection Structure (if, if else, switch etc)
  13. if(d==true)
  14. printf("Inside if Statement\n");
  15.  
  16. if(a%2==0)
  17. printf("a is even\n");
  18. else
  19. printf("a is odd\n");
  20.  
  21. if(b==10)
  22. printf("b is 10");
  23. else if(b==15)
  24. printf("b is 15");
  25. else
  26. printf("b is neither 10 nor 15\n");
  27.  
  28. for(int i=0;i<2;i++){
  29. a=i+1;
  30. printf("Iteration %d\n",i+1);
  31. }
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
b= 20
Inside if Statementa is even
b is neither 10 nor 15
Iteration 1
Iteration 2