Logical Analysis and Programming
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Add without '+'

3 posters

Go down

Add without '+' Empty Add without '+'

Post by Admin Sat Jun 27, 2015 11:20 pm

Write a program to add two number without using the addition operator.

I/P: 5 10

O/P: 15

Admin
Admin

Posts : 22
Points : 22749
Join date : 2015-06-24
Age : 29

https://csenpsb.board-directory.net

Back to top Go down

Add without '+' Empty Re: Add without '+'

Post by vinoveera Mon Jun 29, 2015 12:32 am

#include<stdio.h>
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

Back to top Go down

Add without '+' Empty Re: Add without '+'

Post by Admin Mon Jun 29, 2015 6:15 pm

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.

Admin
Admin

Posts : 22
Points : 22749
Join date : 2015-06-24
Age : 29

https://csenpsb.board-directory.net

Back to top Go down

Add without '+' Empty Re: Add without '+'

Post by sreenivas_srevs Sat Jul 04, 2015 7:28 pm

We can use functions right?

sreenivas_srevs

Posts : 3
Points : 22690
Join date : 2015-06-26

Back to top Go down

Add without '+' Empty Re: Add without '+'

Post by Admin Sat Jul 04, 2015 9:01 pm

sreenivas_srevs wrote:We can use functions right?

what kind of function you will use??

Admin
Admin

Posts : 22
Points : 22749
Join date : 2015-06-24
Age : 29

https://csenpsb.board-directory.net

Back to top Go down

Add without '+' Empty Re: Add without '+'

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum