how to add numbers without using arithmetic operators.
Answer Posted / 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 |
Post New Answer View All Answers
Linked lists -- can you tell me how to check whether a linked list is circular?
How can a string be converted to a number?
Was 2000 a leap year?
What is the difference between malloc calloc and realloc in c?
Write a program to print ASCII code for a given digit.
The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.
What is the difference between exit() and _exit() function?
What is character set?
Do you know pointer in c?
Can we use visual studio for c?
What are the three constants used in c?
What the advantages of using Unions?
Differentiate between Macro and ordinary definition.
Which type of language is c?
How do you print an address?