C Program to Add Two Numbers Without Using Addition Operator

C Program to add two numbers without using addition operator for beginners to understand about the operators and how the looping statement is working in c programming language.

Assignment Operator in C

In the C programming language, the assignment operator is used to assign a new value to a variable, property, event, or indexer element. 

Bitwise logical operations, operations on integral operands, and operations on Boolean operands can all be done with assignment operators.

Assignment operators are used to give a variable a value. 

The assignment operator’s left side operand is a variable, and the assignment operator’s right side operand is a value.

While Loop in C

A while loop is a control flow statement in most computer programming languages that allows code to be executed repeatedly based on a given Boolean condition. 

The while loop is similar to a looping if statement. While loops in C allow you to run the same block of code over and over until a condition is met. 

In C programming, the while loop is the most basic loop. The while loop has only one control condition and runs as long as it is true.

#include <stdio.h>
#include <stdlib.h>
int add(int ,int); 
int main()
{
int n1,n2; 
printf("Enter First Number");
scanf("%d",&n1);
printf("Enter Second Number ");
scanf("%d",&n2);
printf("Sum of Two Number %d",add(n1,n2)); 
return 0;
}
int add(int a, int b)
{ 
int i;
while(b != 0)
{
int c=(a & b);
a=a^b;
b=c<<1;
}
return a;
}

Output:

Enter First Number5
Enter Second Number 5
Sum of Two Number 10