0% found this document useful (0 votes)
7 views11 pages

CPL Question Bank (Viva)

The document is a question bank for a Computer Programming Lab, covering various topics such as functional block diagrams, operating systems, algorithms, and C programming concepts. It includes questions on data types, functions, control statements, searching algorithms, and structures, along with their corresponding answers. The content serves as a comprehensive guide for students preparing for viva examinations in computer programming.

Uploaded by

Rajiv Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

CPL Question Bank (Viva)

The document is a question bank for a Computer Programming Lab, covering various topics such as functional block diagrams, operating systems, algorithms, and C programming concepts. It includes questions on data types, functions, control statements, searching algorithms, and structures, along with their corresponding answers. The content serves as a comprehensive guide for students preparing for viva examinations in computer programming.

Uploaded by

Rajiv Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Computer Programming Lab

Viva Questions
Question Bank

1) Description about Functional block diagram of Computer:


2) Types of bus
3) What is Operating System? Explain the types of Operating System?
4) What is Algorithm? Explain the key features of Algorithm?
5) What is Flowchart? Describe the symbols with names?
6) Explain the advantages and disadvantages of Flowchart?
7) What is pseudocode? Explain with an example?
Note: For the above 7 questions, Answers are there in CPL Lab manual

8) What is C Language?
Solution: C is a high level language in which high language represents English written
instructions.

9) What is preprocessor directives?


Solution: The C preprocessor is a macro processor that is used automatically by
the C compiler to transform your program before actual compilation (Preprocessor
directives are executed before compilation.). ... Macro is defined by #define directive or
#include directive. Preprocessing directives are lines in your program that start with #.

10) What is header files?


Solution: A header file is a file containing C declarations and macro definitions (see
Macros) to be shared between several source files. You request the use of a header file in
your program by including it, with the C preprocessing directive ' #include.

11) What is main function?

Solution: In C, the "main" function is treated the same as every function, it has a return
type (and in some cases accepts inputs via parameters). The only difference is that the
main function is "called" by the operating system when the user runs the program.
12) What is data type?

Solution : A data type is a type of data. Some common data types include integers, floating point
numbers, characters, strings, and arrays.

13) What is a keywords?


Solution : Keywords are predefined, reserved words used in programming
that have special meanings to the compiler. Keywords are part of the
syntax and they cannot be used as an identifier. For example:
int money;
Here, int is a keyword that indicates money is a variable of type int (integer).
Similarly other keywords are float and char.
14) Mention the size of the integer types.

15. Mention the size of the floating types.


Solution :

16. What is variables?


Solution : A variable is nothing but a name given to a storage area that our programs can
manipulate. Each variable in C has a specific type, which determines the size and layout
of the variable's memory; the range of values that can be stored within that memory; and
the set of operations that can be applied to the variable.

17. What is printf () function?

Solution: The printf() is a library function to send formatted output to the screen. The
function prints the string inside quotations. To use printf() in our program, we need to
include stdio. h header file using the #include <stdio.h>

18.What is scanf() function ?

Solution : The scanf function allows you to accept input from standard in, which for us is
generally the keyboard. ... scanf("%d", &b); The program will read in an integer value
that the user enters on the keyboard (%d is for integers, as is printf, so b must be declared
as an int) and place that value into b.

19.What is format specifiers ?

Solution: The format specifiers are used in C for input and output purposes. Using this
concept the compiler can understand that what type of data is in a variable during taking
input using the scanf() function and printing using printf() function.
Example :%d- integer,%f-floating point ,%c-character
20)What is Switch statement ?

Solution : A switch statement allows a variable to be tested for equality against a list of
values. Each value is called a case, and the variable being switched on is checked for
each switch case.

21) What does break in switch statement indicate?

Solution: When a break statement is reached, the switch terminates, and the flow of
control jumps to the next line following the switch statement. The break statement
is optional. If omitted, execution will continue on into the next case. The flow of
control will fall through to subsequent cases until a break is reached.

22) What is if statement ?

If the Boolean expression evaluates to true, then the block of code inside the
'if' statement will be executed. If the Boolean expression evaluates to false, then the first
set of code after the end of the 'if' statement (after the closing curly brace) will be
executed.
23) Difference between if and switch statements?
Solution:
SWITCH allows expression to have integer based evaluation while IF statement allows both
integer and character based evaluation. 5. SWITCH statement can be executed with all
cases if the 'break' statement is not used whereas IF statement has to be true to be executed
further.
24) What is quadratic Equation and math.h function?
Solution:
The solutions of the quadratic equation ax2 + bx + c = 0 correspond to the roots of the
function f(x) = ax2 + bx + c, since they are the values of x for which f(x) = 0.
The math.h header defines various mathematical functions and one macro Ex: fabs,sqrt

25) What are Looping control statements?

Solution: With loop control statements, you can repeatedly execute a block of code.

26. What is the difference between while and do-while loops?

Solution: he difference is that the do while loop executes at least once because it checks for
the loop condition while exiting. While is a entry controlled loop and do while is a exit
control loop. Whereas in do while loop it will enter the loop and will then check for the
condition.
27. What is for loop ?
Solution : A for loop is a repetition control structure that allows you to efficiently write a loop that needs to
execute a specific number of times.
Syntax
The syntax of a for loop in C programming language is −
for ( init; condition; increment ) {
statement(s);
}

28. What is else-if ladder?

Solution: The conditional expressions are evaluated from the top downward. As soon as a true
condition is found, the statement associated with it is executed, and the rest of the ladder is
bypassed. If none of the conditions is true, then the final else statement will be executed.

29. What is conditional branching statement?

Solution: Conditional Statements in C programming are used to make decisions based on the
conditions. Conditional statements execute sequentially when there is no condition around
the statements. ... It is also called as branching as a program decides which statement to
execute based on the result of the evaluated condition.

30. What is linear search?

Solution: Linear search is a very simple search algorithm. In this type of search, a sequential
search is made over all items one by one. Every item is checked and if a match is found then that
particular item is returned, otherwise the search continues till the end of the data collection.

31. What is binary Search?

Solution: Binary search looks for a particular item by comparing the middle most item of the
collection. If a match occurs, then the index of item is returned. If the middle item is greater than
the item, then the item is searched in the sub-array to the left of the middle item. Otherwise, the
item is searched for in the sub-array to the right of the middle item. This process continues on the
sub-array as well until the size of the subarray reduces to zero.

32. What is a function?

Solution: A function is a block of code that performs a specific task.


33. What are the types of functions?

Solution: There are two types of function in C programming:

 Standard library functions.

 User-defined functions

 Standard library functions.


Definition: The C standard library provides macros, type definitions and functions for
tasks such as string handling, mathematical computations, input/output processing,
memory management, and several other operating system services.

User Defined Functions:


A function is a block of code that performs a specific task.
C allows you to define functions according to your need. These functions are known as
user-defined functions. For example:
Suppose, you need to create a circle and color it depending upon the radius and color.
You can create two functions to solve this problem:
 createCircle() function
 color() function

34. What is a multi-dimensional array?

Solution: Multidimensional arrays are an extension of 2-D matrices and use additional
subscripts for indexing. A 3-D array, for example, uses three subscripts. The first two are just
like a matrix, but the third dimension represents pages or sheets of elements.

35. How to initialize two dimensional arrays?

Solution: n a two dimensional array like int[][] numbers = new int[3][2], there are three rows
and two columns. You can also visualize it like 3 integer array of length 2. You can find the
number of rows using numbers.

36. What is pre-processor directive?

Solution: The preprocessor directives give instruction to the compiler to preprocess the
information before actual compilation starts. ... C# compiler does not have a
separate preprocessor; however, the directives are processed as if there was one. In C#
the preprocessor directives are used to help in conditional compilation.

37. What is the difference between the = symbol and == symbol?


Solution :The “=” is an assignment operator is used to assign the value on the right to the
variable on the left.
Example :
The ‘==’ operator checks whether the two given operands are equal or not. If so, it returns true.
Otherwise it returns false.
For example:
5==5

This will return true.


38. What is string?

Solution: Strings are actually one-dimensional array of characters terminated by a null character
'\0'. Thus a null-terminated string contains the characters that comprise the string followed by
a null.

39. What are the built-in functions of string?


Solution :

40. Why the name bubble sort?

Solution : Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm
that repeatedly steps through the list, compares adjacent elements and swaps them if they are
in the wrong order. The pass through the list is repeated until the list is sorted.
41. What is nested for loop?

Solution : C programming allows to use one loop inside another loop. The following section
shows a few examples to illustrate the concept.
Syntax
The syntax for a nested for loop statement in C is as follows −
for ( init; condition; increment ) {

for ( init; condition; increment ) {


statement(s);
}
statement(s);
}
A final note on loop nesting is that you can put any type of loop inside any other type of loop.
For example, a 'for' loop can be inside a 'while' loop or vice versa.

42. What is typecasting? Explain with examples.

Solution : Typecasting, or type conversion, is a method of changing an entity from one data
type to another. ... An example of typecasting is converting an integer to a string. This might
be done in order to compare two numbers, when one number is saved as a string and the other
is an integer.

43. Difference between continue and break statement?


Solution : The main difference between break and continue is that break
is used for immediate termination of loop. On the other hand, 'continue' terminate the current
iteration and resumes the control to the next iteration of the loop.
44..What are structures ?

Solution : A structure is a user defined data type in C/C++. A structure creates a data type that
can be used to group items of possibly different types into a single type.

45..How to create and declare the structures?


Solution : To create a structure?
‘struct’ keyword is used to create a structure. Following is an example.

struct address
{
char name[50];
char street[100];
char city[50];
char state[20];
int pin;
};

To declare structure variables?


A structure variable can either be declared with structure declaration or as a separate declaration
like basic types.

// A variable declaration with structure declaration.


struct Point
{
int x, y;
} p1; // The variable p1 is declared with 'Point'
// A variable declaration like basic data types
struct Point
{
int x, y;
};

int main()
{
struct Point p1; // The variable p1 is declared like a normal variable
}

46. Define pointer?

Solution: A pointer is nothing but a memory location where data is stored. A pointer is used to
access the memory location. There are various types of pointers such as a null pointer,
wild pointer, void pointer and other types of pointers. Pointers can be used with array and
string to access elements more efficiently.

47. How do you declare a pointer variable?


Solution :
The data type of pointer and the variable must match, an int pointer can hold the address
of int variable, similarly a pointer declared with float data type can hold the address of a
float variable. In the example below, the pointer and the variable both are of int type.
#include <stdio.h>
int main()
{
//Variable declaration
int num = 10;

//Pointer declaration
int *p;

//Assigning address of num to the pointer p


p=#

printf("Address of variable num is: %p", p);


return 0;
}
Output:

Address of variable num is: 0x7fff5694dc58


48. What is recursion?
Solution: The process in which a function calls itself directly or indirectly is called recursion and
the corresponding function is called as recursive function.
26.What is binary number ?
A Binary Number is made up of only 0s and 1s.
110100
Example of a Binary Number
There is no 2, 3, 4, 5, 6, 7, 8 or 9 in Binary!
A "bit" is a single binary digit. The number above has 6 bits.

49. What is the process to create increment and decrement statement in C?


Answer: There are two possible methods to perform this task.
 Use increment (++) and decrement (-) operator.
Example When x=4, x++ returns 5 and x- returns 3.
 Use conventional + or – sign.
Example When x=4, use x+1 to get 5 and x-1 to get 3.

50. What is the explanation for the dangling pointer in C?


Answer: When there is a pointer pointing to a memory address of any variable, but after some
time the variable was deleted from the memory location while keeping the pointer pointing to
that location is known as a dangling pointer in C.

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