Algorithm
#include<stdio.h>
#include<conio.h> //only for windows users
void main()
{
clrscr(); //only for windows users
int lim,i;
printf("\n enter the limit:\t");
scanf("%d",&lim);
for(i=0;i<=lim;i++)
{
printf("%d\t",i);
}
getch(); \\only for windows users
}
Output
enter the limit: 5
0 1 2 3 4 5
- start
- read limit
- set i=0
- if i<=limit
- display i
- i+1 go to 4
- else
- stop
#include<stdio.h>
#include<conio.h> //only for windows users
void main()
{
clrscr(); //only for windows users
int lim,i;
printf("\n enter the limit:\t");
scanf("%d",&lim);
for(i=0;i<=lim;i++)
{
printf("%d\t",i);
}
getch(); \\only for windows users
}
Output
enter the limit: 5
0 1 2 3 4 5
No comments:
Post a Comment