Sie sind auf Seite 1von 20

Integral University, Lucknow

Question Bank
Course Code :
Course Name :

EC-208

Credits : 4

Date : 15.12.2016

PROGRAMMING CONCEPTS

Units to be covered in Mid-Sem Exam 1 :

1&2

Mid-Sem Exam 2 : 3 & 4

Difficulty Index: easy (A); moderate (B); difficult (C)


Unit
1

Q. No.

Question

What is the first stage of problem solving?


a) Structuring the Problem
b) Looking for possible solution
c) Problem Identification
d) Making a Decision
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
Which of the following is not a valid C variable
name?
a) int number;
b) float rate;
c) int variable_count;
d) int $main;
Variable names beginning with underscore is not
encouraged. Why?
a) It is not standardized
b) To avoid conflicts since assemblers and
loaders use such names
c) To avoid conflicts since library routines
use such names
d) To avoid conflicts with environment
variables of an operating system
Which of the following is not a valid variable
name declaration?
a) int __a3;
b) int __3a;
c) int __A3;
d) None of the mentioned

UNIT-1

Max.
marks
1

Difficulty
Index
A

All keywords in C are in


a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None
The list of coded instructions is called
a) Computer Program
b) Algorithm
c) Flowchart
d) Utility Program

What will happen if the below program is 1


executed?

#include <stdio.h>
int main()
{
int main = 3;
printf("%d", main);
return 0;
}
a) It will cause a compile-time error
b) It will cause a run-time error
c) It will run without any error and prints 3
d) It will experience infinite looping
9

10

11
12

Comment on the output of this C code?

#include <stdio.h>
int main()
{
int ThisIsVariableName = 12;
int ThisIsVariablename = 14;
printf("%d", ThisIsVariablename);
return 0;
}
a) The program will print 12
b) The program will print 14
c) The program will have a runtime error
d) The program will cause a compile-time
error due to redeclaration.
An assembly language is a
1
a) low level programming language
b) Middle level programming language
c) High level programming language
d) Internet based programming language
Variables created in MATLAB can be seen in 2
_______________.
Programming in _______________________are 2

A
A

13

14

15
16

17
18

difficult to modify.
________________is a program that translate
mnemonic
statements
into
executable
instructions.
The program which acts as a interface between a
user and a the hardware is called an
__________________.
The Kite Box in Flowchart is used for depicting
____________ Statements.
Structured program can be easily broken down
into routines or _______that can be assigned to
any number of programmers.
A group of 4(four) bits is called a ___________.
The ______________ is a program planning tool
that allows the programmers to plan program
logic by writing program instruction in an
ordinary language.

2
2

A
B

19

The Selection logic is also called as a


_______________.

20

_________________ in a program improves its


readability and understanding.
What is pseudo code? How it is used as a
problem-solving tool.
What is an Interpreter and a Compiler?
What are the different Flowcharting Symbols?
What function does each represent?
Write an Algorithm to compute the sum of the
digits of any given number.
Write an Algorithm to find sum of the series
1+4+9+16+25+... upto n terms.
Explain the concept of Fourth Generation
Language.
Discuss by differentiating the concept of
algorithm and flow-chart.
Draw the flowcharts for selection logic.
What is machine language? How does machine
language differ from high level language?
List the differences between an Assembler and a
Compiler.
Design an Algorithm to generate N Fibonacci
Numbers.
Make a Flowchart to calculate the Factorial of a
Number.
What is Pseudocode? Why it is so called? Write
another name for pseudocode. Discuss the
advantages and limitations of pseudocode.
What is an assembly language for a computer? Is
assembly language to machine language

2
2

A
B

4
4

A
B

21
22
23
24
25
26
27
28
29
30
31
32
33

34

35

36

37
38
39

40

translation one-to-one or one-to-many? What is


an assembler?
List the main characteristic features of high level
programming language. Why high level
programming languages are easier to learn and
use?
What do you mean by Algorithm. What are the
different types of algorithm used? What are the
properties of good algorithm? Discuss about
termination, correctness and execution of an
algorithm.
Differentiate between a Flowchart and
Algorithm.
What are the advantages of high level languages
over machine language? Explain.
A company XYZ plans to give a 10% year-end
bonus to each of its employees earning Rs.
15,000 or more per year, and fix a bonus of Rs.
2,000 to all other employees. Draw a flow chart
to calculate total salary including bonus.
What is 4GL? Write down its advantages over
third generation languages.

Solutions for Question #1-20:

Unit-1
Question
No.
1
2
3
4
5
6
7
8
9

10
11

Answer
(c). Problem Identification
(c). According to the syntax for C variable name, it cannot start with a digit.
(d). Since only underscore and no other special character is allowed in a variable
name, it results in an error.
Answer: c
Answer: d
Answer: a
Answer: a
Answer: c
Explanation: A C program can have same function name and same variable name.
Output: 3
Answer: b
Explanation: Variable names ThisIsVariablename and ThisIsVariableName are
both distinct as C is case sensitive.
Output: 14
Answer: a
Workspace

12
13
14
15
16
17
18
19
20

Unit
2

Machine Level Language


Assembler
Operating System
Decision
modules
nibble
Pseudo code
Decision Logic
Indentation

Q. No.

Questions

A GUI:
a) uses buttons, menus, and icons.
b) should be easy for a user to manipulate.
c) stands for Graphic Use Interaction.
d) Both a and b.
IDE is:
a) Independent Development Enterprise
b) A development environment for machine
language
c) An Integrated Development Environment
for Visual Basic
d) A software project management tool
Which of the following is not part of the IDE:
a) Code editor window
b) Properties window
c) Form layout window
d) General window
The application name always appears in the:
a) Properties window
b) Title bar
c) Intermediate window
d) Code window
In the IDE, which of following is used to design
the layout of an application?
a) Form Designer window
b) Project Explorer window
c) Context Menu
d) Form Layout window
Testing helps to ensure _______of the program
for use within a system:
a) Quality, accuracy and except
b) Quality, accuracy and acceptance
c) Design, assurance and acceptance
d) Quality, accuracy and development

UNIT-2

Max.
marks
1

Difficulty
Index
A

The first procedure-oriented language was:


a) FORTRAN
b) BASIC
c) COBOL
d) ADA

Event-driven languages are:


a) FORTRAN based
b) Are used to write procedural languages
c) OOP
d) Designed to make programming the GUI
easier.
Which is not a feature of a GUI that makes
learning a program easy for users?
a) Online help
b) Dialog boxes
c) Detailed key strokes and commands
d) Icons
With A = False and B = True, which statement
evaluates as False?
a) A OR A
b) A OR B
c) B OR A
d) B OR B
The __________ of a button is one of its
properties.
The property used to display information in a
TextBox is _______
If you want to display text that cannot be
modified by the user, use the __________.
If you want to display text that can be modified
by the user, use the __________.
When you declare a variable or a named
constant, Visual Basic reserves an area of
memory and assigns it a name called a
________.
You are designing a form and it will be
necessary for the user to type in their name. You
should use a _____________ for inputting the
users name.
Data whose value may not be changed during the
execution of a project is referred to as a
___________.
The address of external function in the assembly
source file is supplied by a __________ when
activated.
___________ errors are not detected by
assemblers.
__________ serves as the purpose of

10

11
12
13
14
15

16

17

18

19
20

21
22
23
24
25
26
27
28

29
30
31
32
33

34

35
36
37
38
39

40

documentation only.
Differentiate between testing and debugging.
What is the importance of documentation in
computer program?
What is IDE? Write a short note on it.
Write short note on Graphical User Interface
(GUI).
Explain the need for Program Documentation.
Explain Interpreter.
Explain the Compiler.
Discuss the various features of a GUI. Illustrate
some steps to design a GUI for Starting and
Stopping an Induction Motor.
What is Syntax Error?
What is a logical Error?
How will you Debug a Program? Illustrate with
examples.
What will you do if you encounter a Compiler
Error?
What is testing of a program? Why do we need
to test a program? What are the different types of
test data used for testing a program?
Is it easier to detect a syntax error or a logic error
in a program? Write reasons in support of your
answer.
What is an iterative debugger? What special
features are made available by a debugger?
Differentiate between compiler and interpreter.
Write down the basic functionality of linker and
editor in the context of programming.
What are different types of program error?
Explain them in brief with example.
Describe different types of documentation
normally used for documenting software
systems.
Illustrate the steps for documenting a typical
Antivirus Software.

Solution to questions #1-20 of Unit-2:

Unit-2
Question
No.
1
2
3

Answer
Answer: d
Answer: c
Answer: d

2
2

A
A

2
2

B
B

2
2
4
4

C
C
A
A

4
4

B
C

8
8

B
B

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Unit
3

Answer: b
Answer: a
Answer: b
Answer: a
Answer: d
Answer: c
Answer: a
color
text
Label control
TextBox control
identifier
Textbox
constant
linker
Logical
List

Q. No.
1

Questions
Types of loop control statements are:
a) For loop
b) While loop
c) Do-while loop
d) All of these
What is the output of this C code?

Max.
marks
1

Difficulty
Index
A

#include <stdio.h>
int main()
{
int x = 1;
if (x > 0)

UNIT-3

printf("inside if\n");
else if (x > 0)
printf("inside elseif\n");
}

a) inside if
b) inside elseif
c) inside if
inside elseif
d) Compile time error
What is the output of this C code?
#include <stdio.h>
int main()
{
int x = 0;
if (x == 0)
printf("true, ");

else if (x = 10)
printf("false, ");
printf("%d\n", x);
}

a) false, 0
b) true, 0
c) true, 10
d) Compile time error
_______ statement is an unconditional transfer
of control statement:
a) Goto
b) Continue
c) Switch
d) All of these
Which of the following is a relational operator?
a) AND
b) <
c) +
d) &
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
String operation such as strcat(s, t), strcmp(s, t),
strcpy(s, t) and strlen(s) heavily rely upon.
a) Presence of NULL character
b) Presence of new-line character
c) Presence of any escape sequence
d) None of the mentioned
What is the output of this C code(When 2 is
entered)?
#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("1\n");
break;
printf("hi");
default:
printf("2\n");

}
}

10

11
12
13

14
15

16
17
18
19
20
21
22
23

a) 1
b) hi 2
c) Run time error
d) 2
The correct syntax for running two variable for
loop simultaneously is.
a) for (i = 0; i < n; i++) for (j = 0; j < n; j
+= 5)
b) for (i = 0, j = 0;i < n, j < n; i++, j += 5)
c) for (i = 0; i < n;i++){}
for (j = 0; j < n; j+= 5){}
d) None of the mentioned
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
A ________ is 4 bytes wide, whereas a
__________is 8 bytes wide.
The
constant
6.68L
represents
a
_______________ constant.
A _________ statement is generally best to use
when you have more than two conditional
expressions based on a single variable of
numeric type.
The compiler converts your C/C++ instructions
into __________.
To expose a data member to the program, you
must declare the data member in the _____
section of the class.
The output of the following expression
3>6&&7>4 will be _______________.
In C, input/output function prototypes and
macros are defined in ____________ header file.
The command used to round off a value from
1.66 to 2.0 is ___________.
The default data type in MATLAB is
____________.
Size of short integer and long integer can be
verified using the ______________ operator.
Using loops print numbers between 100 and 999,
using C code.
Write a program in C to find the area and
perimeter of a circle.
Write a C program to count number of character

24
25
26

27
28
29
30

31
32
33

34
35

36

37

38

39

in a string.
Write a program in C to reverse a number check
whether the number is palindrome or not.
Write a program in C to check whether a given
number is prime or not.
Write a program in C to input a name and reverse
it and check whether the string is Palindrome or
not.
Write a program in C to print the numbers from 4
to 9 and their squares.
Write a C program to count number of character
in a string.
What are the different types of control statements
available in 'C'? Explain with an example
Write a loop that will calculate sum of every
third integer, beginning with i=2 for all values of
i that are less than 100. Write the loop in
two different ways:
i. Using a do-while statement.
ii. Using a for statement.
What are the conditional statements? When it is
needed and how it can be used in programming?
Write a program in C for swapping two elements
using third variable.
Write the syntax for scanf and printf functions of
C assuming the variable under consideration is a
character.
Write a program in C to find the number of
vowels in a given string.
Write a program in C to input a three digit
number and check whether the number is an
Armstrong Number or not.
Ex: 153= 13+53+33= 1+125+27.
Explain the two way selection (if, if-else, nested
if-else, cascaded if-else) in C language with
syntax.
A C program contains the following declaration.
static int x[8] = {10, 20, 30, 40, 50, 60, 70, 80};
i. What is the meaning of x?
ii. What is the meaning of (x+2)?
iii. What is the value of *x?
iv.
What is the value of (*x+2)?
v.
What is the value of *(x+2)?
Write a program in C to find sum of given series
by using function with argument and return
value: e = 2 + 3/1! 6/2! + 9/3! 12/4! !
Differentiate between local and global variable.
Write a C program to illustrate the effect of

40

global variable on the output of a program.


Write a few lines of codes in C to show the use 8
of conditional operator to find minimum of the
three given numbers.

Solution to questions #1-20 of Unit-3:

Unit-3
Question
No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Answer

16
17
18
19
20

false
stdio.h
ceil()
double
sizeof()

Answer: d
Answer: a
Answer: b
Answer: a
Answer: b
Answer: b
Answer: a
Answer: d
Answer: b
Answer: a
float, double
long double
switch
object code
public

Unit
4

Q. No.
1

Questions
What is the output of this C code?

Max.
marks
1

Difficulty
Index
A

1. #include <stdio.h>
2.

int main()

3.

4.

char *a[2] = {"hello", "hi"};

5.

printf("%s", *(a + 1));

6.

return 0;

7.

a) hello
b) ello
c) hi
d) ello hi
Advantage of a multi-dimension array over pointer 1
array.
a) Pre-defined size.
b) Input can be taken from user.
c) Faster Access.
d) All of the mentioned
Which of the following operation is possible using a 1
pointer char?
(Assuming declaration char *a;)
a) Input via %s
b) Generation of multidimensional array
c) Changing address to point at another location
d) All of the mentioned
What is the output of this C-code?
1

UNIT-4

1. #include <stdio.h>
2.

void main()

3.

4.

int a[3] = {1, 2, 3};

5.

int *p = a;

6.
7.

printf("%p\t%p", p, a);
}

a) Same address is printed.


b) Different address is printed.
c) Compile time error
d) Nothing
What is the output of this C-code?

1. #include <stdio.h>
2.

void main()

3.

4.

char *s= "hello";

5.

char *p = s;

6.

printf("%c\t%c", p[0], s[1]);

7.

a) Run time error


b) h h
c) h e
d) h l
Consider the following code:

2
2

A
B

int i,j:
int ctr = 0;
int myArray[2][3];
for(i=0;i<3;i++)
for(j=0;j<2;j++)
{
myArray[j][i]=ctr;
ctr++;
}

10

11
12
13
14
15

What is the value of myArray[1][2]?


a) 2
b) 3
c) 1
d) 5
A multidimensional array can be expressed in terms of
a) Array of pointers rather than as pointers to a
group of continuous array
b) Array without the group of continuous array
c) Data type array
d) None of these
Maximum number of elements in the array declaration
int a[5] [8] is
a) 28
b) 32
c) 35
d) 40
If the size of the array is less than the number of
initialises then,
a) Extra values are being ignored
b) Generates an error message
c) Size of array is increased
d) Size is neglected when values are given
Array subscripts in C always start at
a) -1
b) 0
c) 1
d) Value provided by the user
String is an array of character arrays terminated
with__________.
An array is the ____________data type
Array can be initialized, provided they are both
_________ and _________.
The syntax for the declaration of array is
___________________.
The index of the last element of an array of n

16
17
18
19

20
21
22
23
24
25

26
27
28

29

30
31
32
33

34

35

elements will be______.


If u declare an array without initializing the value to it
then it will be set to___________________.
In C, if you pass an array as an argument to a function,
___________________ of the array gets passed.
An array elements are always stored in ________
memory locations.
Size of the array need not be specified, when it is
declared
as
a
formal
parameter
and
the__________________ is a part of definition.
If the two strings are identical, then strcmp() function
returns__________.
Explain Array?
Explain Pointer?
Differentiate between Dynamic and Static Memory
Allocation.
Write a program to calculate the sum of all the rows of
a matrix.
Distinguish between the following two declarations:
i.
int(*m)[5] ; and
ii.
int*m[5];
Write a C program to find transpose of a matrix.
What is Insertion Sort? Write a program in C to sort
the list of integers using insertion sort.
What do you understand by an array? Explain the basic
parameters
in
declaration
of
single
and
multidimensional array by suitable example.
What is dynamic memory allocation? Write and
explain the different dynamic memory allocation
functions in C.
Write a program in C to determine if two matrices
entered are Equal.
What is a pointer? Describe call by value and call by
reference with examples.
What is an array? Describe array declaration,
initialization and accessing array elements.
Write a program in C to print the n number of rows
of a Pascal Triangle.
Ex: For n=4;
1
1 1
1 2 1
1 3 3 1
Write a Program in C to input two double dimensional
array (matrix) and add them and display the result as a
third matrix.
Write a program to input a String and copy the string
in another array without using string functions.

2
2
2

A
A
B

2
4

C
A

36
37

38
39

40

Write a program in C to enter n numbers and sort


them in increasing order using Bubble Sort Technique.
Write a program in C to enter n numbers and sort
them in increasing order using Selection Sort
Techniques.
Write a program to reverse a string without using
functions.
Write a function in C using pointers to add two
matrices and to return the resultant matrix to the
calling function.
Write a program to calculate the sum of all the
diagonals of a square matrix

Solution to questions #1-20 of Unit-4:

Unit-4
Question
No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Answer
Answer: c
Answer: d
Answer: c
Answer: a
Answer: c
Answer: d
Answer: a
Answer: d
Answer: b
Answer: b
NULL or \0
derived
external, static
datatype nameofarray [size];
n-1
Garbage Value
base address
sequential
initialization
0(Zero)

Unit
5

Q. No.
1

Questions

Max.
marks
1

A Function that calls itself is known as


a) Inline Function
b) Nested Function
c) Overloaded Function
d) Recursive Function
According to the following declaration of a 1
function, which of the statement given below is
true:

Difficulty
Index
A

int function(int a,int b=2)

UNIT-5

a) Variable b is of integer type and will


always have value 2
b) Variable a and b are of int type and the
initial value of both variables is 2
c) Variable b is global scope and will have
value 2
d) Variable b will have value 2 if not
specified when calling function
Parameters passed to a function are separated 1
with
a) comma(,)
b) semicolon(;)
c) colon(:)
d) None of above
In Pass-by-value method of passing parameters 1
to a function the called function ________
a) can alter the actual parameter
b) cannot alter the actual parameter
c) can only partially alter the actual
parameter
d) None of the above
In Pass-by-reference method of passing 1
parameters to a function the called function
________
a) can alter the actual parameter
b) cannot alter the actual parameter
c) can only partially alter the actual
parameter
d) None of the above
Which function is appropriate for accepting a 1
string?
a) gets ()
b) puts()
c) getch()

d) scanf()
Header files in C contain
1
a) Compiler commands
b) Library functions
c) Header information of C programs
d) Operators for files
It is necessary to declare the type of a function in 1
the calling program if the function
a) Returns an integer
b) Returns a non-integer value
c) Is not defined in the same file
d) None of these
What will be the value retuned by the following 1
function, when it is called with a value 11?

recur(int num)
if ( ( num/2) !=0 )
return ( recur(num/2 ) * 10+num%2 );
else return 1;

10

11
12
13
14
15

16
17

18

a) Function does not return any value,


because it goes into an infinite loop
b) 11
c) 1011
d) None of these
The function that actually created from a call to a
template function is called
a) Generated
b) Inherited
c) Spawned
d) Declassified
Variables declared inside the parenthesis of a
function have ______ visibility.
The return type of a function that does not have
any return type is declared as _________.
A function that uses variable types is called
_______________.
The function __________ is used in a program
when output is to be printed on to a file.
The function islower(char) checks whether a
character is in lower case or not, therefore it
should return _____________.
___________ is the default parameter passing
mechanism in C.
____________ helps to avoid repeating a set of
statements many times and enhances the logical
clarity of the program.
Use of ________ instead of function is
recommended when one wants to reduce the

19
20

21
22
23
24
25
26
27
28
29
30

31

32

33

34

35

36
37
38

39

execution time and when there is a loop with a


function call inside.
Running out of memory may occur due to
_________ function call.
When a function is recursively called, all
automatic variables are __________ during each
execution of the function.
What are functions? How functions help in
reducing human efforts?
Explain Modular Programming. Illustrate some
of its advantages over sequential programming.
Explain Recursion?
Is using exit( ) the same as using return?
Is it possible to execute code even after the
program exits the main( ) function?
What is the difference b/w malloc( ) and calloc(
)?
What is a Static Function?
How many arguments can be used in a function?
Explain the use of fflush( ) function?
State the keyword which is used to transfer the
controls back to a calling function from a
function. Also write a sample program to justify
your answer.
Write a program in C using functions rev( ) to
reverse a string entered by the user and vow( ) to
find the number of vowels in that string.
Write a program in C using functions to swap
two numbers using (i). Call-by-Value and (ii).
Call by-Reference.
Explain the concept of function in C with a
suitable example. How a user defined function is
different from Library function?
Illustrate the difference between Call by value
and Call by reference using suitable program in
C.
What do you mean by dynamic memory
allocations? Explain malloc(), calloc(), realloc()
and free() functions with the help of an example.
Write a C program to calculate the sum on N
numbers using recursion.
Write a C program to calculate the Factorial of a
number using recursion.
Write a program in C to make a simple calculator
by entering two numbers and be able to perform
addition, subtraction, multiplication and division.
Use Functions and if-else statements only.
Write a recursive function in C to solve the game

2
2
2

B
B
C

4
4
4
4

A
A
B
B

40

of Tower-of-Hanoi.
Write a C program to calculate XY using 8
recursion where values of X and Y are entered
through keyboard. Don't use pow() function.

Solution to questions #1-20 of Unit-5:

Unit-5
Question
No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Answer
Answer: d
Answer: d
Answer: a
Answer: b
Answer: a
Answer: a
Answer: b
Answer: b
Answer: c
Answer: c
local
void
variable function
fprintf
0 or 1
Call-by-value
Functions
macro
Recursive
initialised