Download - Rachna C Assessment 19 Sep
-
7/31/2019 Rachna C Assessment 19 Sep
1/20
Course: Items Authoring Template - C
Assessment Item 1Subject Area Fundamentals of C
Subject Overview of C Programming
Question Level EasyQuestion Stem In which of the following category Ansi-C belongs?
Option 1 Object-orientedOption 2 Assembly
Option 3 Strictly-typedOption 4 ProceduralCorrect(Option No.)
4
Assessment Item 2Subject Area Fundamentals of CSubject Overview of C Programming
Question Level MediumQuestion Stem Which of the following syntax is correct to include the standard
input output header file in a C program?
Option 1 $include stdio.hOption 2 #include
Option 3 #include Option 4 void include Correct(Option No.)
3
Assessment Item 3Subject Area Fundamentals of CSubject Datatypes and Variables in C
Question Level Easy
Question Stem What are the minimum sizes allowed in bytes for the datatypes int,float and char by Standard C specifications?
Option 1 1, 2, 4Option 2 2, 2, 4Option 3 2, 4, 8Option 4 4, 8, 16Correct 2
-
7/31/2019 Rachna C Assessment 19 Sep
2/20
(Option No.)
Assessment Item 4Subject Area Fundamentals of CSubject Datatypes and Variables in C
Question Level MediumQuestion Stem Which of the following floating point value is used to specify
double in decimal notation upto 3 digits of precision and left-aligned to 20 character field?
Option 1 #20.3fOption 2 %-20.3fOption 3 $-20.3fOption 4 %20.3f
Correct(Option No.) 2
Assessment Item 5Subject Area Fundamentals of CSubject Operators and Expressions in C
Question Level EasyQuestion Stem What will be the output of the following program?
#include
int main()
{
int l, m = 5, n = - 9, o = 7, p = 3;
l = m++ - --n * o/p;
printf("%d",l);
return 0;
}
Option 1 20Option 2 28Option 3 24Option 4 23
Correct(Option No.) 2
Assessment Item 6Subject Area Fundamentals of CSubject Operators and Expressions in C
Question Level Medium
-
7/31/2019 Rachna C Assessment 19 Sep
3/20
Question Stem Which of the following syntax of the printf() should be used to printthe statement is Your score in your final result is 89%!
Option 1 printf(Your score in your final result is 89\%\!\n);Option 2 printf(Your score in your final result is 89%!\n);
Option 3 printf(Your score in your final result is 89\%!\n);Option 4 printf(Your score in your final result is 89%%!\n);Correct(Option No.)
4
Assessment Item 13Subject Area User defined Datatypes in CSubject Enums in C
Question Level EasyQuestion Stem Which of the following is correct about the below mentioned
declaration?typedef enum error {write, compile,
execute, display} output;
Option 1 It is a structure declarationOption 2 It is a typedef for enum errorOption 3 Compiler errorOption 4 It is a variable error of enum type
Correct(Option No.)
2
Assessment Item 16
Subject Area Control Flow and Logical Expressions in CSubject Selection in C
Question Level EasyQuestion Stem What will be the output of the following program?
#include
int main()
{
int num = 6;
if ( num == 5 );
num = 0;
if ( num = 6 )num++;
else num +=5;
printf("%d", num);
return 0;
}
Option 1 7
-
7/31/2019 Rachna C Assessment 19 Sep
4/20
Option 2 5Option 3 6Option 4 11Correct(Option No.)
3
Assessment Item 17Subject Area Control Flow and Logical Expressions in CSubject Selection in C
Question Level MediumQuestion Stem What will be the output of the following program?
#include
int main()
{
int l = 7;
int m = 3;char optr = "*";
switch (optr)
{
default : l += 2;
case '+' : l += m;
case '*' : l *= m;
case '-' : l -= m;
}
printf("%d", l);
}
Option 1 9Option 2 12Option 3 33Option 4 36Correct(Option No.)
3
Assessment Item 18Subject Area Control Flow and Logical Expressions in CSubject Selection in C
Question Level HardQuestion Stem What will be the output of the following program?
#include
int main()
{
int x = 5;
switch (x)
-
7/31/2019 Rachna C Assessment 19 Sep
5/20
{
default:
;
case 4:
x += 6;
if (x == 9){
x++;
if(x == 10 ) break;
x *=2;
}
x -= 5;
break;
case 9:
x +=6;
break;
}
printf("%d\n", x);
return 0;
}
Option 1 10Option 2 11Option 3 5Option 4 6Correct(Option No.)
4
Assessment Item 19Subject Area Control Flow and Logical Expressions in CSubject Iteration in C
Question Level EasyQuestion Stem What will be the output of the following code?
#include
int main()
{
int num = 0;
for (num = 1; num < 7; num++);
printf("%d", num);
return 0;
}
Option 1 123456Option 2 1234567Option 3 0123456Option 4 7
-
7/31/2019 Rachna C Assessment 19 Sep
6/20
Correct(Option No.)
4
Assessment Item 20Subject Area Control Flow and Logical Expressions in C
Subject Iteration in C
Question Level MediumQuestion Stem What will be the output of the following program?
#include
int main()
{
int a, b;
int count = 0;
int arr[2][3];
for (a=0; a
-
7/31/2019 Rachna C Assessment 19 Sep
7/20
Assessment Item 25Subject Area Functions in CSubject Working with Functions in C
Question Level Easy
Question Stem What will be the output of the following code?#include
void func()
{
int i = 0;
static int j = 0;
i++, j++;
printf("%d - - %d\n", i, j);
}
int main()
{func();
func();
func();
return 0;
}
Option 1 1 - - 12 - - 13 - - 1
Option 2 1 - - 12 - - 2
3 - - 3Option 3 1 - - 1
1 - - 21 - - 3
Option 4 1 - - 01 - - 01 - - 0
Correct(Option No.)
3
Assessment Item 26Subject Area Functions in C
Subject Working with Functions in C
Question Level EasyQuestion Stem Which of the following statement is correct about the program?
#include
int main()
{
-
7/31/2019 Rachna C Assessment 19 Sep
8/20
printf("%p\n", main());
return 0;
}
Option 1 Compiler error for main() used inside printf()Option 2 Infinite loop without any outputOption 3 No error without any output
Option 4 Runtime errorCorrect(Option No.)
2
Assessment Item 27Subject Area Functions in CSubject Working with Functions in C
Question Level MediumQuestion Stem Point out the error in the following program?
#includeint main()
{
int func(int);
int i;
i = func(35);
printf("%d\n", i);
return 0;
}
int func(int num)
{
num > 35? return(30): return(35);}
Option 1 Compiler error for prototype declarationOption 2 Compiler error for return statementOption 3 30Option 4 35Correct(Option No.)
2
Assessment Item 28Subject Area Functions in C
Subject Working with Functions in C
Question Level HardQuestion Stem What will be the output of the following program?
#include
func(int num)
-
7/31/2019 Rachna C Assessment 19 Sep
9/20
{
num++;
return num;
}
int main(){
int func(int);
int num = 7;
func(num = func(func(num)));
printf("%d\n", num);
return 0;
}
Option 1 7Option 2 8
Option 3 9Option 4 10Correct(Option No.)
3
Assessment Item 29Subject Area Functions in CSubject Recursive Functions in C
Question Level Easy
Question Stem What is the output of the following code?#include
int result(int,int);
int main()
{
int x = 5, y = 4, num;
num = result(x,y);
printf("%d", num);
return 0;
}
int result(int x, int y)
{
static int num=0, i=0;
if(i < x)
{
num = num + y;
i++;
result(x,y);
}
-
7/31/2019 Rachna C Assessment 19 Sep
10/20
return num;
}
Option 1 16Option 2 20Option 3 8Option 4 4Correct(Option No.)
2
Assessment Item 30Subject Area Functions in CSubject Recursive Functions in C
Question Level MediumQuestion Stem What is the output of the following code?
#includeint main()
{
int num = 6, ans;
ans = func(num);
printf("%d", ans);
return 0;
}
int func(num)
{
static int ans = 0;if(num>0)
{
ans = ans + num;
func(num-1);
}
return ans;
}
Option 1 6Option 2 20Option 3 21
Option 4 18Correct(Option No.)
3
Assessment Item 31Subject Area Functions in CSubject Recursive Functions in C
-
7/31/2019 Rachna C Assessment 19 Sep
11/20
Question Level HardQuestion Stem What will be the output of the following program?
#include
void output(int);
int main(){
int k, num = 7;
long int i = 0, j = 1, f;
printf("%d ",0);
output(num);
return 0;
}
void output(int num){
static long int one = 1, two = 3, sum;
if( num > 0){sum = one + two;
one = two;
two = sum;
printf("%ld ",sum);
output(num-1);
}
}
Option 1 Compiler errorOption 2 0 4 7 11 18 29 47 76
Option 3 4 7 11 18 29 47 76 123Option 4 3 5 8 13 21 34 55Correct(Option No.)
2
Assessment Item 32Subject Area Functions in CSubject Pointers and Functions in C
Question Level EasyQuestion Stem What will be the output of the following code?
#include
char* func(char *ptr)
{
ptr += 8;
return (ptr);
}
-
7/31/2019 Rachna C Assessment 19 Sep
12/20
int main()
{
char *ptr1, *ptr2;
ptr1 = "Hello Brother!";
ptr2 = func(ptr1);
printf("%s\n", ptr2);return 0;
}
Option 1 rother!Option 2 Brother!
Option 3 other!Option 4 rotherCorrect(Option No.)
3
Assessment Item 33Subject Area Functions in CSubject Pointers and Functions in C
Question Level MediumQuestion Stem What will be the output of the following program?
#include
int main()
{
int i, arr[] = {3, 4, 8, 1, 5, 7};
func(arr, 5);for(i=0; i
-
7/31/2019 Rachna C Assessment 19 Sep
13/20
Assessment Item 34Subject Area Functions in CSubject Pointers and Functions in C
Question Level Hard
Question Stem Considering the datatype int is 2 bytes long. What will be theoutput of the following program?
#include
void func(char**);
void func(char **ptr)
{
char *ptr;
ptr = (ptr+= sizeof(int))[-1];
printf("%s\n", ptr);
}
int main()
{
char *argv[] = {"if", "he", "is", "me"};
func(argv);
return 0;
}
Option 1 IsOption 2 HeOption 3 IfOption 4 me
Correct(Option No.)
4
Assessment Item 35Subject Area Arrays, Strings and Pointers in CSubject Introduction to Arrays in C
Question Level EasyQuestion Stem What will be the output of the following program?
#include
int main()
{int arr[3][2][2]={12,4,4,2,5,6,23,-
4,7,4,55,-3};
printf("value of arr[2][1][0] is %d",
arr[2][1][0]);
return 0;
}
-
7/31/2019 Rachna C Assessment 19 Sep
14/20
Option 1 value of arr[2][1][0] is 55Option 2 value of arr[2][1][0] is 4Option 3 value of arr[2][1][0] is 7
Option 4 No outputCorrect
(Option No.)
1
Assessment Item 36Subject Area Arrays, Strings and Pointers in CSubject Introduction to Arrays in C
Question Level MediumQuestion Stem What will be the output of the following program?
#include
int main()
{
int arr[5], num = -6, z;while(num
-
7/31/2019 Rachna C Assessment 19 Sep
15/20
}
Option 1 346583, 346583Option 2 346584, 346656Option 3 346582, 346590Option 4 346584, 346590
Correct(Option No.)
2
Assessment Item 39Subject Area Arrays, Strings and Pointers in CSubject Passing Array Values in C
Question Level MediumQuestion Stem What will be the output of the following program?
#include
int main()
{void func(int, int[]);
int arr[] = {11, 22, 33, 44, 55};
int i;
func(5, arr);
for(i=0; i
-
7/31/2019 Rachna C Assessment 19 Sep
16/20
Question Level EasyQuestion Stem Which of the following is the correct syntax to make increments in
the ptr variable?
void *ptr;
userStruct arr[6];
ptr = arr;
Option 1 ptr = ptr + sizeof(arr);
Option 2 ptr = ++(int*)ptr;
Option 3 ptr = ptr + sizeof(ptr);
Option 4 ptr = ptr + sizeof(userStruct);
Correct(Option No.)
4
Assessment Item 42Subject Area Arrays, Strings and Pointers in C
Subject Introduction to Pointers in C
Question Level MediumQuestion Stem What is the syntax to allocate space for an array of 20 floating
points initialized to 0?
Option 1 int *ptr = (int
*)malloc(20,sizeof(float));
Option 2 int *ptr = (int *)calloc(20,
sizeof(float));
Option 3 int *ptr = (int*)malloc(20*sizeof(float));
Option 4 int *ptr = (int
*)calloc(20*sizeof(float));
Correct(Option No.)
3
Assessment Item 43Subject Area Arrays, Strings and Pointers in C
Subject Introduction to Pointers in C
Question Level HardQuestion Stem Which of the following code snippet will give the output value 3-1-
6-2-0- of the string?
Option 1 #include
int main()
{
-
7/31/2019 Rachna C Assessment 19 Sep
17/20
int str[] = {3, 1, 6, 5, 0};
int num;
int *ptr = str;
*ptr + 3 = 2 ;
for (num = 0; num < 5; num++ )
printf("%d-", str[num]);return 0;
}
Option 2 #include
int main()
{
int str[] = {3, 1, 6, 5, 0};
int num;
int *ptr = str;
(*ptr)[3] = 2 ;
for (num = 0; num < 5; num++ )
printf("%d-", str[num]);
return 0;
}
Option 3 #include
int main()
{
int str[] = {3, 1, 6, 5, 0};
int num;
int *ptr = str;
*(ptr[ 3]) = 2 ;
for (num = 0; num < 5; num++ )
printf("%d-", str[num]);
return 0;}
Option 4 #include
int main()
{
int str[] = {3, 1, 6, 5, 0};
int num;
int *ptr = str;
*(ptr + 3) = 2 ;
for (num = 0; num < 5; num++ )
printf("%d-", str[num]);
return 0;}
Correct(Option No.)
4
Assessment Item 44Subject Area Arrays, Strings and Pointers in C
-
7/31/2019 Rachna C Assessment 19 Sep
18/20
Subject Introduction to Pointers in C
Question Level Hard
Question Stem Which of the following statement can be added to the belowmentioned program to exactly display This is my world!?
#include
int main()
{
char arr1[] = " This is my world!";
char arr2[25];
char *ptr1, *ptr2;
ptr1 = arr1;
ptr2 = arr2;
while(*ptr1)
*ptr2++ = *ptr1++;
/* Add a statement here */
printf("%s\n", arr2);
return 0;
}
Option 1 *ptr1 = '\n';
Option 2 *ptr2 = '\n';Option 3 *ptr2 = '\0';Option 4 ptr2 = '\0';Correct(Option No.)
3
Assessment Item 49Subject Area Arrays, Strings and Pointers in CSubject Working with Strings in C
Question Level Easy
Question Stem What will be the output of the following program?
#include
int main()
{
char *ptr;
char string[] = "Hello World!";ptr = string;
ptr +=5;
printf("%s", ptr);
return 0;
}
Option 1 World!
-
7/31/2019 Rachna C Assessment 19 Sep
19/20
Option 2 -o World!Option 3 World!Option 4 WorldCorrect(Option No.)
1
Assessment Item 50Subject Area Arrays, Strings and Pointers in CSubject Working with Strings in C
Question Level MediumQuestion Stem What will be the output of the following program?
#include
#include
int main()
{
static char arr[] = "Hello Brother!";printf("%d\n", *(arr + strlen(arr)));
return 0;
}
Option 1 5Option 2 14Option 3 Compiler errorOption 4 0Correct(Option No.)
4
Assessment Item 55Subject Area File I/O in CSubject File Manipulations in C
Question Level Easy
Question Stem Which of the following file function is used to read the specific no.of elements of a binary file?
Option 1 fgets()
Option 2 fread()Option 3 gets()Option 4 fileread()Correct(Option No.)
2
Assessment Item 62Subject Area File I/O in CSubject Working with Text and Binary Files in C
-
7/31/2019 Rachna C Assessment 19 Sep
20/20
Question Level EasyQuestion Stem Which of the following syntax is used to open the binary file to
write in it?
Option 1 FILE *f = fwrite(file1.bin, rb+);Option 2 FILE *f = fopenb(file1.bin, wb+);Option 3 FILE *f = fopen(file1.bin, rb+);Option 4 FILE *f = fwrite(file1.bin, b+);Correct(Option No.)
3