#include <stdio.h>

int main() {

    int i;

The first line includes the standard input/output header file, which is needed for the printf function used later in the program.

The main function is the entry point for the program. It is the first function that is executed when the program runs.

The next line declares a variable i of type int. This variable will be used as the loop counter in the for loop.

    for (i = 1; i <= 10; i++) {

        printf("2 * %d = %d\n", i, 2 * i);


This is the for loop. It starts with the for keyword, followed by parentheses that contain three statements separated by semicolons:

The initialization statement i = 1 sets the value of i to 1 before the loop starts.

The loop condition i <= 10 specifies that the loop will continue as long as the value of i is less than or equal to 10.

The iteration statement i++ increments the value of i by 1 after each iteration of the loop.

Inside the loop, the printf function is used to print a string to the console. The string contains two %d format specifiers, which are placeholders for two integer values that will be printed. The first %d is replaced by the value of i, and the second %d is replaced by the result of 2 * i. The \n at the end of the string is a newline character that causes the output to be printed on a new line.

Finally, the return 0; statement at the end of the main function indicates that the program has completed successfully.

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
Newer Post
Older Post

No comments

Leave a Reply

Select Menu