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

Why is c still so popular?

786


What is default value of global variable in c?

737


What is a good way to implement complex numbers in c?

781


What is the purpose of sprintf?

814


What does %d do in c?

725


What is else if ladder?

790


Is c compiled or interpreted?

875


Write a program to reverse a given number in c language?

835


Difference between MAC vs. IP Addressing

829


Whats s or c mean?

766


What is the difference between near, far and huge pointers?

816


What are static variables in c?

802


What is a c token and types of c tokens?

811


What is graph in c?

803


Why doesnt the call scanf work?

902