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 adding new programming language tutorials very soon.

We make a Collaboration with HackIsOn YouTube Channel So, Please Subscribe Their Channel and keep supporting