Documente Academic
Documente Profesional
Documente Cultură
Option 1 Option 2 Option 3 Option 4 Correct (Option No.) Assessment Item Subject Area Subject
Medium Which of the following syntax is correct to include the standard input output header file in a C program?
Easy What are the minimum sizes allowed in bytes for the datatypes int, float and char by Standard C specifications?
1, 2, 4 2, 2, 4 2, 4, 8 4, 8, 16 2
(Option No.)
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?
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
Easy Which of the following is correct about the below mentioned declaration?
#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
5 6 11 3
#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
{ 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
#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
#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
&& || OR .OR. 2
#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
#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
{ 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
#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
#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
#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
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
#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
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
#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
#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
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
#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
Easy Which of the following is the correct syntax to make increments in the ptr variable?
= = = =
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
Hard Which of the following code snippet will give the output value 3-16-2-0- of the string?
Option 1
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
Subject
Introduction to Pointers in C
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
#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
#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
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
Easy Which of the following syntax is used to open the binary file to write in it?