Print first n natural numbers

 #include <stdio.h>


int main(){

int i=1;
int n;
printf("Enter the number of natural numbers you want to print\n");
scanf("%d",&n);
printf("The n natural numbers are:\n");
do
{
  printf("%d\n",i);  /* code */
  i++;
} while (i<=n);

 return 0;
}

Comments

Popular posts from this blog

snake game Version-2 (using random number)

allocating dynamic memory using calloc

store a table in dynamic array and then change the size of array dynamically to store more numbers