how to add numbers without using arithmetic operators.
Answers were Sorted based on User's Feedback
Answer / sneha
#include <stdio.h>
int add(int a,int b)
{
if(!a)
return b;
else
return add((a&b)<<1,a^b);
}
void main()
{
int a=2, b=3, c;
c = add(a,b);
printf("%d\n",c);
}
Is This Answer Correct ? | 15 Yes | 3 No |
Answer / lookog
int add2(int a,int b)
{int s;
char *p=(unsigned)a;
s=&p[b];
return(s);
}
The previous soln with int would not be accurate, as int
storage is platform dependent. char is 1 bytes mostly.p[b]
is equivalent to *(p+b) and already p=a has been set.
though result is coming for -1000,-1000, not sure what it
means physically(address of -2000 ?)
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / srikanth
int main()
{
int a=3,b=5;
printf("
%d
",printf("%*c%*c",a,' ' ,b,' '));
}
Is This Answer Correct ? | 0 Yes | 0 No |
#include<Stdio.h>
#include<conio.h>
void main()
{
int a=10,b=20;
while(b--) a++;
printf("Sum is :%d",a);
}
Is This Answer Correct ? | 9 Yes | 11 No |
Answer / abdur rab
#include <stdio.h>
int main ( int argc, char* argv [ ] )
{
int value1 = 10;
int value2 = 5;
printf ( "\n The sum is :%d", value1 | value2 );
}
Is This Answer Correct ? | 10 Yes | 12 No |
Answer / autojack
#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,x=10,c;
clrscr();
c=a|x;
printf("%d",c);
getch();
}
Is This Answer Correct ? | 2 Yes | 5 No |
Answer / satish gaikwad
oh sorry I have considered as addition operator
Is This Answer Correct ? | 2 Yes | 6 No |
Answer / valli
#include<stdio.h>
main()
{
int a=5,b=6,s;
int *p=a;
s=&p[b];
printf("%d",s);
}
Is This Answer Correct ? | 1 Yes | 5 No |
Define a structure to store roll no, name and marks of a student. Using the structure of above write a ‘C’ program to create a file “student.dat”. There must be one record for every student in the file. Accept the data from the user.
What is variable in c example?
int main() { int i=1; switch(i) { case '1': printf("hello"); break; case 1: printf("Hi"); break; case 49: printf("Good Morning"); break; } return 0; }
What is the purpose of scanf() and printf() functions?
what is the role you expect in software industry?
write a programming in c language, 1 3 5 7 9 11
Explain enumerated types in c language?
Is fortran still used today?
What is NULL pointer?
write an algorithm and a program to count the number of elements in a circularly singly linked list
In scanf h is used for
what is the difference between #include<> and #include”…”?