0% found this document useful (0 votes)
32 views

Day 27 Multiple

C programming notes 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Day 27 Multiple

C programming notes 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Multiple choice Types

Write the program in system and compile it , then write the output

1 Which of the following statement swap between two numbers

a. a=(a+b)-(b=a)
b. a=(a-b)-(b=a)
c. b=(b+a)+(a=b)
d. b=(b-a)-(a=b)
2 Which of the following statement is same as a==b

a. a<b || a>b
b. a<b && a>b
c. a>b || b>a
d. a>=b && b>=a
3 What is the output of this C code?
#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
**m = 6;
printf("%d\n", k);
}
a. 5
b. 6
c. Compilation error
c) None
4 Which of the following statement is same as -1^n

a. return n&1 ? -1 : 1;
b. return n&1 ? 1 : 0;
c. return n&0 ? -1 : 1;
d. none
5 Find maximum and minmum of two numbers without using relational operators

a. ((a+b) + abs(a-b))/2, (a+b)-(abs(a-b))/2


b. ((a-b) + abs(a+b))/2, (a+b)+(abs(a-b))/2
c. (a+ abs(a+b))/2, (b-(abs(b-a))/2
d. none
6 #include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int **r = &p;
printf("%d %d", *r, **r);
}
a. address of a and 1
b. address of p and and address of a
c. address of r and value of r
d. address of p and 1
7 The recursive functions are executed in a
a. Parallel Order
b. First In First Out order
c. Last In First Out order
d. Iterative order
8 Which of the following statement is same as f(7)=4 or f(4)=7

a. return x|3
b. return x&3
c. return x^3
d. none
9 Finding square root of a number

a. exp(log(n)/2))
b. exp(log(n)/log(2))
c. pow(n,2)/(log(n)/2)
d. none
10 int main()
{
int i=-3, j=2, k=0, m;
m = ++i && ++j || ++k;
printf("%d, %d, %d, %d\n", i, j, k, m);
}
a. 1,2,0,1
b. -3,2,0,1
c. -2,3,0,1
d. 2,3,1,1
11 Which is the character array used to accept command line arguments?
a. char argv
b. char* argv[]
c. char argv[]
d. char* argv
12 void main()
{
m();
void m()
{
printf(“SimpleWay2Code”);
}
}
a. SimpleWay2Code
b. Compile time error
c. Nothing
d. Varies
13 What is the output
#include "stdio.h"
main()
{
char *str=NULL;
strcpy(str,"cquestionbank");
printf("%s",str);
}

a. cquestionbank
b. cquestionbank\0
c. compilation error
d. run time error
14 Given the below statements about C programming language is true

a. main() function should always be the first function present in a C program file
b. all the elements of an union share their memory location
c. A void pointer can hold address of any type and can be typcasted to any type
d. A static variable hold random junk value if it is not initialized
15 What is the task of pre-processor?

a. Expanding
b. Compiling
c. Linking
d. All of the above
16 Which of the following statements about stdout and stderr are true?

a. They both are the same


b. Run time errors are automatically displayed in stderr
c. Both are connected to the screen by default.
d. stdout is line buffered but stderr is unbuffered
17 When a + b is divided by 12 the remainder is 8, and when a – b is divided by 12 the remainder
is 6. If a > b, what is the remainder when ab divided by 6?
a. 3
b. 1
c. 5
d. 4
18 Which of the following is a most perfect declaration

a. char p[]={'i','n','d','i','a',' ','i','s',' ','b','e','s','t'};


b. char q[]={'i','n','d','i','a',' ','i','s',' ','b','e','s','t','\0'};
c. char r[]="india is best";
d. char *s="india is best";
19 What is the major difference between strcpy and strncpy function

a. strcpy() takes two parameters, but strncpy() takes three parameters


b. strcpy() , copy whole string but strncpy(), copy only specified number of characters
c. strcpy() copy string with nul character , but strncpy() does't copy nul character
d. none
20 Which of the following is not a string function

a. strcpy()
b. strcat()
c. strupr()
d. strstr()
21 void main()
{
int i=10;
int *ip=&i;
int **ipp=&&i;
printf("%d %d %d",i,ipp,*ipp);
}
a. address of i , address of i, address of p
b. address of i , address of i, address of 10
c. 10,address of ip, addressof i
d. compile time error
22 Comment on the following

Const int *ptr;


a. We cannot change the value pointed by ptr
b. We cannot change the pointer ptr itself
c. Both of the above
d. We can change the pointer as well as the value pointed by it.
23 Difference between calloc() and malloc()

a. calloc() takes single argument while malloc() takes two arguments


b. malloc() takes a single argument while calloc() takes two arguments
c. malloc() initializes the allocated memory to ZERO and calloc() initializes the allocated
memory to NULL
d. malloc() memory allocation is 1-D array equivalent and calloc() memory allocation is 2-D
array equivalent.
24 Find the output
void main()
{
int num=345,m,sum=0;
do
{
m=num%10;
num=num/10;
continue;
sum=sum*10+m;
}
while(num!=0);
printf("%d",sum);
}
a. 3 4 5
b. 5 4 3
c. 0
d. None of these
25 Find output
main()
{
int x;
int a=5;
x= 30 || --a;
printf("%d",a);
}
a. 5
b. 4
c. 1
d. compilation error
26 Find the output
void main()
{
int x=0;
if( !x>0)
printf(“C ”);
printf(“Marathon”);
else
printf(“at LIT”);
}
a. C Marathon
b. C at LIT
c. at LIT
d. Compilation error
27 Which of the following is true about functions?

a. The formal parameters are also known as arguments.


b. A static function will not be known outside its source file.
c. Functions have internal linkage by default.
d. All the above
28 Find the output
main()
{
show(2);
}
int show(int n)
{
if(n>0)
{
printf("%d ",n);
show(n-1);
show(n-1);
}
}
a. 1 1 2
b. 1 2 1
c. 2 1 1
d. 2 2 1
29 How many times "hello" will be displayed

main()
{
int i=1;
if(i<=100)
{
printf("Hello");
i=i+5;
main();
}
}
a. 20 times
b. 100 times
c. infinite times
d. stack overflow
30 main()
{
char x[]="c at lit-2018";

printf("%s",x+x[0]-x[2]);
}
a. c at lit-2018
b. at lit-2018
c. lit-2018
d. none

You might also like