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
How are variables declared in c?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
What is unary operator?
What does nil mean in c?
What is main () in c?
Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.
Difference between constant pointer and pointer to a constant.
What are the 4 types of organizational structures?
What are # preprocessor operator in c?
What is console in c language?
Can we access the array using a pointer in c language?
What is wild pointer in c?
What is exit() function?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.