wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

GNIDOC ROUND 1

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What will be the output of the following code snippet?

#include<stdio.h>

int main()

{

int i;

i = (printf("Welcome"), printf(" To Progeni "));

printf("%d", i);

return 0;

}

a)

a) Welcome To Progeni , error

b)

b) compilation error

c)

c) Welcome To Progeni 12

d)

d) Welcome To Progeni 19

2.

What is the output of below program?

int main()

{

if("0")

{

cout<<"EPUDRAA";

}

else

{

cout<<" THE BOYS";

}

return 0;

}

a)

a)EPUDRAA

b)

b) THE BOYS

c)

c) both a) and b)

d)

d) none

3.

What is the value of p in the following C++ code snippet?

#include <iostream>

using namespace std;

int main()

{

int p;

bool a = true;

bool b = false;

int x = 8;

int y = 2;

p = ((x | y) + (a + b));

cout << p;

return 0;

}

a)

10

b)

11

c)

8

d)

12

4.

What will be the output of the following code snippet?

#include <stdio.h>

int main() {

    printf("%d %d", (032), (27));

    return 0;

}

a)

032 27

b)

32 27

c)

26 27

d)

026 27

5.

By assuming size of int = 8 bytes , char = 1 byte for 64-bit compiler, find the output.

#include <iostream>

#include<string.h>

using namespace std;

int main() {

int *pr[10];

const char *ptr="varta maamey durrr";

char p[]="Eppudra";

cout<<sizeof(pr)<<" ";

cout<<sizeof(ptr)<<" ";

cout<<sizeof(p);

}

a)

a) 80 12 7

b)

b) 10 8 7

c)

c) 80 8 8

d)

d) 80 4 8

6.

What will be the output of the following code snippet? 

#include <stdio.h>

int main() {

bool ok = false;

printf(ok? "YES" : "NO");

return 0;

}

a)

A)Yes

b)

B)No

c)

C)Compilation Error

d)

D)None of the above

7.

What is the search complexity in direct addressing?

a)

a) O(n)

b)

b) O(logn)

c)

c) O(nlogn)

d)

d) O(1)

8.

How many times will ‘I LOVE U’ be printed in the above program?

 #include <stdio.h>

int main()

{

    int i = 1024;

    for (; i; i >>= 1)

        printf("I LOVE U");

    return 0;

}

a)

A) 3000 times

b)

B) infinite times

c)

C) 11 times

d)

D) compile time error 

9.

What will be the output of the following code snippet?

#include <stdio.h>

void solve() {

    int a = 3;

    int res = a++ + ++a + a++ + ++a;

    printf("%d", res);

}

int main() {

solve();

return 0;

}

a)

24

b)

20

c)

18

d)

12

10.

#include <iostream>

using namespace std;

int main() 

{

    int a,rem;

    cin>>a;

    while(a!=0)

    {  

       rem=a%10;

       (rem%2==0)?cout<<'L':cout<<'a';

       a/=10;

    }

    return 0;

}

If the input is 1123345678 what is the output?

a)

a)LaaLaaLaLa

b)

b)LaLaLaaLaa

c)

c)aLaLaaLaaL

d)

d)aaLaaLaLaL

11.

Pick the correct statements.

(i) int array2D[2][3] = {1,2,3,4,5,6};

(ii) int array2D[][3] = {1,2,3,4,5,6};

(iii) int array2D[2][] = {1,2,3,4,5,6};

(iv) int array2D[][] = {1,2,3,4,5,6};

a)

A) Only (i) is correct.

b)

B) Only (i) and (ii) are correct.

c)

C) Only (i), (ii) and (iii) are correct.

d)

D) All (i), (ii), (iii) and (iv) are correct

12.

What will be the output of the following code snippet?

#include <stdio.h>

#include <string.h>

int main()

{

char str[20] = "PROGENI";

int s = strlen(str);

str[3] = '\0';

s += strlen(str);

strcpy(str,"PROGEN");

s += strlen(str);

strcat(str,"PRO");

s += strlen(str);

printf("%d\n",s);

return 0;

}

a)

23

b)

24

c)

25

d)

26

13.

What will be the output of the code snippet?

#include <stdio.h>

int main()

{

    int a,b,c;

    

    a=0x23; b=011;

    c=a+b;

    

    printf("%d",c);

    

    return 0;

}

a)

11

b)

44

c)

66

d)

Error

14.

Find the output of the code snippet.

#include <stdio.h>

using namespace std;

int main()

{

   int num=2;

   while(num==0);

   {

        cout<<"kelambu ";

        num=num-1;

   }

   cout<<num;

   return 0;

}

a)

A.kelambu kelambu 0

b)

B.kelambu kelambu 2

c)

C.kelambu 1

d)

D.compilation error

15.

In C language, FILE is of which data type?

a)

int

b)

char*

c)

struct

d)

None of the above

16.

What will be the output of following program?

#include "stdio.h"

int main()

{

char a[] = { 'A', 'B', 'C', 'D' };

char* ppp = &a[0];

*ppp++;

printf("%c %c ", ++ppp, --ppp);

}

a)

C A

b)

B C

c)

B A

d)

C B

17.

What will be the output of the following code snippet? 

#include <stdio.h>

int main() {

bool ok = false;

printf(ok? "YES" : "NO");

return 0;

}

a)

A)Yes

b)

B)No

c)

C)Compilation Error

d)

D)None of the above

18.

Which of the following is the correct usage of conditional operators used in C?

a)

a) a>b ? c=30 : c=40;

b)

b) a>b ? c=30;

c)

c) max = a>b ? a>c?a:c:b>c?b:c

d)

d) return (a>b)?(a:b)

19.

#include <stdio.h>

#include <string.h>

int main()

{

      for(cout<<"Avengers assemble "; false; )

    {

        cout<<" now";

    }

   return 0;

}

a)

Avengers assemble

b)

Compilation error 

c)

Avengers assemble now

d)

now

20.

#include<iostream>

using namespace std;

int main()

{

char str[10];

cin>>str;

cout<<str;

return 0;

}

Input: Ennada feeling ah?!

a)

Ennada

b)

Ennada feeling ah?!

c)

Ennada fe

d)

Ennada fee

21.

What will be the output of following code snippet?

#include <iostream>

using namespace std;

int main() 

{

    int x=23,y=24;

    x=x++;

    y=y--;

    x==y?cout<<x:cout<<y;

    return 0;

}

a)

Error

b)

23

c)

24

d)

None of the above

22.

If we have a tree of n nodes, how many edges will it have?

a)

a)1

b)

b)(n*(n-1))/2

c)

c)(n*(n-1))

d)

d)n-1

23.

Which part of the program address space is p stored in the following C code?

    #include <stdio.h>

    int *p;

    int main()

    {

        int i = 0;

        p = &i;

        return 0;

    }

a)

a) Code/text segment

b)

b) Data segment

c)

c) Bss segment

d)

d) Stack

24.

what will be the output of the code snippet?

#include <stdio.h>

using namespace std;

int main()

{

    char str1[] = { 'g', 'n', 'i', 'd', 'o' ,'c'};

    char str2[] = "gnidoc";

    printf("%ld,%ld", sizeof(str1), sizeof(str2));

    return 0;

}

a)

6,7

b)

6,6

c)

7,8

d)

8,9

25.

What will be the output of the following code snippet?

#include <stdio.h>

#define CUBE(x) x x x

int main() {

    int ans = 256 / CUBE(4);

    printf("%d", ans);

     return 0;

}

a)

8

b)

4

c)

1024

d)

None of the above