You are on page 1of 7

PART - B

 Explain Storage classes in ‘C’ 1.39


 Write algorithm, program and draw flowchart of /finding square root of
quadratic equations
 Explain Data types in C 1.32
 Explain String handling built-in functions in C 5.21 , 4.8
 Write a Program for Matrix multiplication ,addition
 Sort the elements of an array using insertion sort and selection sort
 Explain all math built-in library functions 5.7.2
 Explain various decision making statement in C with suitable example
 Explain various types of looping with suitable example in C 2.43
 Explain binary search and linear search with suitable programs 4.29
 Write a C Program for finding factorial
 Write a program to compute sum of N numbers
 Explain 2D arrays with suitable example 3.16
 Explain various string operations performed with example, write C program 4.8
for each string operation without using built-in functions
 Explain steps in defining and calling user-defined with suitable example 5.5
 Write a Program to find mean, median and mode
 Write Program to print all prime numbers between two given numbers

PART - A
1. What are the functionalities played by the declaration of variables?
 Variable tells the compiler that
 what the variable name is.
 what type of data the variable will hold.

2. Define algorithm. Explain its characteristics


 An algorithm is a sequence of well-defined computational steps for solving the given
problem that takes some inputs and produces some output
 In other words it is a step by step procedure for solving a prolem
 Each algorithm must have
o Specification: Description of the computational procedure
o Pre-conditions: The condition(s) on input.
o Body of the Algorithm: consist of sequence of clear and unambiguous
instructions.
o Post-conditions: The condition(s) on output

3. Define flow chart. List the symbols used in flow charts.


 A flowchart is a diagrammatic graphical representation of an algorithm that describe the
“flow” of a program visually

1
 Symbol used in flowchart listed below:

4. Draw a flowchart to compute addition of given two numbers

5. How the efficiency of an algorithm can be measured?


 An efficiency of an algorithm can be measured based on the following factors:
 Time: time taken by the computer system to execute an algorithm. The lesser is the
time required, the better is the algorithm
 Memory: memory required to store and execute you algorithm in the system,
The lesser is the memory required, the better is the algorithm.
 Accuracy of Result/Output: if more than one algorithm exists to solve one problem
then we choose algorithm that produce more accurate results than others,

6. Write an algorithm to calculate simple interest.


Step 1: Read the input values for principal amount (P), number of years
(N) and rate of interest (RI).
Step 2: Computer SI = (P*N* RI)/100
Step 3: Print “The SI is”, SI
Step 4: Stop

2
7. Define data types and classify them
 Data types are required when you declare variables in C. data type indicates
what type of data that can be stored in that variable .
 Variables can be broadly classified into the following:

8. What are the features of C programming Language?

3
9. Explain void types?
 The void data type does not store values. So, we don’t declare variables of void
data type. It is only used in the function definition to indicate that the function
does not return any value to the calling program or function does not accept any
input from function call
 Example:
void show(void)
{
printf(“welcome”);
}

10. List different types of constant supported by C program?


 Constants refer to fixed values that the program may not alter during program execution.
C support several types of constants as illustrated in the figure:

11. Summarize relational and logical operators


 Relational Operators are used to construct conditional expression which produce result
as either zero or one. Relational operators includes the following:
o == (equal to)
o != (not equal to )
o < (less than)
o <= (less than or equal to)
o > (greater than)
o >= (greater than or equal to)

 logical Operators are used to concatenate the result of more than one relational
expressions. logical operators includes the following:
o logical AND - &&
o logical OR - ||
o logical not - !

12. List out the various decision making statements available in C?


 C supports following decision making statements:
 simple if
 alternate if
 chained / cascaded if
 nested if
 switch

13. Compute what is the output of variable A in the following expression?

4
A=2 * 3 + 4 % 5 – 3 / 2.0 + 6 ;

14. Define variable. Summarize the rules and guide lines for naming variable
 Variable is nothing but the name of a memory location in that we can store some data
 Variables are declared to store some value within it.
 example:
int a, b, c=10;
float balance,mark1, mark2;
char ch=’Y’;
 guide lines for naming variable are listed below:
 The first character of an variable must be alphabet (or) underscore
 subsequent character could be either letters, digits (or) underscore
 Any other special character will not be allowed, including space
 variables are case sensitive, for example variables sum,SUM,SuM are treated as
three different variables
 Length of the variable can be up to 31 characters
 C keywords or reserved words cannot be used as identifier

15. Define array and its types.


 An arrays are used to store more than one values of same data type using a
single variable name
 Individual elements of an array variable is accessed using index or subscript
 Based on dimensions, an array can be classified into the following:
o Single dimensional array
o Two-dimensional array
o Multidimensional array
 Example:
char text[80];
int x [3] [3];

16. List out the features of an array


 features of an arrays includes the following:
 size of the array is fixed, which cannot be altered.after its creation
 Array stores Homogeneous Elements.
 Individual elements of an array is accessed using index or subscript
 Dimensions of an Array need to be specified at the time of declaration of an array
variable.
 memory allocated for array variable is Contiguous Storage.memory
 array support Random Access.
 array index can range from 0 to size of the array - 1

17. Write a C program to print an array of ‘n’ numbers using the for loop.
int main()
{
float weight[10]={50,76.6,45.3,60,77};
int i;
for(i = 0; i<5; i++)
printf("%f\n", weight[i]);

5
}
18. List out the various string operations in ‘C’.
 various string operations are listed below:
 finding length of the given string
 concatenate one string with another
 copy one string into another
 extracting substring from the given string
 searching substring in the given string
 find and replace substring in the given string

19. Differentiate call by value and call by reference.


 Both call by value and call by reference refers to different ways pass passing parameter to
function
In Call by value In Call by reference
The value of actual argument is copied to The address of actual argument is copied to
formal parameter in the function definition formal parameter in the function definition
Both the actual and formal parameters Both the actual and formal parameters refer
refer to the different memory locations. to the same location
Any changes made in the formal Any changes made in the formal parameter
parameter will not reflected in the actual will be reflected in the actual parameters
parameters

20. Write down any 4 math functions available in ‘C’.


 The following are example of math functions:
Syntax of the Function Description & Example
double sqrt(double x) Returns the square root of x.
printf("%f",sqrt(4)); //output=2.000000
double pow (double x, double y) Returns result of x raised to the power y
printf("%f",pow(2,3)); //output=8.000000
double ceil(double x) Return next smallest integer value that is greater
then x
printf("%f",ceil(2.789));
printf(" %f",ceil(2.001));
//output=3.000000 3.000000
double sin(double x) Compute Sine of angle in radians
printf("%f",sin(90*3.1415/180));
//output=1.000000

21. Extend how strings are represented in C language?


• In C, strings are represented using char array variable. String is a sequence of character
enclosed in double quotation mark.
• Example:
char name[ ]= "Kajendran";
(Or)
char name[ ]= {'K', 'a', 'j', 'e', 'n', 'd', 'r', 'a', 'n', '\0'};

22. Outline the syntax for array declaration


• A one dimensional array can be declared using following syntax:
[StorageClass] DataType VariableName [size];

6
• Where StorageClass is optional and size could be any positive integers, but cannot be
negative
• Example:
int A[20];
static float marks[5];
• Similarly, A two dimensional array can be declared using following syntax:

DataType VariableName [row-size][col-size];

• Example:
int x [3] [3];
char namelist[50][25];

23. What are the main elements of an array declaration?


• The general syntax for array declaration is shown below:
data-type arrayName[size1][size1]…[sizeN];

• The main elements of an array declaration include:


 Data type of the elements that can be stored in array variable
 Name of the array variable
 Dimension of array variable
 Maximum size of each dimension

• Example
int A[20]; //1D integer array can store maximum of 20 elements
char namelist[50][25]; //2D integer array can store maximum of 50 string having
maximum length of 25 character

24. Define the term recursion in language C?


• If a function is called from within the body of the same function then it is said to be
recursive function or recursion. It is the process of calling a function by itself
• Example:

25. Explain the advantages of functions


• Functions facilitate code re-usability
• Functions reduces the length of the program
• Function enhance readability of program
• Functions are used to avoid rewriting same code again and again in a program
• Functions makes debugging, Testing and maintenance of program becomes easy

26. What are type modifiers?


• Type modifiers includes the following: signed, unsigned, long, short
27. What is compile-time operator?
sizeof operator is referred as compile-time operator

You might also like