C Programming : C Programming code to accept and display n numbers

Course Details

Field of Study: Computer Science & Engineering
Course Name: C Programming
Description: C Programming code to accept and display n numbers i.e if n=5 it displays as 1 2 3 4 5

Algorithm

Accept the number, n
Display the numbers from 1 up to n using for loop

Code

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n;
printf("Enter a number.\n"wink;
scanf("%d",&n);
for(int i=1;i<=n;i++){
printf("%d ",i);
}
getch();
}
Posted by makeale 01/05/2015 03:02 PM Comments
 

Archives