Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Thursday, February 10, 2011

C14 : Print numbers upto a given limit

Back to Home   &  C


A ))) //Program to print numbers upto 20 using While loop

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i=0;
while(i<=20)
{
printf("%d\n\n",i);
i++;
}
getch();
}
---------------------------------------------------------
Output
0
1
2
..
..
20
===============================================

B ))) //Program to print numbers from  20 to 1 using While loop

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i=20;
while(i>0)
{
printf("%d\n\n",i);
i--;
}
getch();
}
---------------------------------------------------------
Output
20
19
18
..
..
2
1
===============================================
C ))) //Program to print numbers from  100 to 60 using Do-While loop



//Program to print the numbers from 100 to 60 using do-while loop
#include<stdio.h>
#include<conio.h>
void main()
 {
 clrscr();
 int i=100;
 do
 {
 printf("%d\n",i);
 i--;
 }
 while(i>=60);
 getch();
 }

---------------------------------------------------------
Output
100
99
98
..
..
61
60
===============================================
Back to Home   &  C



No comments: