In this program, the task is to print a table of any number. After taking input of a finite numbers a & n, the condition will be checked by for loop "for(i=1;i<=n;i++)", in this program we've used i=1 not i=0 since the table would start from a*1=a not a*0=0 & then the loop continues till n by printing a*i everytime & i keeps updating until the condition i<=n is wrong .
Program to print table.
#include<stdio.h>#include<conio.h>
void main()
{ int a,n,i;
clrscr();
printf("program to print table (of no. a from 1 to n)");
printf("\n\n enter value of a : ");
scanf("%d",&a);
printf(" now enter n (should be finite) : ");
scanf("%d",&n);
printf("\n\n");
for(i=1;i<=n;i++)
{ printf("%d * %d = %d",a,i,a*i);
printf("\n");
}
getch();
}

No comments:
Post a Comment
Guys if you think something is wrong or should be edit than please do comment.