[go: up one dir, main page]

0% found this document useful (0 votes)
16 views2 pages

Sheet 1 Solution

The document contains a multiple choice quiz with 14 questions about programming concepts such as loops, conditional statements, functions, and operators. The questions cover topics like the output of for loops, the use of conditional operators, parameters vs arguments in functions, and the order of operations in expressions.

Uploaded by

maody268
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Sheet 1 Solution

The document contains a multiple choice quiz with 14 questions about programming concepts such as loops, conditional statements, functions, and operators. The questions cover topics like the output of for loops, the use of conditional operators, parameters vs arguments in functions, and the order of operations in expressions.

Uploaded by

maody268
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Akbar Elyom Academy Course structure programming

CIS: First year sheet to solve Examiner :Dr Hussein Omran


Second Term May.2021
1. What is the output of the following program?
#include<iostream>
using namespace std;
int c=1;
int main (){
int a, b=0;
for(a=0;a<10;++a)
{
if(c%2==1)
b+=c;
}
cout<<b;
return 0;
}
(a) 20 (b) 25 (c) 10 (d) 30 (e) None of the above
2. What is the output of the following statements?
for(int i = 10; i++; i<15)
cout<< i;
(a) 1011121314 (b)101112131415 (c)910111213 (d)It will go to infinite loop (e)None of all
3. What's wrong in this statement? (x == 4 && y == 5) ? (a = 5) ; (b = 6);
(a)The question mark should be an equal sign
(b)The first semicolon should be a colon
(c)There are too many variables in the statement
(d)The conditional operator is only used with strings
(e)There shouldn’t be any assignment operator in this statement.
4. What's wrong in the following statement, provided k is a variable of type int?
for (k = 2, k <=12, k++)
(a) The increment should always be ++k
(b) The variable must always be the letter i when using a for loop
(c) There should be a semicolon at the end of the statement
(d) The variable k can’t be initialized (e) The commas should be semicolons.
5. What is printed when this program is executed
#include<iostream>
using namespace std;
int f( int x){
if ( x<= 4)
return x;
return f(--x);
}
int main()
{
cout<< ("%d\n", f(7));
return 0;
}
(a)4 (b)4 5 6 7 (c)1 2 3 4 (d)Syntax error (e)Runtime error.
6. The size of an int must be greater than or equal to that of a _________
(a) Long int (b) Short int (c) Float (d) Double (e) Char.
7. What are the values of a, b are if the following code fragment is executed
int a ,b=7;
a=b<4?b<<1:b>4?7>>1:a;
cout <<a << " and " << b << endl;
(a)Garbage and 7 (b)7 and 3 (c)3 and 7 (d)3 and 3 (e)7 and 7.
8. Pick equivalent control structure for following repetitive control structure
for( C1; C3; C2 ) { statements; }
(a) while( C1) { C2; statements; C3; }
(b) C1; while(C2) { statements; C3; }
(c) while( C3) { C1; statements; C2; }
(d) C1; while(C3) { statements; C2; }
(e) C1; C3; while(C2) { statements; }.
9. The recursive functions are executed in a
(a) Parallel order (b) First In First Out order
(c) Last In First Out order (d) Iterative order (e) Random order.
10. Consider the following program fragment, and choose the correct one
main( )
{
int a, b = 2, c;
a = 2 * (b++);
c = 2 * (++b);
}
(a) a = 4, c = 8 (b) a = 3, c = 8 (c) b = 3, c = 6 (d) a = 4, c = 6 (e) b = 4, c = 6.
11. What will be the value of sum after the following program is executed?
#include<iostream>
using namespace std;
int main( ){
int sum = 1, index = 9;
do
{
index = index - 1;
sum *= 2;
}while( index > 9 );
cout<<sum;
}
(a) 1 (b) 2 (c) 9 (d) 0.5 (e) 0.25.
12. What we mean by the following
a. Variable deflation?
b. Reference sign
13. Information will be passed to the function via special identifier is called
(a) Arguments (b) Parameters (c) Both (a) and (b) above (d) Elements (e) Characters
14. What number will z in the sample code given below?
int z, x=5, y= -10, a=4, b=2;
z=x++ - --y *b/a;
(a) 5 (b) 6 (c) 10 (d) 11 (e) 12.
Good luck

You might also like