Please just give me the correct and explain a lil bit on why u choose it... thank you
What is the output of the following code?
#include <iostream.h>
int main ()
{
int i=6;
i /= i -2;
cout << i;
return 0;
}
a) error and will not complie?
b) 1
c) 1.5
d) 2
e) 4
(2)
Which of the following does not correctly compute the mathmatical average of the int variables a , b and c
a)float (a+b+c) / 3.0
b) (a+b+c) / 3
c) float ((a+b+c) / 3)
d) float (a+b+c) /3
(3)
sum =0;
outercount =1;
while (outercount <= 3)
{
inntercount 1;
while (innercount <= innercount )
{
sum = sum + innercount;
innercount ++;
}
outercount ++;
}
cout << sum <<endl;
a) 1 b) 4 c) 10 d) 20 e) 35
4)
How many time will this loop iterate?
int x=0,
y=0,
z= 10;
do
{
y=x;
x += z;
}
while ( z++ < 9)
a) 0 b) 1 c) 9 d) 10 e) infinite number of timez
5)
consider the function definition
void demo ( int intval, float & floatval )
{
intval = intval *2;
floatval = float (intval) + 3.5;
return;
}
what are the values of myint and myfloat after the following code fragment is executed?
int myint = 20;
float myfloat = 4.8;
demo (myint, myfloat);
a)myint =20 and myfloat = 43.5
b)myint = 40 and myfloat = 4.8
c) myint = 20 and myfloat = 4.8
d) myint = 40 and myfloat = 43.5
e) none of the above.
6)
After the execution of the code fragment
int ar[5];
int i;
for ( i=0; i< 5; i++)
{
ar[i] = i +2;
if ( i > =3 )
ar [i-1] = ar [i] +3;
}
what is contained in ar[2]?
a) 8 b) 4 c) 3 d) 2 e) none of the above
7)
Given a 5000 element array beta, which of the code fragments below could used to print out the values of beta [0],
beta[2],beta [4] abd so forth? ( all variables are of type int )
a)
for ( i=0; i < 5000 ; i+=2)
cout << beta [i] <endl;
b)
for ( i=0 ; i <2500 ; i++)
cout << beta [2*i] << endl;
c)
for ( i= 0; i < 2500 ; i++)
cout << beta [i] *2 <<endl;
d)
a and c
e ) a,b,c