PPS - Unit 1-Question Bank

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 16

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

FACULTY OF ENGINEERING AND TECHNOLOGY


RAMAPURAM CAMPUS, CHENNAI-600 089

DEPARTMENT OF COMPUTER SCIENCE


AND
ENGINEERING

PROGRAMMING AND PROBLEM SOLVING - 21CSS101J


Year: I
QUESTION BANK

UNIT I [CLO 1]
PART – A
MULTIPLE CHOICE QUESTIONS

1. Who is father of C Language?


A. Bjarne Stroustrup
B. Dennis Ritchie
C. James A. Gosling
D. Dr. E.F. Codd
Ans: B

2. C Language developed at ?
A. AT & T's Bell Laboratories of USA in 1972
B. AT & T's Bell Laboratories of USA in 1970
C. Sun Microsystems in 1973
D. Cambridge University in 1972
Ans: A

3. For 16-bit compiler allowable range for integer constants is ?


A. -3.4e38 to 3.4e38
B. -32767 to 32768
C. -32768 to 32767
D. -32668 to 32667
Ans: C

4. 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
Ans: B

5. A C variable can start with


A. An alphabet
B. A number
C. A special symbol other than underscore
D. keyword
Ans: A

1
6. Which of the following is allowed in a C Arithmetic Instruction?
A. []
B. {}
C. ()
D. ||
Ans: C

7. Which of the following is the correct hierarchy of arithmetic operations?


A. / + * -
B. * -/ +
C. + - / *
D. * / + -
Ans: D

8. Program which is written originally by the programmer is classified as


A. object code
B. machine code
C. source program
D. interactive programs
Ans: C

9. Which operator has the lowest priority?


A. ++
B. %
C. +
D. ||
Ans: D

10. comment is correct s about the ++ operator among the following


A.It is not an unary operator
B.The operator can come between the operands
C.operand It can be applied to an expression
D.It associates from the right
Ans: D

11. An assembler trAnslates


A. machine code into assembly code
B. assembly code into machine code
C. processing time into manual time
D. routine into subroutine
Ans: B

12. Name given by a programmer to any particular data is classified as


A. identifier
B. identification
C. exponent
2
D. mantissa
Ans: A

13. The ternary conditional expression using the operator?: could be easily coded using ------------
----- statement
a) Nested if
b) if-else
c) if
d) for
Ans: b

14. The statement when executed in a switch statement causes immediate exit
from the structure.
a) goto
b) default
c) break
d) switch
Ans: c

15. Variable which uses the same name in whole program and in its all routines thus
best classified as

3
A. middle variable
B. default variable
C. local variable
D. global variable
Ans: D

16. Statement which is used to make choice between two options and only option is to be
performed is written as
A. if statement
B. if else statement
C. then else statement
D. else one statement
Ans: A

17. The statement is used to trAnsfer the control to the end of statement block in a
loop:
a. Continue
b. Break
c. Switch
d. Goto
Ans b

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


a) int _a3;
b) int a_3;
c) int 3_a;
d) int _3a
Ans: c

19. All keywords in C are in


a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None of the mentioned
Ans: a

20. Which of the following is true for variable names in C?


a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length
Ans: c

21. The format identifier ‘%i’ is also used for _ data type?
a) char
b) int
c) float
d) double
Ans: b

22. In an expression involving || operator, evaluation

4
a. Will be stopped if one of its components evaluates to false
b. Will be stopped if one of its components evaluates to true
c. Takes place from right to left
d. Takes place from left to right
And: d

23. What is the output of this C code? [PLO 3]


#include <stdio.h>
int main()
{
signed char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}
a) 128
b) -128
c) Depends on the compiler
d) 1
Ans: b

24. What is the output of this C code?


#include <stdio.h>
int main()
{
j = 10;
printf("%d\n", j++);
return 0;
}
a) 10
b) 11
c) Compile time error
d) 0
Ans: c

25. The following code ‘for( ; ; )’ represents an infinite loop. It can be terminated by
a) break
b) exit(0)
c) abort()
d) all of the mentioned
Ans: a

26. The keyword ‘break’ cannot be simply used within:


a) do-while
b) if-else
c) for
d) while
Ans: b

27. Which keyword is used to come out of a loop only for that iteration?
a) break
5
b) continue
c) return
d) none of the mentioned
Ans: b

28. The first step in problem solving is ---------------


a) Understand the problem
b) Identify the problem
c) Developing algorithm/Flowchart
d)Listing the possible outcome
Ans: b

33In C programming language, which of the following type of operators have the highest
precedence
a. Relational operators
b. Logical operators
c.Arithmetic operators
d.Equality operators
Ans: d

34. The solution can be reached by completing the actions in steps. These steps are called
a) Sequence
b)Algorithm
c) Flowchart
d)Steps
Ans: b

38-------------------meAns the set of instructions that make up the solution after they have been
coded into a programming language.
a) solution
b) result
c) program
d) error
Ams: c

39. A language applied for wide range of application is called as language


a. Special purpose
b)General purpose
c. Individual purpose
d)Scientific purpose
Ans: b

40. Compiler converts the source code into


a. C code
b. Byte code
c. Object code
d. Executable code
Ans: c

41. converts source code to machine language one line at a time.


a. Compiler

6
b. Interpreter
c. Assembler
d.CPU
Ans: b

42. The program that converts high level language to a machine language is called
a. Interpreter
b. Linker
c. Compiler
d.Loader
Ans: c

43. ‘#’ symbol is known to be


a. Linker
b.Compiler
c. Assembler
d.Preprocessor directive
Ans: d

44. A is a notational system for describing computations in both machine and


human readable form
a. Programming language
b.Machine language
c. High-level language
d.Assembly language
Ans: a

45 program converts assembly language into machine language


a. compiler
b. interpreter
c. assembler
d. preprocessor directive
Ans: c

46 is a distinguishing characteristic of human excellence in every area of behavior


a) creativity
b) thinking
c) visualization
d) problem solving
Ans: a

47. Which of the following is the correct way of writing comments?


a)*/comments/*
b)/*comment*/
c)**comment**
d){comment}
Ans: b

48. C programming language is


a)object oriented programming language
b)Procedure oriented programming language
7
c)function oriented programming language
d)Unstructured programming language
Ans: b

49. The memory space taken for a char type data is


a) 2 bytes
b)4 bytes
c) 8 bytes
d)1bytes
Ans: d

50 .The memory space taken for aint type data is


a) 2 bytes
b) 4 bytes
c) 8 bytes
d)10bytes
Ans: a

51. What is the only function all programs must contain ?


a)start()
b)system()
c)main()
d)program
Ans: c

52.For 16-bit compiler allowable range for integer constants is ?


a) -3.4e38 to 3.4e38
b) -32767 to 32768
c) -32668 to 32667
d) -32768 to 32767
Ans: d

53.Every statement in C program is to be terminated by a


a) dot(.)
b)semi-colon(;)
c) colon(:)
d)Question mark(?)
Ans: b

54. which of the following will not valid expressions in C?


a) a=2+(b=5);
b) a=11%3
c) a=b=c=5
d) b+5=2
Ans: d
55. The----------------------operator is true only when both the operands are true.
a) &&
b) b) ||
c) c)!
d) d) ?:
Ans: a

8
56. The-----------------------statement when executed in a switch statement causes immediate exit
from the structure.
a) goto
b) default
c) break
d) switch
Ans: c

56. The ternary conditional expression using the operator?: could be easily coded using ------------
----- statement
a) Nested if
b) if-else
c) if
d) for
Ans: b

1. he------------------------operator is true only when both the operands are true.


a) &&
b) ||
c)!
d)?
Ans: a

2. The ternary conditional expression using the operator?: could be easily coded using ------------
statement
a) Nested if
b) if-else
c) if
d) for
Ans:b

3. The expression!(x!=y) can be replaced by the expression--------------------


a) x!=y
b) x==y
c)x=!y
d)!x=!y
Ans:c

4. int a=10;
++a;
a++;
Printf(“%d”,a);
a) 10
b) 11
c)12
d) 13
Ans: c
9
5. int a=11;
a=a%2;
a=a/2;
printf(“%d”,a);
a) 1
b) 5
c) 0
d)0.5
Ans: c

6. #include <stdio.h>
int main()
{
int i = 3;
printf("%d", (++i)++);
return 0;
}
What is the output of the above program?
a) 3
b) 4
c) 5
d) Compile-time error
Ans: d

7. Which of the following is not a logical operator?


a) &&
b) !
c) ||
d) |
Ans: d

Ans : d

8. Give the output for below code


int main()
{
int a = 1;
int b = 1;
int c = a || --b;
int d = a-- && --b;
printf("a = %d, b = %d, c = %d, d = %d", a, b, c, d);
return 0;
}
a) a = 0, b = 1, c = 1, d = 0
b) a = 0, b = 0, c = 1, d = 0
c) a = 1, b = 1, c = 1, d = 1
d) a = 0, b = 0, c = 0, d = 0
Ans : b

9. What is the output of below code?


int main
{
int a = 10, b = 20, c = 30;
10
if (c > b > a)
printf("TRUE");
else
printf("FALSE");
return 0;
}
a) TRUE
b) FALSE
c) Compiler Error
d) Output is compiler dependent
Ans: b

10.int main() {
int a = 1;
int b = 0;
b = a++ + a++;
printf("%d %d",a,b);
return 0;
} Find the output of the code
a) 3 6
b) Compiler Dependent
c) 3 4
d) 3 3
Ans:b

11
11. What is the output of this C code?

int main()
{
int i = -5;
int k = i %4;
printf("%d\n", k);
}
a) Compile time error
b) -1
c) 1
d) Run time error
Ans: b

12.What is the value of x in this C code?


void main()
{
int x = 4 *5 / 2 + 9;
}
a) 6.75
b) 1.85
c) 19
d) 3

Ans: c

13.#include <stdio.h>
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:d

14. int main()


{
printf("before continue ");
continue;
printf("after continue\n");
}
a.Before continue after continue
b.Before continue
c.after continue
d.Compile time error
Ans:d

28. What is the output of the code given below?


12
int main()
{
printf("%d ", 1);
goto l1;
printf("%d ", 2);
l1:goto l2;
printf("%d ", 3);
l2:printf("%d ", 4);
}
a.1 4
b.Compilation error
c.1 2 4
d.1 3 4
Ans:a

29. What is the output of code given below?


int main()
{
printf("%d ", 1);
l1:l2:
printf("%d ", 2);
printf("%d\n", 3);
}

a.Compilation error
b.1 2 3
c.1 2
d.1 3
Ans : b

30. Result of a logical or relational expression in C is?


a. True or False
b. 0 or 1
c. 0 if expression is false and any positive number if expression is true
d. None of the mentioned
Ans:b

31. Ternary operator operates on how many operands


a) 1
b) 2
3)3
d)4
Ans: c

32. Which Operator has the lowest precedence


a) sizeof
b) b)unary
c) c)assiignment
d) d)comma
13
Ans: d
UNIT I [CLO 1][CLO 6] PART –B
4 MARKS
1. Comment “C is mid level language”?
2. What is problem solving?
3. What are the six steps of problem solving?
4. Discuss about how the problems can be solved with computers?
5. What is a program?
6. Why is problem analysis important?
7. What are the tools of problem solving available?
8. How do problem-solving tools help in leading to a solution?
9. Why it is important to test a solution before coding it?
10.What is an algorithm? Give the characteristics of the algorithm.
11.What is a flowchart? Give the symbols/shapes used in the flowchart.
12.Define pseudocode and give its importance with an example.
13. Discuss the difficulties with problem solving in detail.
14. State the use of %d and %f .Write a printf statement in C using the above mentioned
symbols? 15.What is main difference between variable and constant?
16.Explain bitwise left shift operator?
17.Explain primary data types used in C?
18.Difference between formatted & unformatted statement ?
19.What is meant by storage class of variable?
20. Explain with example ++i and i++.
21. Explain about arrow operator in C.
22. What are the non-numeric data types in C ?
23. Draw a flow chart to check if a number is even.
24. What are the various data types that the scanf statement can handle
1. Give the general syntax of conditional operator?
2. Define operator in C. What role an operator plays in C program?
3. Differentiate between relational and logical operators used in C?

UNIT-1 [CLO 1]
PART -C
12 MARKS
1) Explain the evolution of programming languages.
2) Explain the various steps involved in problem solving with diagram.
3) Draw the flowchart and write the algorithm and c code to find the sum and to reverse the digits
of given five-digit number.
4) Write an algorithm and draw a flow chart to find the factorial and Fibonacci series of given number.

5) Write a note on Algorithm, Flow chart and Pseudocode.


6) Explain the scope, lifetime of variable in C with example.
7) Write down the algorithm to find the largest number among three given numbers and outline the
steps in the algorithm with the inputs 5, 17, 3.
8) Draw flowchart to compute the salary of an employee in a company. Assume that there are two
types of employees in the company daily wages and regular. Salary is calculated as number of hours
worked* wages per hour for daily wagers and basic pay +(% of DA * basic pay)/100 + HRA + medical
allowance for regular employees. Sketch the flow of your design for a regular employee with basic pay
= 5000, % of DA = 75 % and HRA = 500. (8)
9) Explain in detail about operators with an example
10) Refer all elab Programs
11) Draw a flowchart and write an algorithm and the code in C to find the sum of two numbers
and return the digit in lowest places value.
12) Draw a flowchart and write an algorithm to find the product of two numbers without using the “*”
14
operator.
13) Draw a flowchart and write an algorithm to find if a string is a palindrome.

15
16

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy