Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

20 Jul 2012

c program to add two numbers without using third variable

Write a c program to add two Numbers without using Third variable..

PROGRAM:

#include<stdio.h>
int main()
{
     int x,y;
     printf(" ***PROGRAM TO ADD TWO NUMBERS WITHOUT USING
                THIRD VARIABLE*** ");
     printf("\n Enter the first number to be added: ");
     scanf("%d",&x);         /* taking x value from keyboard*/
     printf("\n Enter the second number to be added: ");
     scanf("%d",&y);         /* taking y value from keyboard*/
     x = x + y;     /*assining the value of sum of x and y to x*/

     printf("\n The sum of two numbers is: %d\n",x);    /*printing the sum.*/
     return 0;
}

Sample Output: ( using GNU GCC Compiler with Code Blocks IDE )
  Enter the first number to be added: 15
  Enter the second number to be added: 5
  The sum of two numbers is: 20


For c# Program:

C# Program To Add Two Numbers/Integers without using Third Variable

1 comment: