FOR Loop in C Language:
(1) The FOR statement is used to iterate over a range of values or a sequence. The FOR loop is executed for each of the items in the range.
(2) Sample C language code and its output, as shown.
#include <stdio.h> #include <conio.h> //Table of 2 using for loop int main() { int x; int i; i = 0; for (x = 1; x <= 10; x++) { i = i + 2; printf(“2 * %d = %d \n”,x,i); } getch(); return 0; } |
(3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.
(4) After building the code, press the “Run” button, as shown.
(5) After pressing the “run” button, the output screen is opened, as shown.
For Loop Syntax:
for (statement 1; statement 2; statement 3) { //write logic } |