You are on page 1of 13

1

ASSIGNMENT PSP(PROBLEM SOLVING THROUGH PROGRAMMING)

Name of Student: UDIT PATHAK

USN:19BTRCI031

Date of Submission:25/03/2020

Branch/Section:CSE-Artificial Intelligence

1. Which one is not a reserve keyword in C Language?


A. auto B. main C. case D. register
ANS: (B) Main

2. The C language consist of number of keywords.


A. 32 B. 40 C. 24 D. 56
ANS: (A) 32

3. Which operator has the lowest priority?


A. ++ B. % C. + D. ||
ANS: (D) ||

4. Which pair of functions below are used for single character I/O?
A. getchar() and putchar() B. scanf() and printf() C. input() and
output() D. None of these
ANS: (A) getchar() and putchar()

5. What is the output of this program?


void main()
{
int a=b=c=100; a=b=c=25;
printf(“\n %d %d %d”, a, b, c);
}
1

UDIT PATHAK (SIMPAD PVT LTD)


A. 25 25 25 B. Compile Time Error C. 100 100 100 D. Three Garbage
Value
ANS: (B) Compile Time Error
R: b and c are not declared,so they cannot be assigned to a,Instead
of a=b=c
if a,b,c are seperately assigned,that would be considered as multiple
declaration
and intialization.

6. Which format specifier is used to print the values of double type


variable?
A. %If B. %Id C. %Iu D. %f
ANS: (A) %lf

7. What will be the output of the following program?


void main ( )
{
double x=28; int r;
R= x%5;
printf (“\n r=%d”, r);
}
A. r= 3 B. Run time Error C. Compile time Error D. None of the
Above
ANS:(C) Compile time error
R: Because 'R' is not declared.

8. Which of the following operator has right to left associativity?


A. && B. // C. % D. sizeof
--ANS: (D) sizeof

9. What will be the value of x after executing the program?


void main ( )
{

UDIT PATHAK (SIMPAD PVT LTD)


int x;
x = printf(“I See, Sea in C”);
printf(“\n x= % d” , x);
}
A. x= 15 B. x=2 C. Garbage value D. Error
ANS: (A) x= 15

10. Study the following C program


void main ( )
{
int a= 0;
for ( ; a ;);
a++;
}
What will be the value of the variable a, on the execution of the
above program
A. I B. 0 C. –1 D. None of these
ANS: (A) 1

11. What will be the output?


void main ( )
{
int I= 48;
printf(“\n %c %d”, I, I );
}
A. Error B. 48 48 C. 1 48 D. 0 48
ANS:(D)0 48
R:Ascii of 48 is 0.

12. A static variable in C by default gets initialized to


A. 0 B. blank space C. 1 D. garbage value
ANS: (A) 0

UDIT PATHAK (SIMPAD PVT LTD)


13. A declaration float a, b; occupies of memory?
A. 1 bytes B. 4 bytes C. 8 bytes D. 16 bytes
ANS: (C) 8 Bytes

14. What is the output of the following program?


void main()
{
int x=40; y=30; z=80;
if(x<y<z)
printf(“\n Hello world”);
else
printf(“\nGood by”);
A. Hello world B. Good by C. Compile time error D. None of these
ANS:(B)Good by

15. Which of the following is not a relational operator?


A. ! B. != C. >= D. <
ANS: (A) !

16. Which of the following is an operator in ‘C’?


A. , B. $ C. @ D. None of these
ANS: (A) comma operator,
R: It is used to link the related expressions together,It is evaluated
from left to right

17. C is a language
A. High Level B. Low Level C. Middle Level D. Machine Level
ANS: (A) High level language
R:It depends upon the condition,If compared to Python,Java it is
low level
If compared to Assembly launguage it is High.

18. C language is available for which of the following Operating

UDIT PATHAK (SIMPAD PVT LTD)


Systems?
A. DOS B. Windows C. Unix D. All of these
ANS: (D) All of these

19. What will be the output of the expression 11 ^ 5?


A. 5 B. 6 C. 11 D. None of these
ANS:(D)None of these

20. Header files in C contain


A. Compiler commands B. Library functions C. Header information of
C programs D. Operators for files
ANS:(A) Compiler commands

21. What will be the output of the following C code?


void main()
{
float x = 0.1;
printf("%d, ", x);
printf("%f", x);
}
A. 0.100000, junk value B. Junk value, 0.100000 C. 0, 0.100000 D. 0,
0.999999
ANS:(B) Junk value,0.100000

22. What will be the output of the following C code?


int main()
{
int i = 23;
char c = -23;
if (i < c)
printf("Yes\n");
else
printf("No\n");

UDIT PATHAK (SIMPAD PVT LTD)


}
A. Yes B. No C. Depends on the compiler D. Depends on the
standard
ANS:(B) No.

23. What will be the output of the following C code? (Assuming that
we have entered the value 1 in the
standard input)
void main()
{
char *ch;
printf("enter a value between 1 to 3:");
scanf("%s", ch);
switch (ch)
{
case "1":
printf("1");
break;
case "2":
printf("2");
break;
}
}
A. 1 2. Compile time error 3. 2 4. Run time error
ANS:(B)Compile time error

24. What will be the output of the following C code?


int main()
{
float f = 1;
switch (f)
{
case 1.0:

UDIT PATHAK (SIMPAD PVT LTD)


printf("yes\n");
break;
default:
printf("default\n");
}
}
A. yes B. yes default C. Undefined behavior D. Compile time error
ANS:(d)Compile time error
R:Case needs float value and the value passed is int.

25. What will be the output of the following C code?


void main()
{
int a = 3;
int b = ++a + a++ + --a;
printf("Value of b is %d", b);
}
A. Value of x is 12 B. Value of x is 13 C. Value of x is 10 D.
Undefined behavior
ANS:(B) Value of x is 13.

26. Which of the following data type will throw an error on modulus
operation (%)?
A. char B. short C. int D. float
ANS:(D) float

27. What will be the output of the following C code?


int main()
{
int a = 10;
double b = 5.6;
int c;
c = a + b;

UDIT PATHAK (SIMPAD PVT LTD)


printf("%d", c);
}
A. 15 B. 16 C. 15.6 D. 10
ANS:(A)15

28. Which of the following is an invalid if-else statement?


A. if (if (a == 1)){} B. if (func1 (a)){} C. if (a){} D. if ((char) a)
{}
ANS: (A) if(if(a==1){}

29. What will be the output of the following C code?


void main()
{
m();
}
void m()
{
printf("hi");
m();
}
A. Compile time error B. hi C. Infinite hi D. Nothing
ANS:(C) Infinite Hi

30. Can we use a function as a parameter of another function? [Eg:


void wow(int func())].
A. Yes, and we can use the function value conveniently
B. Yes, but we call the function again to get the value, not as
convenient as in using variable
C. No, C does not support it
D. This case is compiler dependent
ANS:(C) No, C does not support it.

31. What will be the output of the following C code?

UDIT PATHAK (SIMPAD PVT LTD)


void main()
{
int x = 97;
int y = sizeof(x++);
printf("X is %d", x);
}
A. X is 97 B. X is 98 C. X is 99 D. Run time error
ANS:(A) X is 97.

32. What will be the output of the following C code?


void main()
{
int x = 4;
int *p = &x;
int *k = p++;
int r = p - k;
printf("%d", r);
}
A. 4 B. 8 C. 1 D. Run time error
ANS: (C) 1

33. Which of the following is not a valid variable name declaration?


A. float PI = 3.14; B. double PI = 3.14; C. int PI = 3.14; D. #define
PI 3.14
ANS:(D)#define PI 3.14

34. Which of the following cannot be a variable name in C?


A. volatile B. true C. friend D. export
ANS:(A) Volatile

35. Name the loop that executes at least once


A. for B. if C. while D. do-while
ANS:(D) do-while

UDIT PATHAK (SIMPAD PVT LTD)


36. Convert the decimal number 12.125 to binary.
A. 1100.0110 B. 1110.0010 C. 1100.0010 D. 1010.1100
ANS:(C)1100.0010

37. Which binary value equals 2^-1


A. 1.0000 B. 0.0010 C. 0.0001 D. 0.1000
ANS:(D) 0.1000

38. Which binary value equals 2^1?


A. 0100 B. 0010 C. 0001 D. 1000
ANS:(B) 0010

39. What is the decimal value of 2^-3?


A. 0.25 B. 0.75 C. 0.125 D. 0.8
ANS:(C) 0.125

40. The hexadecimal equivalent of decimal 77 iS


A. 3D16 B. 3E16 C. 5D16 D. 4D16
ANS:(D) 4D

41. Convert the decimal number 14.875 to binary.


A. 1110.0111 B. 1110.1110 C. 1111.1011 D. 1100.1100
ANS:(B)1110.1110

42. Convert decimal 64 to octal.


A. 778 B. 768 C. 1008 D. 1048
ANS:(C)1008

43. The binary equivalent of hexadecimal 10 is


A. 00010000 B. 00110 C. 1010 D. 11000
ANS:(A)00010000

UDIT PATHAK (SIMPAD PVT LTD)


44. The decimal equivalent of the BCD value 1000 0110 iS
A. 8610 B. 7610 C. 8810 D. 8110
ANS:(A) 86

45. Convert the decimal number 3.375 to binary.


A. 0101.1100 B. 0011.1010 C. 0011.0011 D. 0011.0110
ANS:(D)0011.0110

46. Which numbering format can only represent the ten decimal digits?
A. ASCII B. octal C. BCD D. binary
ANS:(C) BCD

47. The BCD equivalent of decimal 912 is


A. 1001 0001 0010BCD B. 1001 1000 0001BCD C. 0111 1111 1110BCD D. 0010
001 1001BCD
ANS:(A) 1001 0001 0010 BCD

48. Convert octal 377 to binary.


A. 11101101 B. 01111011 C. 10110111 D. 11111111
ANS:(D)11111111

49. The binary equivalent of hexadecimal DB is


A. 10110011 B. 11011100 C. 10111011 D. 11011011
ANS:(D)11011011

50. Which numbering format is most commonly used in a computer's


machine language?
A. ASCII B. hexadecimal C. octal D. BCD
ANS:(B) Hexadecimal.

51. C programs are converted into machine language with the help of
A. An Editor B. A compiler C. An operating system D. None of the
above

UDIT PATHAK (SIMPAD PVT LTD)


ANS: (B)Compiler

52. Who is the father of Computer?


A. Allen Turing B. Charles Babbage C. Simur Cray D. Augusta
Adaming
ANS:(B)Charles Baggage

53. CD-ROM stands for


A. Compactable Read Only Memory
B. Compact Data Read Only Memory
C. Compactable Disk Read Only Memory
D. Compact Disk Read Only Memory
ANS:(D) Compact disk read only memory

54. The capacity of 3.5 inch floppy disk is


A. 1.40 MB B. 1.44 GB C. 1.40 GB D. 1.44 MB
ANS:(D)1.44MB

55. What characteristic of read-only memory (ROM) makes it useful?


A. ROM information can be easily updated.
B. Data in ROM is non-volatile, that is, it remains there even without
electrical power.
C. ROM provides very large amounts of inexpensive data storage.
D. ROM chips are easily swapped between different brands of
computers.
ANS: (B) Data in ROM is non volatile,that is,it remains there even
without electric power.

56. Second Generation computers were developed during


A. 1949 to 1955 B. 1956 to 1965 C. 1965 to 1970 D. 1970 to 1990
ANS:(B)1956 to 1965

57. A computer program that translates one program instructions at a

UDIT PATHAK (SIMPAD PVT LTD)


time into machine language is
called a/an
A. Interpreter B. CPU C. Compiler D. Simulator
ANS:(C) Compiler

58. SMPS stands for


A. Switched mode Power Supply B. Start mode power supply C. Store
mode power supply D. Single
mode power supply
ANS:(A) Switched mode power supply

59. The instructions that tell a computer how to carry out the
processing tasks are referred to as
computer.........
A. programs B. processors C. input devices D. memory modules
ANS:(A)Programs

60. Which of the following are the functions of an operating system


A. Allocates resources B. Monitors Activities C. Manages disks and files
D. All of the above
ANS:(D) All of the above

UDIT PATHAK (SIMPAD PVT LTD)

You might also like