Thursday, 23 August 2012

INTERESTIG 'C'

TO ADD TWO NUMBERS IN 'C' PROGRAMMING WITH USING ONE VARIABLE:-
 #include<stdio.h>
void main()
{
int a;
clrscr();
a=(scanf("%d",&a)+a-1)+(scanf("%d",&a)+a-1);
printf("%d",a);
getch();
}
EXPLANATION:-
          In C, the code statement scanf("%d",&a)  has a default value one. Since,when this statement executes first time in the operation then its value becomes 1 and due to its execution it stores the first value in 'a' and vice versa for another part of operation . To vanish the default values of scanf statements in the expression 1 is subtracted in the both part of expression. 
                                                              EXPLAINED BY:- AVINASH KUMAR.
       "If you have any query or sugession, please post on my blog . thanks."

No comments:

Post a Comment