A - B. C. D .: Int Fun Is Overrided With Extern Int Fun

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

C PROGRAMMING APTITUDE TEST 1

TIME: 20 MINUTES

1.Is there any difference between following declarations?


1:
extern int fun();
2:
int fun();
A
Both are identical
.
B.No difference, except extern int fun(); is probably in another file
C.int fun(); is overrided with extern int fun();
D
None of these
.

2. By default a real number is treated as a


A
float
.

B.double

C.long double

D
far double
.

3
. Is the following statement a declaration or definition?

extern int i;
A
Declaration
.

B.Definition

C.Function

D
Error
.

4.

What will you do to treat the constant 3.14 as a long double?


A
use 3.14LD
.

B.use 3.14L

C.use 3.14DL

D
use 3.14LF
.

5
. We want to round off x, a float, to an int value, The correct way to do is

A y = (int)(x + 0.5)

B.y = int(x + 0.5)

ROLL NO:

.
C.y = (int)x + 0.5

D
y = (int)((int)x + 0.5)
.

FIND THE OUTPUT OF THE FOLLOWING CODE SNIPPETS


6.
int main()
{
float a=0.7;
if(a < 0.7)
printf("C\n");
else
printf("C++\n");
return 0;
}

A
C
.
C.Compiler error
7.

B.C++
D.Non of above

#include<stdio.h>
#include<math.h>
int main()
{
printf("%f\n", sqrt(36.0));
return 0;
}

A
6.0
.
C.6.000000

B.6
D.Error: Prototype sqrt() not found.

8. int main()
{
int x = 10, y = 20, z = 5, i;
i = x < y < z;
printf("%d\n", i);
return 0;
}

A
0
.
C.Error

B.1
D.None of these

9.
1. What is the correct value to return to the operating system upon the successful
completion of a program?
A. -1

B. 1
C. 0
D. Programs do not return a value.
10.
int main()
{
void v = 0;
printf("%d", v);
return 0;
}

A
Error: Declaration syntax error 'v' (or) Size of v is unknown or zero.
.
B.Program terminates abnormally.
C.No error.
D
None of these.
.
11.

Which of the following special symbol


allowed in a variable name?
A
* (asterisk)
.
C.- (hyphen)

B.| (pipeline)
D._ (underscore)

12. Which header file should be included to use functions like malloc() and calloc()?
A
memory.h
.

B.stdlib.h

C.string.h

D
dos.h
.

13. #include <stdio.h>


int main(void)
{
int i = 3;
int j;
j = sizeof(++i + ++i);
printf("i=%d j=%d\n", i, j);
return 0;

A
I=4 j=2
.
C. i=5 j=2

B. i=3 j=2
D. Undefined behaviour

14. #include<stdio.h>
int main()
{
int y=128;
const int x=y;
printf("%d\n", x);
return 0;
}

A
128
.
C.Error

B.Garbage value
D.0

15.
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;

A
20
.
C.Garbage Value

B.0
D.Error

16.
int main()
{
int X=40;
{
int X=20;
printf("%d ", X);
}
printf("%d\n", X);
return 0;
}

A
extern int a is declaration, int a = 20 is the definition
.
B.int a = 20 is declaration, extern int a is the definition
C.int a = 20 is definition, a is not defined
D a is declared, a is not defined

.
17. Write the output(if any) of the given program (2 marks). If error, mention the
error & reason.
void abc()
{
auto int b=0;
Static int s;
s=0;
++s;
++b;
printf(%d %d \n , b, s);
}
void main()
{
abc(); abc(); abc();

}
18. Write a program to swap two numbers without using a temporary variable. (2
marks)

You might also like