Home
Current Affairs January 2024

What is the correct answer?

4

What would be the output of the following program?
int x=40;
main(){
int x=20;
printf("
%d",x);
}

A. 40

B. 20

C. Compilation Error

D. Garbeg Value

Correct Answer :

B. 20


20 Because whenever there is a conflict between a local and a global variable, it is the local variable gets priority.

Related Questions

What is the correct answer?

4

gets() and puts() are unformatted I/O functions.

A. True

B. False

What is the correct answer?

4

The statement "for (i = 0, j = 2; j <= 10; j++)" is a valid statement in 'C'.

A. True

B. False

What is the correct answer?

4

Only one break can be used in one loop.

A. True

B. False

What is the correct answer?

4

Which of the following is not recommended in a header file?

A. Type definitions (typedefs)

B. Class definitions

C. Function definitions

D. Template definitions

What is the correct answer?

4

The output of the following code is:
void main() 
{
int a = 0;
while (a<=50) for(;;) if(++a % 50==0) break;
printf("a = %d", a);
}

A. a = 100

B. a = 50

C. compilation error

D. runtime error

What is the correct answer?

4

fprintf()function can be used to write into console.

A. True

B. False

What is the correct answer?

4

The value of an enumerated datatype can be read using scanf() function.

A. True

B. False

What is the correct answer?

4

Each pass through a loop is called a/an

A. enumeration

B. iteration

C. culmination

D. pass through

What is the correct answer?

4

printf() is not a library function.

A. True

B. False

What is the correct answer?

4

The expression (i + j)++ is illegal.

A. True

B. False

What is the correct answer?

4

The printf() function retunes which value when an error occurs?

A. Positive value

B. Zero

C. Negative value

D. None of these

What is the correct answer?

4

The output of the following code is:
void main() 
{
int a;
int &b = a;
a=100;
printf("b=%d\ta=%d
", b,a);
}

A. b=100 a=100

B. b=100 a=0

C. b=0 a=100

D. Error

What is the correct answer?

4

struct stud
{
int roll;
char name[20];
float marks;
} *p;
What will be the byte size of p?

A. 24

B. 2

C. 26

D. None

What is the correct answer?

4

The expression "int i = j = k = 0;" is invalid.

A. True

B. False

What is the correct answer?

4

continue statement is used

A. to go to the next iteration in a loop

B. come out of a loop

C. exit and return to the main function

D. restarts iterations from beginning of loop

What is the correct answer?

4

The main() function can be called from any other function.

A. True

B. False

What is the correct answer?

4

------ is the ternary operator

A. ?,-

B. ?,:

C. ++<--

D. none of the above

What is the correct answer?

4

In the expression - 'x + y + 3z =20'

A. x + y' is a keyword

B. 3 and 20 are constants

C. 3z is a constant

D. y is a variable and z is a constant

What is the correct answer?

4

Which of the following is not a standard exception built in C++.

A. std::bad_creat

B. std::bad_alloc

C. std::bad_cast

D. std::bad_typeid

What is the correct answer?

4

Every if statement can be converted into an equivalent switch statement.

A. True

B. False

What is the correct answer?

4

The expression "b = 3 ^ 2;" will evaluate b = 9.

A. True

B. False

What is the correct answer?

4

What will be output if you will compile and execute the following c code?
#include 
int main(){
int i=320;
char *ptr=(char *)&i;
printf("%d",*ptr);
return 0;
}

A. 1

B. 64

C. 320

D. Compiler Error

What is the correct answer?

4

The contents of a file opened in 'r+' mode cannot be changed.

A. True

B. False

What is the correct answer?

4

The -------------------------- loop executes at least once.

A. for

B. while

C. do-while

D. while & do-while

What is the correct answer?

4

The expression 'int j = 6 + 3 % -9;' evaluates to -1.

A. True

B. False

What is the correct answer?

4

Character data types cannot be declared as unsigned.

A. True

B. False

What is the correct answer?

4

The output of the following code is:
main() 
{
int a = 5, b = 6;
(a == b? printf("%d", a));
}

A. 0

B. 5

C. Error

D. None of the above

What is the correct answer?

4

All macro substitutions in a program are done before compilation of the program.

A. True

B. False

What is the correct answer?

4

A function to be called must be ended with a----------------

A. .

B. ?

C. ;

D. none of the above

What is the correct answer?

4

Which of the following keyword supports dynamic method resolution?

A. abstract

B. Virtual

C. Dynamic

D. Typeid