Thursday 9 May 2013

Sum of 2 numbers without using Arithmetic Operators


DESCRIPTION: This program finds the sum of two numbers without using any of the arithmetic operators. Here we have made use of the looping methods to find the sum of two numbers.


PROGRAM:


#include<stdio.h>
#include<stdlib.h>
void main()
{
    int n1,n2,sum,temp;
    printf("enter the 2 number's\n");
    scanf("%d%d", &n1,&n2);
   sum=n2;
   temp=n1;
   while(temp>0)
   {
       sum++;
       temp--;
   }
   printf("%d+%d=%d",n1,n2,sum);
}


OUTPUT WINDOW:


No comments:

Post a Comment