0
Alien head

C Programming - 2

Description: THIS IS A TEST FOR PRACTISE THE OUTPUT AND SPECIAL FEATURES OF C
Number of Questions: 50
Created by:
Tags: C PROGRAMMING Programming Fundamentals of Computer Programming Computer Basics Integration by Parts Indefinite Integration Integration by Substitution Integration of Special Functions In-Definite Integration
Attempted 0/50 Correct 0 Score 0

What is the value of variable POLYGON?
main()
{

int POLYGON, L, B; L=B =2; POLYGON = (L==B) ? 1 : 0;
}

  1. 0

  2. 1

  3. 2

  4. None of the above


Correct Option: B

If ASCII value of 'x' is 120. What is the value of i = ('x' - 'w')/3?

  1. 1

  2. 2

  3. 0

  4. 4


Correct Option: C

What will be the value of sum after the following program is executed?
main() {
int sum, index; sum = 1; index = 9;
do {
index = index - 1; sum = 2*sum; } while(index >9);

  1. 1

  2. 2

  3. 9

  4. 0.5


Correct Option: B

How many times will the following loop be executed if the input data item is 01234?
while( c = getchar() ! = 0) {

  1. Infinitely

  2. Never

  3. Once

  4. Five


Correct Option: A

What is the final value of digit?
main()
{
int digit; for(digit = 0 ; digit <=9; ++digit)
printf(“%d ”,digit);
digit = 2*digit; --digit; }

  1. 19

  2. -1

  3. 17

  4. 16


Correct Option: A

The library function sqrt operates on a double precision argument. If i is an integer variable, which one of the following calls would correctly compute sqrt(i)?

  1. sqrt((double)i)

  2. (double) sqrt(i)

  3. (double)(sqrt(i))

  4. sqrt(i)


Correct Option: A

If a = 0x6db7 and b = 0xa726, what is the value of a ^ b?

  1. 0x58d9

  2. 0xca91

  3. 0xceb7

  4. 0x2526


Correct Option: B

If a = 0x6db7 and b = 0xa726, then what is the value of a & b?

  1. 0xca91

  2. 0x6db7

  3. 0xab92

  4. 0x2526


Correct Option: D

What would be the output of the follwing program?
sum = 0;
for(i=1;i<10;i++)
if(i%2==0) sum +=i;
printf(“%d”, sum);

  1. 45

  2. 0

  3. 40

  4. 30


Correct Option: D

If a = -11 & b = -3, what is the value of a % b?

  1. -3

  2. -2

  3. 2

  4. 3


Correct Option: B

Suppose i =7, f = 5.5 and c = 'W', what is the value of the given expression?
(c ! = 'p' || i+f <=10)

  1. 1

  2. 0

  3. -1

  4. Not defined


Correct Option: A

Suppose i, j and k are integer variables with values 1, 2, 3 respectively, what is the value of the following expression?!((j+k) > (i+5))

  1. 5

  2. 0

  3. 1

  4. 6


Correct Option: C

The ''puts(argv[0]);'' prints

  1. the name of source file

  2. Argv

  3. the no. of command line arguments

  4. name of executable file


Correct Option: D

If n = 10, then the statement arr[++n] = n++ assigns

  1. 10 to arr[12]

  2. 4 to arr[12]

  3. 4 to arr[11]

  4. compiler dependent


Correct Option: D

Consider the following program fragment.
main()
{
int a,b,c; b=2 ; a= 2*(b++); c = 2*(++b); }
Which one of the following is correct?

  1. a = 4, c = 6

  2. a = 3, c = 8

  3. b = 3, c = 6

  4. a = 4, c = 8


Correct Option: D

What will be the value of i?
int i = 1;
i = i +2*i ++;
printf(“%d”,i);

  1. 4

  2. 1

  3. 3

  4. 2


Correct Option: A

The expression ''4 + 6/3 * 2 - 2 + 7 %3'' is equal to

  1. 3

  2. 4

  3. 6

  4. 7


Correct Option: D

What will be the value of y in the following program fragment?
int y = 10;
If(y++ >9 && y++! = 10 && y++>10)

  1. 10

  2. 11

  3. 12

  4. 13


Correct Option: D

printf( “ab”, “cd”, “ef”); prints

  1. ab

  2. abcdef

  3. abcdef, followed by garbage

  4. none of above


Correct Option: A

The following program fragment prints
int a= 5 , b=2;
printf(“%d” , a+++++b);

  1. 7

  2. 8

  3. 9

  4. none of above


Correct Option: D

The following program results in
main()
{
printf(“%u”, main);

  1. printing of a garbage number

  2. an execution error

  3. printing of starting address of the function main

  4. an infinite loop


Correct Option: C

Consider the following declaration.
int a = 5, b = &a;
printf(“%d”, a
b);The above program prints

  1. 25

  2. garbage

  3. 5 x address of b

  4. error message


Correct Option: D

If 7 bits are used to store a character, the percentage reduction of needed storage will be

  1. 22.5

  2. 2.5

  3. 8

  4. 12.5


Correct Option: D

Consider the declaration.
int a = 5, b = &a;
printf(“%d”, a
*b); prints

  1. 25

  2. garbage

  3. 0

  4. error message


Correct Option: A

The following program prints
main()
{
int i = 5; i = (++i) / (i ++);
printf(“%d”,i);
}

  1. 2

  2. 5

  3. 1

  4. 6


Correct Option: A

Directions: Answer the following question, based on the following declaration.
struct {
char city[10];
char street[20];
int pincode;
} addr;
struct {
char name[20];
int sex ;
addr locate;
} criminal,*kd = &criminal;

The third character in the criminal name can be accessed by

  1. criminal.name[2]

  2. kd->name[2]

  3. (*kd).name[2]

  4. either (2) or (3), but not by (1)


Correct Option: A

The statement fseek(fp,0L,0) means

  1. fp is a file pointer

  2. position the read-write-head at the start of the file

  3. position the read-write-head at the end of the file

  4. erase the contents of the file


Correct Option: A

Directions: Answer the following question based on the following declaration.
struct {
char city[10];
char street[20];
int pincode;
} addr;
struct {
char name[20];
int sex ;
addr locate;
} criminal,*kd = &criminal;

*(kd ->name + 2) can be used instead of

  1. *( criminal.name + 2)

  2. kd -> (name + 2)

  3. *((*kd).name + 2)

  4. either (2) or (3), but not by (1)


Correct Option: A

The following declaration means
int x : 4;

  1. x is a 4-digit integer

  2. x cannot be greater than a 4 digit integer

  3. x is a 4-bit integer

  4. none of above


Correct Option: C

The most significant bit will be lost in

  1. <<

  2. complementation

  3. >>

  4. none of above


Correct Option: A

The declaration
enum cities { bethlehem, jericho, nazareth = 1, jerusalem }
assign(s) the value 1 to

  1. bethlehem

  2. nazareth

  3. bethlehem and nazareth

  4. jericho and nazareth


Correct Option: D

The output of the following program will be
main()
{ int a = 1, b=2, c=3;
printf(“%d”, a+=(a+=3,5,a)); }

  1. 8

  2. 12

  3. 9

  4. 6


Correct Option: A

Directions: Answer the following question based on the following declaration.
struct {
char city[10];
char street[20];
int pincode;
} addr;
struct {
char name[20];
int sex ;
addr locate;
} criminal,*kd = &criminal;

The pincode can be accessed by

  1. criminal.locate.pincode

  2. criminal.pincode

  3. kd->locate.pincode

  4. kd.locate ->pincode


Correct Option: A

If one wants to retain certain bits and set the rest from a given bit pattern, the correct masking operation is

  1. OR

  2. AND

  3. Exclusive OR

  4. Complementation


Correct Option: A

The following statements find the

define hypotenuse(a, b) sqrt( a*a + b*b);

the macro call hypotenuse (a+2,b+3);

  1. hypotenuse of a triangle with sides, a+2 and b+3.

  2. the square root of 3*a + 4*b + 5

  3. the square root of (a+2) 2 + (b+3) 2

  4. none of these


Correct Option: B

If the word size is 16 bit, ~0xc5 will be

  1. 0x3a

  2. 0xff3a

  3. 0x5c

  4. none of above


Correct Option: B

Directions: Answer the following question, based on the following declaration
struct {
char city[10];
char street[20];
int pincode;
} addr;
struct {
char name[20];
int sex ;
addr locate;
} criminal,*kd = &criminal;

The 'sex' can be accessed by

  1. criminal.sex.

  2. kd -> sex.

  3. (*kd).sex.

  4. either (1) or (3) but not by (2)


Correct Option: A

The program
main()
{
float b = 0.7; printf(“%d, %f”,b,b);
}
prints

  1. a garbage value 0.7

  2. 0 ,0.0

  3. 7, 0.7

  4. an error message


Correct Option: B

In a certain machine, the sum of an integer and its 1's complement is 220-1. What is the size of (int), in bits?

  1. 16

  2. 32

  3. Unpredictable

  4. None of above


Correct Option: D

Lint is

  1. a tool for analyzing a C program

  2. an interactive debugger

  3. a C interpreter

  4. a C compiler


Correct Option: D

What is the output of the following 'C' program?
main()
{
printf(“ %x”,-1 >>4);
}

  1. ffff

  2. 0fff

  3. 0000

  4. fff0


Correct Option: A

The statement printf (“%d”, sizeof(“”)); prints

  1. an error message

  2. 0

  3. garbage

  4. 1


Correct Option: D

If y is of integer type, the expressions 3*(y-8)/9 and (y-8)/9*3 yield the same result if

  1. y is an even number

  2. y is an odd number

  3. (y-8) is a multiple of 9

  4. (y-8) is a multiple of 3


Correct Option: C

What header file should be included if you are to develop a function that can accept variable no. of arguments?

  1. vararg.h

  2. stdlib.h

  3. stdio.h

  4. stdarg.h


Correct Option: D

In C language, x = x-y+1; means

  1. x = x-y+1

  2. x = -x-y-1

  3. x = -x + y +1

  4. x = x-y-1


Correct Option: D

What does the statement printf(“%d”,10?0?5:11:12); print?

  1. 10

  2. 0

  3. 12

  4. 11


Correct Option: D

The rule for implicit type conversion in 'C' is

  1. int < unsigned < float < double

  2. unsigned < int < float < double

  3. int< unsigned < double < float

  4. unsigned < int < double < float


Correct Option: A

What does the following C statement print?
print(“%d”, ++5);

  1. 5

  2. 6

  3. 7

  4. An error message


Correct Option: D

What is the output of following 'C' fragment?
For(i=1,j=10;i<6;++i,--j)
printf(“%d%d”,i,j);

  1. 1 10 2 9 3 8 4 7 5 6

  2. 1 2 3 4 5 10 9 8 7 6

  3. 1 1 1 1 1 9 9 9 9 9

  4. None of above


Correct Option: A

Recursive functions are executed in a

  1. last in first out order

  2. first in first out order

  3. parallel fashion

  4. any one of the above


Correct Option: A
+ View questions