Tuesday, May 7, 2013

C Program to print 1-100 using for loop

The Program given below is a C++ Program to show 1 to 100 in the Output. I have used for loop to print 1-100 on the screen. You may also print any set of number of a fixed interval. For example you may print 3, 6, 9.....27. If you want to do so then need to replace the 5th line by for(i=3; i<=27; i=i+3). Thus you may print any of your expected set of number of same interval.
#include<stdio.h>
void main()
{
int i;
for(i=1; i<=100; i=i+1)
printf("%d, ",i);
}


The Output of the above C++ Program is given below.

This id the result of the above C program

No comments:

Post a Comment