Question: Give the correct answer 1) What will be the output of the following C code? #include void m(int p, int q) { int temp =

Give the correct answer

1) What will be the output of the following C code?

#include

void m(int p, int q)

{

int temp = p;

p = q;

q = temp;

}

void main()

{

int a = 6, b = 5;

m(a, b);

printf("%d %d ", a, b);

}

a) 5 6

b) 5 5

c) 6 5

d) 6 6

2)What will be the output of the following C code?

#include

void m(int p, int q)

{

printf("%d %d ", p, q);

}

void main()

{

int a = 6, b = 5;

m(a);

}

a) 6

b) 6 5

c) 6 junk value

d) Compile time error

3) What will be the output of the following C code?

#include

void main()

{

char *s = "hello";

char *p = s;

printf("%p\t%p", p, s);

}

a) Different address is printed

b) Same address is printed

c) Run time error

d) Nothing

4)What will be the output of the following C code?

#include

void main()

{

char *s= "hello";

char *p = s;

printf("%c\t%c", 1[p], s[1]);

}

a) h h

b) Run time error

c) l l

d) e e

5) What will be the output of the following C code?

#include

int main()

{

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

int *p = ary + 3;

printf("%d ", p[-2]);

}

a) 1

b) 2

c) Compile time error

d) Some garbage value

6)What will be the output of the following C statement? (assuming the input is "cool brother in city")

printf("%s ", argv[argc]);

a) (null)

b) City

c) In

d) Segmentation Fault

7)What is the first argument in command line arguments?

a) The number of command-line arguments the program was invoked with;

b) A pointer to an array of character strings that contain the arguments

c) Nothing

d) None of the mentioned

8)What is argv[0] in command line arguments?

a) The name by which the program was invoked

b) The name of the files which are passed to the program

c) Count of the arguments in argv[] vector

d) None of the mentioned

9)What are the applications of a multidimensional array?

a) Matrix-Multiplication

b) Minimum Spanning Tree

c) Finding connectivity between nodes

d) All of the mentioned

10)What will be the output of the following C code?

#include

int main()

{

int ary[2][3];

foo(ary);

}

void foo(int *ary[])

{

int i = 10, j = 2, k;

ary[0] = &i;

ary[1] = &j;

*ary[0] = 2;

for (k = 0;k

printf("%d ", *ary[k]);

}

a) 2 2

b) Compile time error

c) Undefined behaviour

d) 10 2

11)What will be the output of the following C code?

#include

int main()

{

foo(ary);

}

void foo(int **ary)

{

int i = 10, k = 10, j = 2;

int *ary[2];

ary[0] = &i;

ary[1] = &j;

printf("%d ", ary[0][1]);

}

a) 10

b) 2

c) Compile time error

d) Undefined behaviour

12)What will be the output of the following C code?

#include

int main()

{

int ary[2][3][4], j = 20;

ary[0][0] = &j;

printf("%d ", *ary[0][0]);

}

a) Compile time error

b) 20

c) Address of j

d) Undefined behaviour

13)Which option should be selected to work the following C expression?

string p = "HELLO";

a) typedef char [] string;

b) typedef char *string;

c) typedef char [] string; and typedef char *string;

d) Such expression cannot be generated in C

14)Which of the given option is the correct method for initialization?

typedef char *string;

a) *string *p = "Hello";

b) string p = "Hello";

c) *string p = 'A';

d) Not more than one space should be given when using typedef

15)Which of the following may create problem in the typedef program?

a) ;

b) printf/scanf

c) Arithmetic operators

d) All of the mentioned

16)What does the following C code snippet mean?

char *gets(char *s)

a) reads the next input line into the array s

b) writes the line into the array s

c) reads the next input character into the array s

d) write a character into the array

17)The______function reads atmost one less than the number of characters specified by size from the given stream and it is stored in the string str.

a) fget()

b) fgets()

c) fput()

d) fputs()

18) Choose the correct difference between getc() and fgetc().

a) If it is not a macro, it may evaluate stream more than once

b) if it is amacro, it may not evaluate stream more than once

c) if it is a macro, it may evaluate stream more than once

d) no difference between fgetc() and getc()

19)The ______ function appends not more than n characters.

a) strcat()

b) strcon()

c) strncat()

d) memcat()

20)What is the function of strcoll()?

a) compares the string, result is dependent on the LC_COLLATE

b) copies the string, result is dependent on the LC_COLLATE

c) compares the string, result is not dependent on the LC_COLLATE

d) copies the string, result is not dependent on the LC_COLLATE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!