Saturday 6 September 2014

C Program to Print the first N Natural Numbers

Program:

#include<stdio.h>
#include<conio.h>
void main( )
{
           int c=1,n;
           printf("\n Enter N value: ");
           scanf("%d", &n);
           while(c<=n)
           {
                    printf("\n %d",c);
                    c++;
            }
            getch( );
}

Input/Output:

Enter N value: 5
1
2
3
4
5

0 comments:

Post a Comment