Tuesday, December 30, 2014

C using do while program



Program 1

#include
#include
void main()
{
int i,n;
clrscr();
          i=1;
          printf("Enter the number\n");
          scanf("%d",&n);
          do
          {
          printf("%d",i);
          i=i+1;
          }
          while(i<=n);
getch();
}

Output
           
          Enter the number
          6
          1,2,3,4,5,6

Program 2

#include
#include
void main()
{
char name[25];
int c=1;
clrscr();
          printf("\n Enter any name\n");
          scanf("%s",name);
          do
          {
          printf("%d  Good Day %s\n",c,name);
c=c+1;
}
while(c<=10);
getch();
}

Output
          
          Enter any name
          Ragul
1.     Good Day Ragul
2.     Good Day Ragul
3.     Good Day Ragul
4.     Good Day Ragul
5.     Good Day Ragul
6.     Good Day Ragul
7.     Good Day Ragul
8.     Good Day Ragul
9.     Good Day Ragul
10.            Good Day Ragul

No comments:

Post a Comment