sir i wanted to know how we wap in c to add numbers without
using arithmetic operator in which digits are entered by
user?
Answers were Sorted based on User's Feedback
Answer / niranjan vg
#include<stdio.h>
int main()
{
int a,b,sum,carry;
printf("\n Enter the numbers : ");
scanf("%d%d",&a,&b);
sum=a^b;
carry=a&b; // Produce a extra carry bit if present
while(carry!=0)
{
carry<<=1; // shift for every iteration so
that it gets added with the next digit
a=sum;
b=carry;
sum=a^b; // perform Xor Operation
carry=a&b; // Calculate the new value for carry
}
printf("\n The sum is %d", sum);
}
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / sheshivardhan reddy.rayala
using aadd()function we can add the arguements without
using arithmetic operator
| Is This Answer Correct ? | 1 Yes | 2 No |
write a program that prints a pascal triangle based on the user input(like how many stages) in an efficient time and optimized code?
Find errors (1) m = ++a*5; (2) a = b ++ -c*2; (3)y = sqrt (1000);
Why is %d used in c?
Can static variables be declared in a header file?
When should the volatile modifier be used?
What is structure padding ?
the maximum width of a c variable name can be a) 6 characters b) 8 characters c) 10 characters d) 20 characters
print pattern 1 1 33 33 555 555 77777777 555 555 33 33 1 1
What is main return c?
write a code for large nos multilication (upto 200 digits)
Is both getch() and getchar() functions are similar? if it is similar means why these two functions are used for same usage? if it is not similar means what is the difference?
progrem to generate the following series 1 12 123 1234 12345