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

  1. Accept the number, n
  2. 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");
scanf("%d",&n);
for(int i=1;i<=n;i++){
printf("%d ",i);
}
getch();
}

Share this article:
Previous Post: Type of Sampling in Communication Systems

October 16, 2014 - In Academics, Electronics

Next Post: Dual Nature of Light

October 23, 2014 - In Academics, Electronics

Related Posts