Sunteți pe pagina 1din 20

Course: Items Authoring Template - C Assessment Item Subject Area Subject 1 Fundamentals of C Overview of C Programming

Question Level Question Stem

Easy In which of the following category Ansi-C belongs?

Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject

Object-oriented Assembly Strictly-typed Procedural 4

2 Fundamentals of C Overview of C Programming

Question Level Question Stem

Medium Which of the following syntax is correct to include the standard input output header file in a C program?

Option 1 Option 2 Option 3 Option 4 Correct (Option No.)

$include stdio.h #include <iostream.h> #include <stdio.h> void include <stdio.h> 3

Assessment Item Subject Area Subject

3 Fundamentals of C Datatypes and Variables in C

Question Level Question Stem

Easy What are the minimum sizes allowed in bytes for the datatypes int, float and char by Standard C specifications?

Option 1 Option 2 Option 3 Option 4 Correct

1, 2, 4 2, 2, 4 2, 4, 8 4, 8, 16 2

(Option No.)

Assessment Item Subject Area Subject

4 Fundamentals of C Datatypes and Variables in C

Question Level Question Stem

Medium Which of the following floating point value is used to specify double in decimal notation upto 3 digits of precision and leftaligned to 20 character field?

Option 1 Option 2 Option 3 Option 4 Correct (Option No.)

#20.3f %-20.3f $-20.3f %20.3f 2

Assessment Item Subject Area Subject

5 Fundamentals of C Operators and Expressions in C

Question Level Question Stem

Easy What will be the output of the following program?

#include<stdio.h> int main() { int l, m = 5, n = - 9, o = 7, p = 3; l = m++ - --n * o/p; printf("%d",l); return 0; }


Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject 20 28 24 23 2

6 Fundamentals of C Operators and Expressions in C

Question Level

Medium

Question Stem

Which of the following syntax of the printf() should be used to print the statement is Your score in your final result is 89%!

Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject

printf(Your score in your final result is 89\%\!\n); printf(Your score in your final result is 89%!\n); printf(Your score in your final result is 89\%!\n); printf(Your score in your final result is 89%%!\n); 4

13 User defined Datatypes in C Enums in C

Question Level Question Stem

Easy Which of the following is correct about the below mentioned declaration?

typedef enum error {write, compile, execute, display} output;


Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject It is a structure declaration It is a typedef for enum error Compiler error It is a variable error of enum type 2

16 Control Flow and Logical Expressions in C Selection in C

Question Level Question Stem

Easy What will be the output of the following program?

#include<stdio.h> 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

Option 2 Option 3 Option 4 Correct (Option No.)

5 6 11 3

Assessment Item Subject Area Subject

17 Control Flow and Logical Expressions in C Selection in C

Question Level Question Stem

Medium What will be the output of the following program?

#include<stdio.h> 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 Option 2 Option 3 Option 4 Correct (Option No.) 9 12 33 36 3

Assessment Item Subject Area Subject

18 Control Flow and Logical Expressions in C Selection in C

Question Level Question Stem

Hard What will be the output of the following program?

#include<stdio.h> int main() { int x = 5; switch (x)

{ 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 Option 2 Option 3 Option 4 Correct (Option No.) 10 11 5 6 4

Assessment Item Subject Area Subject

19 Control Flow and Logical Expressions in C Iteration in C

Question Level Question Stem

Easy What will be the output of the following code?

#include<stdio.h> int main() { int num = 0; for (num = 1; num < 7; num++); printf("%d", num); return 0; }
Option 1 Option 2 Option 3 Option 4 123456 1234567 0123456 7

Correct (Option No.)

Assessment Item Subject Area Subject

20 Control Flow and Logical Expressions in C Iteration in C

Question Level Question Stem

Medium What will be the output of the following program?

#include<stdio.h> int main() { int a, b; int count = 0; int arr[2][3]; for (a=0; a<3; a++) for (b=0; b<2; b++) { arr[b][a] = count; ++count; printf("%d",arr[b][a]); } return 0; }
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject 0123 012 012345 Syntax error 3

22 Control Flow and Logical Expressions in C Logical Expressions in C

Question Level Question Stem

Easy How is logical OR represented in C language?

Option 1 Option 2 Option 3 Option 4 Correct (Option No.)

&& || OR .OR. 2

Assessment Item Subject Area Subject

25 Functions in C Working with Functions in C

Question Level Question Stem

Easy What will be the output of the following code?

#include<stdio.h> 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 Option 2 Option 3 Option 4 Correct (Option No.) 1--1 2--1 3--1 1--1 2--2 3--3 1--1 1--2 1--3 1--0 1--0 1--0 3

Assessment Item Subject Area Subject

26 Functions in C Working with Functions in C

Question Level Question Stem

Easy Which of the following statement is correct about the program?

#include<stdio.h> int main() {

printf("%p\n", main()); return 0; }


Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject Compiler error for main() used inside printf() Infinite loop without any output No error without any output Runtime error 2

27 Functions in C Working with Functions in C

Question Level Question Stem

Medium Point out the error in the following program?

#include<stdio.h> int 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 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject Compiler error for prototype declaration Compiler error for return statement 30 35 2

28 Functions in C Working with Functions in C

Question Level Question Stem

Hard What will be the output of the following program?

#include<stdio.h> func(int num)

{ num++; return num; } int main() { int func(int); int num = 7; func(num = func(func(num))); printf("%d\n", num); return 0; }
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) 7 8 9 10 3

Assessment Item Subject Area Subject

29 Functions in C Recursive Functions in C

Question Level Question Stem

Easy What is the output of the following code?

#include<stdio.h> 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); }

return num; }
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) 16 20 8 4 2

Assessment Item Subject Area Subject

30 Functions in C Recursive Functions in C

Question Level Question Stem

Medium What is the output of the following code?

#include<stdio.h> int 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 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject 6 20 21 18 3

31 Functions in C Recursive Functions in C

Question Level Question Stem

Hard What will be the output of the following program?

#include<stdio.h> 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 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject Compiler error 0 4 7 11 18 29 47 76 4 7 11 18 29 47 76 123 3 5 8 13 21 34 55 2

32 Functions in C Pointers and Functions in C

Question Level Question Stem

Easy What will be the output of the following code?

#include<stdio.h> char* func(char *ptr) { ptr += 8; return (ptr); }

int main() { char *ptr1, *ptr2; ptr1 = "Hello Brother!"; ptr2 = func(ptr1); printf("%s\n", ptr2); return 0; }
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) rother! Brother! other! rother 3

Assessment Item Subject Area Subject

33 Functions in C Pointers and Functions in C

Question Level Question Stem

Medium What will be the output of the following program?

#include<stdio.h> int main() { int i, arr[] = {3, 4, 8, 1, 5, 7}; func(arr, 5); for(i=0; i<=5; i++) printf("%d, ", arr[i]); return 0; } func(int *j, int num) { int i; for(i=0; i<num; i++) *(j+1) = *(j+i)+5; }
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) 3, 4, 10, 1, 5, 7, 3, 4, 8, 10, 1, 5, 7, 3, 4, 8, 10, 5, 7, 3, 10, 8, 1, 5, 7, 3

Assessment Item Subject Area Subject

34 Functions in C Pointers and Functions in C

Question Level Question Stem

Hard Considering the datatype int is 2 bytes long. What will be the output of the following program?

#include<stdio.h> 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 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject Is He If me 4

35 Arrays, Strings and Pointers in C Introduction to Arrays in C

Question Level Question Stem

Easy What will be the output of the following program?

#include<stdio.h> 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; }

Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject

value of arr[2][1][0] is 55 value of arr[2][1][0] is 4 value of arr[2][1][0] is 7 No output 1

36 Arrays, Strings and Pointers in C Introduction to Arrays in C

Question Level Question Stem

Medium What will be the output of the following program?

#include<stdio.h> int main() { int arr[5], num = -6, z; while(num<5) arr[num] = ++num; for(num=-5; num<5; num++) printf("%d, ", arr[num]); return 0; }
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 4

Assessment Item Subject Area Subject

37 Arrays, Strings and Pointers in C Introduction to Arrays in C

Question Level Question Stem

Hard What will be the output of the following program if the address of array is 346580 assuming each integer occupies four bytes?

#include<stdio.h> int main() { int arr[] = {56, 89, 28, 20, 82, 22, 52}; printf("%u, %u\n", arr+3, &arr+3); return 0;

}
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject 346583, 346583 346584, 346656 346582, 346590 346584, 346590 2

39 Arrays, Strings and Pointers in C Passing Array Values in C

Question Level Question Stem

Medium What will be the output of the following program?

#include<stdio.h> int main() { void func(int, int[]); int arr[] = {11, 22, 33, 44, 55}; int i; func(5, arr); for(i=0; i<5; i++) printf("%d,", arr[i]); return 0; } void func(int num, int arr[]) { int *ptr = 0; int i = 0; while(i++ < num) ptr = &arr[i]; *ptr = 0; }
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject 12, 23, 34, 45, 56, 11, 22, 33, 44, 55, No output Compiler error 2

41 Arrays, Strings and Pointers in C Introduction to Pointers in C

Question Level Question Stem

Easy Which of the following is the correct syntax to make increments in the ptr variable?

void *ptr; userStruct arr[6]; ptr = arr;


Option 1 Option 2 Option 3 Option 4 Correct (Option No.)

ptr ptr ptr ptr


4

= = = =

ptr + sizeof(arr); ++(int*)ptr; ptr + sizeof(ptr); ptr + sizeof(userStruct);

Assessment Item Subject Area Subject

42 Arrays, Strings and Pointers in C Introduction to Pointers in C

Question Level Question Stem

Medium What is the syntax to allocate space for an array of 20 floating points initialized to 0?

Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject

int *ptr = (int *)malloc(20,sizeof(float)); int *ptr = (int *)calloc(20, sizeof(float)); int *ptr = (int *)malloc(20*sizeof(float)); int *ptr = (int *)calloc(20*sizeof(float));
3

43 Arrays, Strings and Pointers in C Introduction to Pointers in C

Question Level Question Stem

Hard Which of the following code snippet will give the output value 3-16-2-0- of the string?

Option 1

#include<stdio.h> int main() {

Option 2

Option 3

Option 4

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; } #include<stdio.h> 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; } #include<stdio.h> 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; } #include<stdio.h> 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; }
4

Correct (Option No.)

Assessment Item Subject Area

44 Arrays, Strings and Pointers in C

Subject

Introduction to Pointers in C

Question Level Question Stem

Hard Which of the following statement can be added to the below mentioned program to exactly display This is my world!?

#include<stdio.h> 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 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject *ptr1 = '\n'; *ptr2 = '\n'; *ptr2 = '\0'; ptr2 = '\0'; 3

49 Arrays, Strings and Pointers in C Working with Strings in C

Question Level Question Stem

Easy What will be the output of the following program?

#include<stdio.h> int main() { char *ptr; char string[] = "Hello World!"; ptr = string; ptr +=5; printf("%s", ptr); return 0; }
Option 1 World!

Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject

-o World! World! World 1

50 Arrays, Strings and Pointers in C Working with Strings in C

Question Level Question Stem

Medium What will be the output of the following program?

#include<stdio.h> #include<string.h> int main() { static char arr[] = "Hello Brother!"; printf("%d\n", *(arr + strlen(arr))); return 0; }
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) 5 14 Compiler error 0 4

Assessment Item Subject Area Subject

55 File I/O in C File Manipulations in C

Question Level Question Stem

Easy Which of the following file function is used to read the specific no. of elements of a binary file?

Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject

fgets() fread() gets() fileread() 2

62 File I/O in C Working with Text and Binary Files in C

Question Level Question Stem

Easy Which of the following syntax is used to open the binary file to write in it?

Option 1 Option 2 Option 3 Option 4 Correct (Option No.)

FILE *f FILE *f FILE *f FILE *f 3

= fwrite(file1.bin, rb+); = fopenb(file1.bin, wb+); = fopen(file1.bin, rb+); = fwrite(file1.bin, b+);

S-ar putea să vă placă și