100% c prog to illustrate usage of 'while loop'
/*program to print multiplication tables of given integers using "while(condition )"*/
#include <stdio.h>
void main()
{
int n,i,flag=4; //flag value can be any non zero
while(flag)
{
printf("\n enter a integer whose multiplication table is required:");
scanf("%d",&n);
for(i=1;i<11;i++)
{
printf("\n %3d * %2d= %3d",n,i,n*i);
}
printf("\n enter 0 to stop, else enter other number to continue:");
scanf("%d",&flag);
};
}
ఔట్పుట్ ఈ కింది విధంగా కనపడును..
enter a integer whose multiplication table is required:7
7 * 1= 7
7 * 2= 14
7 * 3= 21
7 * 4= 28
7 * 5= 35
7 * 6= 42
7 * 7= 49
7 * 8= 56
7 * 9= 63
7 * 10= 70
enter 0 to stop, else enter other number to continue:2
enter a integer whose multiplication table is required:14
14 * 1= 14
14 * 2= 28
14 * 3= 42
14 * 4= 56
14 * 5= 70
14 * 6= 84
14 * 7= 98
14 * 8= 112
14 * 9= 126
14 * 10= 140
enter 0 to stop, else enter other number to continue:0
#include <stdio.h>
void main()
{
int n,i,flag=4; //flag value can be any non zero
while(flag)
{
printf("\n enter a integer whose multiplication table is required:");
scanf("%d",&n);
for(i=1;i<11;i++)
{
printf("\n %3d * %2d= %3d",n,i,n*i);
}
printf("\n enter 0 to stop, else enter other number to continue:");
scanf("%d",&flag);
};
}
ఔట్పుట్ ఈ కింది విధంగా కనపడును..
enter a integer whose multiplication table is required:7
7 * 1= 7
7 * 2= 14
7 * 3= 21
7 * 4= 28
7 * 5= 35
7 * 6= 42
7 * 7= 49
7 * 8= 56
7 * 9= 63
7 * 10= 70
enter 0 to stop, else enter other number to continue:2
enter a integer whose multiplication table is required:14
14 * 1= 14
14 * 2= 28
14 * 3= 42
14 * 4= 56
14 * 5= 70
14 * 6= 84
14 * 7= 98
14 * 8= 112
14 * 9= 126
14 * 10= 140
enter 0 to stop, else enter other number to continue:0
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.