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
#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