Image

Programs - C Language - Control Statement

Program:


#include<stdio.h>

main()
{
int i,j,n;

printf("\n Enter number ( 0 or 1) only : ");
scanf("%d",&n);

for(i=1;i<=10;i++)
 {
  if(n==0)
  {
   if(i%2==0)
    printf("\n%3d%3d%3d%3d%3d%3d%3d%3d%3d",2*i,4*i,6*i,8*i,10*i);
  }
  else
  {
    printf("\n%3d%3d%3d%3d%3d%3d%3d%3d%3d",1*i,3*i,5*i,7*i,9*i);
  }
 }

 return 0;
}

Output:

Enter number ( 0 or 1) only : 1

 1 3 5 7 9 40 1114738084199400
 2 6 10 14 18 40 1114738084199400
 3 9 15 21 27 40 1114738084199400
 4 12 20 28 36 40 1114738084199400
 5 15 25 35 45 40 1114738084199400
 6 18 30 42 54 40 1114738084199400
 7 21 35 49 63 40 1114738084199400
 8 24 40 56 72 40 1114738084199400
 9 27 45 63 81 40 1114738084199400
10 30 50 70 90 40 1114738084199400