Question Bank UNIT I

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

UNIT – I – Question Bank

1 mark question

1. The term computer is derived from the word compute.

2. Some of the application areas of the computer are Education, Entertainment,


Sports, Advertising, Medicine, Science and Engineering, Government, and Home.

3. The steps that are followed by the programmer for writing a program: Problem
Analysis, Program Design, Program Development, and Program Documentation
and Maintenance.

4. Algorithm is an ordered sequence of finite, well defined, unambiguous instructions


for completing a task

5. There are three kinds of control structures. They are Sequential, Selection and
Iterative

6. Sequential - instructions are executed in linear order

7. Selection (branch or conditional) - it asks a true/false question and then selects the next
instruction based on the answer

8. Iterative (loop) - it repeats the execution of a block of instructions.

9. There are two main selection constructs—if-statement and case statement.

10. WHILE and DO-WHILE are the two iterative statements.

11. A flowchart is a diagrammatic representation of the logic for solving a task

12. Pseudo code consists of short, readable and formally-styled English language used for
explaining an algorithm.

13. In a pseudo code, some terms are commonly used to represent the various actions. For
example, for inputting data the terms may be (INPUT, GET, READ).
17. In a pseudo code, some terms are commonly used to represent the various actions. For
example, for outputting data (OUTPUT, PRINT, DISPLAY).

18. In a pseudo code, some terms are commonly used to represent the various actions. For
example, for calculations (COMPUTE, CALCULATE).

19. In a pseudo code, some terms are commonly used to represent the various actions. For
example, for incrementing and decrementing (INCREMENT).

20. In a pseudo code, some terms are commonly used to represent the various actions. For
example, in addition to words like ADD, SUBTRACT, INITIALIZE used for addition,
subtraction, and initialization, respectively.

21. A C program is basically a collection of functions


22. C language is well suited for structure programming.
23. A newline character instructs the computer to move the control to the next line.
24. C program execution begins from main ()
25. const keyword is used to prevent any changes in the variable within a C program
26. What will be output of the following c code?
#include <stdio.h>
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
27. What will be output of the following c code?
#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = y && (y | = 10);
printf("%d\n", z);
return 0;
}
a) 1
b) 0
c) Undefined behavior due to order of evaluation
d) 2

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


#include <stdio.h>
int main()
{
int c = 2 ^ 3;
printf("%d\n", c);
}
a) 1
b) 8
c) 9
d) 0
29. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 4;
float k = 4;
printf("%d", k)
}
error
30. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 1, y = 2;
if (x && y == 1)
printf("true\n");
else
printf("false\n");
}
False

2 marks question

1. What is an algorithm? Enlist the advantages of algorithm.

Algorithm is an ordered sequence of finite, well defined, unambiguous instructions for


Completing a task.
Algorithm is an English-like representation of the logic which is used to solve the problem.
It is a step- by-step procedure for solving a task or a problem. The steps must be ordered,
unambiguous and finite in number.

2. What are the characteristics of algorithms in computer?


 Input
 Output
 Definiteness
 Finiteness
 Effectiveness

3. Write an algorithm to find the maximum among the three numbers.

Step 1: Start.
Step 2: Read the three numbers n1, n2, n3.
Step 3: Compare n1 with n2 and n1 with n3. If n1 is greater display n1 as greater, else n3 is
greater
Step 4: Compare n2 with n3. If n2 is greater display n2 as greater, else n3 is greater.
Step 5: Stop

4. Write an algorithm to find the area and circumference of a circle.

Step 1: Start.
Step 2: Read the values radius
Step 3: Calculate area of circle with product of pi value (3.14) and square of radius, store it as
area.
Step 4: Calculate circumference of circle with product of pi value (3.14) with radius and
constant 2, store it as circumference
Step 5: display area
Step 6: display circumference
Step 7: Stop.
5. Write an algorithm to calculate simple interest.

Step 1: Start.
Step 2: Read Principal Value (P), Rate of Interest (R) and Number of Years (T)
Step 3: Calculate simple interest with the formula, product of Principal value (P), Rate of
Interest (R) and Number of Years (T) whole divided by 100 and store it as SI. Step 4: display
SI
Step 5: Stop.

6. Define flow chart. Why is flow chart required? (or) What are flowcharts and list down
their advantages?

A flowchart is a diagrammatic representation of the logic for solving a task.


The purpose of drawing a flowchart is to make the logic of the program clearer in a visual form.

7. What is control structure?

Control structures specify the statements to be executed and the order of execution of
statements.

8. What is sequential, selection and iterative control structures?

Sequential - instructions are executed in linear order


Selection (branch or conditional) - it asks a true/false question and then selects the next
instruction based on the answer
Iterative (loop) - it repeats the execution of a block of instructions.

9. List down any four standard flowchart symbols and mention its meaning

Sl. No Symbols Name Description


Flow lines Indicates direction of flow
1

Terminator Start or stop of the program


2

Parallelogram Input or Output symbol


3

Rectangle Process or operation


4

5 Diamond Represent decision making and


branching.
6 Connector Connect the flowchart
(circle)
10. What is pseudo code? What is the purpose of it?

Pseudo code consists of short, readable and formally-styled English language used for
explaining an algorithm.
A pseudo code is easily translated into a programming language. Generally, programmers
prefer to write pseudo code instead of flowcharts.

11. Write the pseudo code to find whether the given number is odd or even.

BEGIN
READ value of N.
IF N MOD 2 is equal to 0 THEN
PRINT Even Number
ELSE
PRINT Odd Number
END IF
END

12. Write a pseudo code for swapping two numbers without using temporary
storage.

BEGIN
READ values of num1 and num2
PRINT Before swapping num1 = num1 and num2 = num2.
COMPUTE num1 by adding num1 with num2.
COMPUTE num2 by subtracting num2 from num1.
COMPUTE num1 by subtracting num2 from num1.
PRINT After swapping num1 = num1 and num2 = num2.
END

13. Differentiate between algorithm and pseudo code.


An algorithm is a sequence of instructions used to solve a particular problem. Pseudo code is
a tool to represent the algorithm.

An algorithm can be represented using a pseudo code. Pseudo code is a readable, formally
styled English like language representation of the algorithm. Pseudo code use structured
constructs of the programming language for representation. The user does not require the
knowledge of a programming language to write or understand a pseudo code.

5 marks or 10 marks Questions

1. What are the advantages and disadvantages of C language?


Advantages:-
a. Suitable for creating application
b. software and system software
c. Easy, simple and fast.
d. It can be used for general purpose
e. Powerful language
f. Flexible and portable
Disadvantages:-
a. It is a weakly typed language
b. It needs extra memory space
c. It is not object oriented language

2. What are the characteristics of C language?


 It has many in-built functions
 Pointers can be used
 It is a structured language
 Small and easy to understand
 Efficient programming language
 It can be used in many types of computers

3. Give the structure of a C program


Documentation section
Preprocessor section
Definition section
Global declaration section
Main function()
{
Declaration part;
Executable statements;
}
User defined function()
{
Executable statements;
}

4. What are the steps to execute a C program?


 Create a C program
 Compile the program (Alt+F9)
 Link that program to library
 Execute the program(Ctrl+F9)

5. What is a token? What are the types of Tokens?


 The smallest individual unit of a program is called as Token
 Identifiers, keywords, constants, strings, operators

6. Mention some keywords in C language.


If, else, while, do, for, continue, break, include, main, int, float, char, void.

7. What is a constant?
A constant is a fixed value that cannot be changed in the C program execution.
8. What is a variable?
 A variable is an identifier for memory location
 Data can be stored in it and taken when needed.
9. What is user-defined datatype? What are its types?
User can define a new kind of data type to declare variables. It is called as user-defined
data type.
Types: Typedef, Enumerated
10. What is the difference between local variable and global variable?
Local Variable Global Variable
Defined at starting of a block Declared before the main function
It can be used only within that block It can be used anywhere in the program
ex:- ex:-
int a=10; void main()
void main() {
{ int i=10;
printf(“%d”,i); printf(“%d”,i);
}}
o/p:- 10 o/p:- 10

11. What ate the data types available in C?


 In-built data type (int, char, float, …)
 User defined data type( typedef, enum,struct)
 Derived data type (array, pointer, function)
 No data type (void)

12. What are the basic (or) fundamental datatypes?


 Int – to store numbers without decimal point
 Float – to store numbers with decimal point
 Char – to store a single character
 Double – To store a big decimal point number

13. Write any 6 escape sequences in C.


\n – move to next line
\t – move one space horizontally
\v- move in space vertically
\f – move to next page
\r – move to starting of that line
\b – backspace

14. What are the different types of I/O statements available in C.

1. unformatted I/O statements


- getchar()/ putchar(), getc()/putc(), getch(),getche()/putch(),
gets()/puts()
2. formatted I/o statements
- scanf() / printf()

15. what is the syntax of printf function?


 printf (format_string, list_of_expressions);
where:
 format_string is the layout of what's being printed
 list_of_expressions is a comma-separated list of variables or
expressions yielding results to be inserted into the output

16. what is the syntax of scanf function?
 scanf(format_string, list_of_variable_addresses);

o The format string is like that of printf


o But instead of expressions, we need space to store incoming data, hence the
list of variable addresses
17. Mention some of the format specifiers used with C language.
A conversion specifier is a symbol that is used as a placeholder in a formatting string. For
integer output (for example), %d is the specifier that holds the place for integers.

Here are some commonly used conversion specifiers (not a comprehensive list):

%d int (signed decimal integer)


%u unsigned decimal integer
%f floating point values (fixed notation) - float, double
%e floating point values (exponential notation)
%s string
%c character
18. What will be the outputs for the following program, when the value of I is 5 and 10?
void main()
{
int i;
scanf(“%d”,&i);
if(i=5)
printf(“five”);
}
Output : five since i=5 assigns value of 5 to variable i. so always the if
statement returns true and displays the output as ‘five’.
Part B

1. Explain in detail about algorithm with example?


2. Explain in detail about flowchart with example?
3. Explain in detail about pseudocode with example?
4. Write algorithm, draw flowchart and write the C program for the following program.
a) Area and Circumference of a circle
b) Roots of quadratic equation
c) Total and average of Student
d) To calculate net salary of an employee
e) Biggest of 3 numbers
f) Fibonacci Series
g) Odd or even
h) Leap year or not
i) Swapping of 2 numbers without using 3rd variable
j) Sum of n natural numbers

5. Explain the structure of C.


Include Header file Section

Global Declaration Section

/*
/*Comments
Comments*/ */

main()
{
/* Comments */
main()

Declaration
{ part;
Executable part;
/* Comments */
}
User-defined functions
{
statements;
Declaration part;
}
Executable part;

6. Explain with examples different formatted I/O statements available.

7. Define token. List and explain various types of tokens with example.

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