This is a simple Program in C to print sum or addition of two numbers without using Arithmetical operators. This is a part of Mumbai University MCA Colleges. It is mostly asked in Interviews.
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
Add without Arithmetic Operators
#include <stdio.h>
#include <iostream.h>
int main()
{
int a=7,b=5;
while(b--) // b will take value 5,4,3,2,1,0
a++; // a will take values 7,8,9,10,11,12
cout<<a;
}
Here what we have done is that we have run a added the number 1 or incremented the value of variable by 1 and decremented the other by 1 till the decremented variable is 0.
The number of times the loop runs for 'b', that many times the value of a will increase.
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
No comments:
Post a Comment