Translate

Saturday, 22 March 2014

Program to print the set of even numbers in Turbo c ++

Source Code :

#include<stdio.h>                                                                            
#include<conio.h>                                                                          
void main(void)                                                                               
{                                                                                                       
int a;
clrscr();
a=0;
printf("\n\t%d",a);
a+=2;
printf("\n\t%d",a);
a+=2;
printf("\n\t%d",a);
a+=2;
printf("\n\t%d",a);
getch();
}

In this we used the increment factor " a+=2" , that mean from the original value of "a" add two to the number and print it, and we assigned the original value of "a" a=0 , so after each line the factor adds +2 to the original a=0 and prints it. like 0,2,4.......
The sample program looks something like this 




No comments:

Post a Comment