FOR Loop in C Language

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.

For Loop Sample C language code
#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);
  return 0;

(3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.

Click on Build option for the for loop

(4) After building the code, press the “Run” button, as shown.

click on run button to run the for loop code for c

(5) After pressing the “run” button, the output screen is opened, as shown.

For loop code ouput obtained in c

For Loop Syntax:

for (statement 1; statement 2; statement 3) {
  //write logic

If Else condition in C Language
SWITCH Statement in C Language
Use of CHAR function in SQL
Create Database via query in SQL Server
Types of JOINS Statement in SQL Server
REPLACE (Transact-SQL)– Microsoft Docs

Leave a Reply