![]() |
Re: Multiple Choice Questions in C (Answers not given)
The compiler i use is LCC-WIN 32
This is how i have written the program and the warnings. 1 #include<stdio.h> 2 void afunction(int *x) 3 { 4 x=new int; 5 *x=12; 6 } 7 int main() 8 { 9 int v=10; 10 afunction(&v); 11 printf("%d",v); 12 } Error c:\lcc\test.c: 4 undeclared identifier 'new' Error c:\lcc\test.c: 4 operands of = have illegal types 'pointer to int' and 'int' Warning c:\lcc\test.c: 4 possible usage of new before definition Error c:\lcc\test.c: 4 Syntax error; missing semicolon before `int' Error c:\lcc\test.c: 4 empty declaration Compilation + link time:0.7 sec, Return code: 1 As for the other questions i haven't yet understand the following: #10 why does the loop stop when i=0? #17 i don't understand why the precedence affects the value of b Thanks |
Re: Multiple Choice Questions in C (Answers not given)
I am not sure about the error but I can explain about the other 2.
When anything becomes zero its equal to false or else its true. In C there is nothing bool but everything is with respect to 0 and Non zero. 0 being false and Non Zero is true. Say if you have something like if(1) will always be true. Regarding precedence try expanding the macro on pen and paper and you will see both evaluation does not come out to be same. |
Re: Multiple Choice Questions in C (Answers not given)
Quote:
|
Re: Multiple Choice Questions in C (Answers not given)
I should become -1 in ++i for the expression to become 0 and if it becomes 0 then ++i becomes 1 and the same logic goes for i++ but its the increment that is done after the loop breaking condition check.
|
Re: Multiple Choice Questions in C (Answers not given)
Code:
1 #include<stdio.h> |
Re: Multiple Choice Questions in C (Answers not given)
Try this coding in the manner...........u got answer
Code:
#include <stdio.h> |
Re: Multiple Choice Questions in C (Answers not given)
Quote:
|
Re: Multiple Choice Questions in C (Answers not given)
Run it in Microsoft Vc++ compiler ...
U will get an answer of value "10" |
Re: Multiple Choice Questions in C (Answers not given)
thanks
|
Re: Multiple Choice Questions in C (Answers not given)
Quote:
|
| All times are GMT +5.5. The time now is 13:39. |