In this example, the initial and final values of loop variable i (of type int) are 1 and 10, respectively. The increment expression, i += 1, increases the value of i by 1. Thus, i assume values 1, 2, 3, 4 and 5.
Note that the final expression, i <= 10, evaluates as false for next value of 1, i. e., 11. The printf statement, which is executed for each value of i, prints the value of i and i * i followed by a newline. The output is as shown below.
#inc1ude <stdio.h>
#inc1ude<conio.h>
void main()
{
int i;
for(i = 1; i < 10; i++)
printf(“%8d %8d %8d\n”, i, i * i, i * i * i);
getch();
}
OUTPUT:
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.
Related Articles
Basic Courses
Advance Courses