Add without '+'
3 posters
Page 1 of 1
Add without '+'
Write a program to add two number without using the addition operator.
I/P: 5 10
O/P: 15
I/P: 5 10
O/P: 15
Re: Add without '+'
#include<stdio.h>
int main()
{
int num1 = 10, num2 = 5, i;
while (num2 > 0) {
num1++;
num2--;
}
printf("%d", num1);
return (0);
}
int main()
{
int num1 = 10, num2 = 5, i;
while (num2 > 0) {
num1++;
num2--;
}
printf("%d", num1);
return (0);
}
vinoveera- Posts : 7
Points : 22699
Join date : 2015-06-27
Re: Add without '+'
vinoveera wrote:#include<stdio.h>
int main()
{
int num1 = 10, num2 = 5, i;
while (num2 > 0) {
num1++;
num2--;
}
printf("%d", num1);
return (0);
}
Your program is fine. Superb thinking. Keep it up.
Re: Add without '+'
We can use functions right?
sreenivas_srevs- Posts : 3
Points : 22690
Join date : 2015-06-26
Re: Add without '+'
sreenivas_srevs wrote:We can use functions right?
what kind of function you will use??
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|