Showing posts with label 1 to 10. Show all posts
Showing posts with label 1 to 10. Show all posts

Wednesday, May 16, 2018

C program to display integers from one to ten.

Program code
#include <stdio.h>
#include <conio.h>
void main()
{
int i=1;
clrscr();
while (i<=10)
{
printf("%d\n",i);
i++;
}
getch();
}

Output
1
2
3
4
5
6
7
8
9
10

C program to display all even numbers between one and ten.


Program code
#include <stdio.h>
#include <conio.h>
void main()
{
int i;
clrscr();
printf(“The even numbers between one and 10\n”);
for (i=2;i<=10;i=i+2)
printf(“%d\n”,i);
getch();
}

Output
The even numbers between one and 10
2
4
6
8
10