1.Write a program to evaluate the factorial value of a integer no.
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int n,i,fact=1;
printf(“enter the no”);
scanf(“%d”,&n);
i=1;
if(n>1)
do
{
fact=fact*i;
i++;
}
while(i<=n);
printf(“\n factorial value=%d”,fact);
getch( );
}
Output:
enter the no 9
factoria value=362880
2.Write a program find out the table of the intger no.
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int n,m,I;
printf(“enter the no”);
scanf(“%d”,&n);
i=1;
do
{
m=n*I;
printf(“%d%d=%d”,n,I,m);
i++;
}
while(i<=10);
getch( );
}
Output:
Enter the no 9
9*1=9
9*2=18
9*3=27
9*4=36
9*5=45
9*6=54
9*7=63
9*8=72
9*9=81
9*10=90
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int n,i,fact=1;
printf(“enter the no”);
scanf(“%d”,&n);
i=1;
if(n>1)
do
{
fact=fact*i;
i++;
}
while(i<=n);
printf(“\n factorial value=%d”,fact);
getch( );
}
Output:
enter the no 9
factoria value=362880
2.Write a program find out the table of the intger no.
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int n,m,I;
printf(“enter the no”);
scanf(“%d”,&n);
i=1;
do
{
m=n*I;
printf(“%d%d=%d”,n,I,m);
i++;
}
while(i<=10);
getch( );
}
Output:
Enter the no 9
9*1=9
9*2=18
9*3=27
9*4=36
9*5=45
9*6=54
9*7=63
9*8=72
9*9=81
9*10=90
0 Comment to "Example do-While Loop in C Language"
Post a Comment