Blogger templates

Pages

Monday 30 April 2012

C Program: Enter a Number and Prints its Tabel in Correct as well as in Reverse order

table

Input a number from keyboard and prints its table in 2 ways
  • In reverse order
  • In correct order
1. In reverse order
 
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();

printf(" Enter a number:\n");
printf(" Table is:\n");
scanf("%d" , &a);

for(b=10 ;b>=1 ;b--)
{
c=a*b;
printf("%d\n" ,c);
}
getch();
}

Output:
Enter a number:
2
Table is:
20
18
16
14
12
10
8
6
4
2

2.  In correct order

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf(" Enter a number:\n");
printf(" Table is:\n");
scanf("%d" , &a);

for(b=1 ;b<=10 ;b++)
{
c=a*b;
printf("%d\n" ,c);
}

getch();
}

Output:
Enter a number:
2
Table is:
2
4
6
8
10
12
14
16
18
20



0 comments:

Post a Comment