How to add two numbers without using arithmetic operators?

Answer Posted / roopali

#include<stdio.h>
int sum(int num1, int num2);
int main()
{
int num1, num2, result;
printf("Enter the number:");
scanf("%d%d",&num1,num2);
result=sum(num1,num2);
printf("The sum of two numbers is:%d",result);
return 0;
}

int sum(int num1, int num2)
{
int i;
for(i=0;i<num2;i++)
{
num1++;
}
return num1;
}

Is This Answer Correct ?    3 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many levels of pointers can you have?

695


Write the Program to reverse a string using pointers.

613


find out largest elemant of diagonalmatrix

1643


Why can arithmetic operations not be performed on void pointers?

583


What is the use of the function in c?

594






What is union and structure in c?

606


Explain Basic concepts of C language?

640


What are the advantages of c preprocessor?

708


Where are the auto variables stored?

620


the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none

639


How can I remove the trailing spaces from a string?

608


What does the characters “r” and “w” mean when writing programs that will make use of files?

848


Who invented bcpl language?

698


Tell me when would you use a pointer to a function?

603


What is #include in c?

596