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

Computer Science Engineering

Special Notes

It's a special area where you can find special questions and answers for CSE students or IT professionals. Also, In this section, we try to explain a topic in a very deep way.

CSE Notes