for Loop :

for loop :

A for loop is used to execute and repeat a block of statements depending on a condition.

Syntax :

  1. for ( <initial value>; <condition>; <increment> )
  2. {
  3. <statement block>
  4. }

Example :

  1. /* Description: program to natural number upto N */
  2. #include<stdio.h>
  3. main()
  4. {
  5. int n,i;
  6. printf("\n Enter value to n : ");
  7. scanf("%d",&n);
  8. for(i=1;i<=n;i++)
  9. {
  10. printf("%d\n",i);
  11. }
  12. getch();
  13. }

Output :

c language - program to natural number upto N

Next Update

Loading...

We have a YouTube channel for live game streaming purposes, the channel name is "NightHawk". You can visit our gaming channel and support us, Thank you