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 Are Currently Working On Our Android Application Development and We already have two YouTube channels their name is CodeX or NightHawk. CodeX is for programming related videos and NightHawk is for online game streaming so please supporting us and Subscribe to our channels, Thank you