Write a program that displays the number from 1 to 9


Difficulty level
This exercise is mostly suitable for students
#include <stdio.h>
#include <conio.h>

void main()
{
	int I;

	/* display numbers from 0 to 9 */

	//solution 1
	I = 0;
	while (I<10)
	{
		printf("%i \n", I);
		I++;
	}

	//solution 2
	I = 0;
	while (I<10)
		printf("%i \n", I++);

	//solution 3
	I = -1;
	while (I<9)
		printf("%i \n", ++I);

	getch();
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Adding very large floating-point numbers