Sunday, July 12, 2009

Very simple math help in C programming?

3. What will be the value of the following variables after running the following statements through the compiler?


i) iValue1= (((2*3)-((6-3)%2))+(2+5/2));


ii) iValue2= 5/(4-2)+9/4-1;


iii) iValue3 = 3 * (5%3) ;





4. Determine the order of execution of operations in the code below. Determine the sequence actively.

Very simple math help in C programming?
9 3 6


answers are:


ivalue1=9


ivalue2=3


ivalue3=6





so first i start from ivalue3,ie easy


c compiler precedence


first give preference to brackets


iValue3 = 3 * (5%3) ;


so first 5%3,it takes remainder=2,then 3*2=6,finally answer=6





second:iValue2= 5/(4-2)+9/4-1;


first it takes brackets,


5/2+9/4-1 then


2+9/4-1


2+9/3


11/3


3


finally answer is 3





first one:


iValue1= (((2*3)-((6-3)%2))+(2+5/2));


(((6)-(3%2))+(2+2))


( ( (6)-(1) ) + (4))


((5)+(4))


so,finally the value is 9.
Reply:cout %26lt;%26lt; "May be you can contact a homework helper at website like http://homeworkhelp.co.in/ " %26lt;%26lt; endl;
Reply:#include %26lt;iostream%26gt;





int main(void) {


std::cout %26lt;%26lt; "Do your own homework." %26lt;%26lt; std::endl;





return 0;


}
Reply:3. The variables won't have any value after you run through the compiler. They don't even exist until the program runs. However, since all of the values are constants, the compiler will create code that initializes the variables to the results of the equations so that won't have to happen at runtime. But the actual answer to the question is that the variables don't exist until the program runs. When the program is just sitting there after having been compiled the variables don't even exist.





(In other words, this is a dumbly worded question.)





4. There is no code below.
Reply:cout %26lt;%26lt; "hello world";

medium

No comments:

Post a Comment