Sei sulla pagina 1di 4

You are logged in as 080265L LIVERA (Logout)

You are here


*
*
*
*
*

LearnOrg-Moodle
/ ? CS1020-08S2
/ ? Quizzes
/ ? Quiz 2 for Group B2 (1pm - 3pm)
/ ? Attempt 1

Quiz 2 for Group B2 (1pm - 3pm)


JavaScript must be enabled to continue!
1
Marks: 1
What are two predefined FILE pointers in C?
Choose one answer.
a. console and error
b. stdout and stderr
c. stdio and stderr*************************
d. stdout and stdio
2
Marks: 1
What will the code below print when executed?
double x = -3.5, y = 3.5;
printf( "%.0f : %.0f ", ceil( x ), ceil( y ) );
printf( "%.0f : %.0f ", floor( x ), floor( y ) );
ceil =>rounds up 3.2=4
floor =>rounds down 3.2=3
Choose one answer.
a. -3 : 4 -4 : 3******************************
b. -3 : 3 -4 : 4
c. -4 : 4 -3 : 3
d. -4 : 3 -4 : 3
3*********************
Marks: 1
Which one of the following calls will open the file test.txt for
reading by fgetc?
Choose one answer.
a. fileopen( "test.txt", "r" );
b. fopen( "test.txt", "r" );**********************************
c. fread( "test.txt" )
d. read( "test.txt" )
4
Marks: 1
Which one of the following could replace the line with ???? in the
code below to display the string 1-2-3-10-5- when the code is
executed?

int x[] = {1, 2, 3, 4, 5};


int u;
int *ptr = x;
????
for( u = 0; u < 5; u++ )
{
printf("%d-", x[u]);
}
printf( " " );
Choose one answer.
a. *ptr[ 3 ] = 10;*********************************
b. *ptr + 3 = 10;
c. *(ptr + 3) = 10;
d. (*ptr)[ 3 ] = 10;
5****************************
Marks: 1
What is the proper declaration for the variable c in the code below?
c = getchar();
Choose one answer.
a. char c;
b. char *c;
c. unsigned char c;
d. unsigned int c;
6
Marks: 1
What will be the output when the code below is executed?
int y[4] = {6, 7, 8, 9};
int *ptr = y + 2;
printf("%d ", ptr[ 1 ] ); /* ptr+1 == ptr[1] */
Choose one answer.
a. 8
b. 7
c. 6
d. 9*******************************
7*****************************
Marks: 1
What will the below sample code produce when executed?
void myFunc (int x)

{
if (x > 0)
myFunc(--x);
printf("%d, ", x);
}
int main()
{
myFunc(5);
return 0;
}

Choose one answer.


a. 0, 0, 1, 2, 3, 4,***************
b. 4, 3, 2, 1, 0, 0,
c. 5, 4, 3, 2, 1, 0,
d. 0, 1, 2, 3, 4, 5,
8
Marks: 1
What is printed when the sample code below is executed?
int y[4] = {6, 7, 8, 9};
int *ptr = y + 2;
printf("%d ", ptr[ 1 ] ); /*ptr+1 == ptr[1]*/
Choose one answer.
a. 8
b. 7
c. 9********************************
d. The code will not compile.
9
Marks: 1
Which one is the correct statement in the following?
Choose one answer.
a. A function can be defined within the main function.
b. A function must have at least one argument.
c. A function need not return a value.************************************
d. A global variable is visible in all blocks and functions in a program.
10*****************************************
Marks: 1

Which is the correct output when the following block of code is executed
int num[5] , *p, i;
p = num;
*p = 10;
p = num + 1;
*p = 20;
p = num;
*(p+2) =30;
for ( i = 0 ; i < 5 ; i++ )
printf ( %d , num[i] );
Choose one answer.
a. 10, 20 , 30
b. 30, 30 , 30
c. null , null , null
d. none of the above********************************
Time Remaining
You are logged in as 080265L LIVERA (Logout)

Potrebbero piacerti anche