Saturday, September 15, 2012

CODE #04:SIMPLE PROGRAM TO ADD TWO NUMBERS WITHOUT USING THIRD VARIABLE

| |

#include<stdio.h>

main()
{
   int a = 1, b = 2;

   /* Storing result of addition in variable a */

   a = a + b;

   /* Not recommended because original value of a is lost  
    * and you may be using it some where in code considering it 
    * as it was entered by the user. 
    */

   printf("Sum of a and b = %d\n", a);

   return 0;
}

0 comments:

Post a Comment

Powered by Blogger.