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

Programs carrying 4 marks

1. Write a function program to convert temperature in Celsius to Fahrenheit


2. Write a function program that returns the area of a triangle given the length of three
sides using the formula Area= SQRT( s(s-a)(s-b)(s-c) ) where s =(a+b+c)/2
3 Write a functions sub program in C to return the area of a triangle give the length of
the Base and height
4 Write a function subprogram to return the force exerted on an object of mass m
moving with the acceleration a ( F = ma)
5. Write a function sub program to return 1 if the given number is even or else return 0
6 Write flowchart and C program to generate the following patterns.
****** *
****** ***
****** *****
****** *******
7 Write a C program to find both smallest and largest among the given three numbers.

8. Write a C program to accept three integers and if sum of first two number is greater than
third number then display the difference else display the sum.

9 Write a function subprogram in C to return 1 if a given number is prime or else return 0


10 Write a function sub program to reverse given multidigit number. ( R= Num%10,
RevNum = RevNum *10+ R , Num=Num/10 )
11 Write a function sub program to find the largest digit in a given multidigit number.
( Max=0, R = Num%10 , if( R GT Max ){ Max = R }, Num =Num/10 )
12 Write a function subprogram in C to return the sum of digits of a given multidigit
number.
( R= Num%10, Sum = Sum + R, Num = Num/10 )
13 Write a function program in C to convert a number into it’s BINARY EQUIVALENT.(eg:
15 = 1111 , 16 = 10000 )
( first R = Num%2, BinNum = BinNum + R*Pwr, Pwr= Pwr*10, Num = Num/2 )
14 To convert temperature in C to F and return the value of F.
15 Input coordinates of two points (X1,Y1) and (X2, Y2). Calculate the
distance between these two points using the formula:
Distance = √( (X12-X22) –( Y12-Y22))
16 To check whether a given number is a PERFECT number ( sum of the
divisors is the number)
17 To input and sort N numbers in an array using Bubble sort.
18 To find the cosine of an angle in degree by summing the terms generated
till the value of the term is greater than 0.0001.
19 To find the sine of an angle in degrees by summing the terms generated
till the value of the term is greater than 0.001
20 To find the sum of N natural numbers
21 To find the sum of the N terms of the series S= 1+ 3 + 5 + . . . N terms
22 To find the sum of N terms of the series: S = 2+ 4+ 6+ … N terms
23 To find the sum of N terms of the series S =1! + 3! + 5! + …N terms
24 To find the sum of N terms of the series S = 1! – 3! + 5! +..N terms
25 To find the sum of N terms of the series S = 1!*2! + 2!*3! + 3!*4!+..
26 To find the sum of N terms of the series S = 1!*3! + 2!*5! + 3!*7! +..
27
Write a program in C to transpose an NxN square matrix.

ARRAYS & Matrices


1. Write a function sub program to search a given number is a sorted array using
BINARY SEARCH method. Let the function return 1 if the number is found or else
return -1
2 Write a function sub program to search a given number is a sorted array using LINEAR
SEARCH method. Let the function return 1 if the number is found or else return -1
3. Write a function in C to return the average of N numbers is an array.
4. Write a function in C to return the maximum number in an array
5. Write a function in C to return the smallest number is an array
6 Write a function in C reverse the content of an array
7 Write a function sub program to return the standard deviation of N numbers in an
array.
8 Write function sub program to sort N numbers in an array using BUBBLE SORT
9 Write function sub program to sort N numbers in an array using SELECTION SORT
10 Write a program to find the second largest number in an array
11 Write a function program to find the sum of two matrices of dimensions MxN
12 Write a function sub program to find the product of two matrices of dimensions MxP
and PxN
13 Write a function sub program in C to return the TRACE of a square matrix of
dimension NxN
14 Write a function to create a UNIT MATRIX. ( PRINCIPAL DIAGONAL HAS 1 , all the rest
are 0 )
15 Write a program in C to find the largest number among three numbers.
16 Write a program in C to delete a given number from a list of numbers
17. Write a program to delete duplicate copied of all the numbers in a list
18. Write a program in C to transpose a matrix.
19 Write flowchart and C program to insert a number at a particular location in an array
20. Write flowchart and C program to input some integers and indicate whether the numbers are
even or odd.
21. Write flowchart and C program to copy the content of an array to another

STRINGS
8 Write a function program in C to return the length of a string
9 Write a function sub program in C to join two string.
10 Write a function sub program in C to compare two string. Let the function return 0 if
they are lexicographically equal. If the first string is greater( comes after the second
string in the dictionary) let eh function return a positive number else a negative
number
11 Write a function sub program in C to make a duplicate copy of a given string
(fnStrCpy() )
12 Write a function sub program in C to convert a given string to upper case
(fnToUpper() )
13 Write a function sub program in C to convert a given string to lower case (fnToLower()
)
14 Write a function sub program in C to reverse a given string.
15

10 marks questions
1 An electric power distribution company charges domestic consumers as follows.

Let the program read customer number , name and the power consumed and print

Consumption Units Rate of Charge


0-200 Rs2 per unit
201-400 400 plus Rs 3 per unit excess of 200
401-600 Rs 860 plus Rs 4 per unit excess of 400
600 and above 1500 plus Rs 5 per every excess over 600
the amount to be paid by the customer.
2 . Write flowchart and C program to compute the roots of the quadric equation
Y = ax2 + bx + c =0.
√𝒃𝟐 −𝟒𝒂𝒄
The root are given by: 𝒙 = −𝒃 ± 𝟐𝒂
The program should input the values of a,b,c and print the values of the roots based
on the following conditions.
a) No solution if a and b are zero.
b) There is only one solution is a is zero and it is x = -c/b
3 Write a C program to accept ProductID, PName and Price. Calculate the amount for N
products based on the following criteria.
 Price is less than 500  10% discount
 Price is greater than or equal to 500 and less than 1000  20%
discount
 Price is greater than 1000 then  25% discount.

4 Write a function to sort N numbers in an array using Bubble sort. Use it in the main
program to sort N numbers in an array. ( Input N numbers into an array, and display them
before sorting and after sorting )
5 Write a function to sort N numbers in an array using SELECTION sort. Use it in the
main program to sort N numbers in an array. ( Input N numbers into an array, and display
them before sorting and after sorting )
6 Write function programs to enter numbers into a N x M matrix and print the content
of the matrix. Write one more function to find the sum of two matrices Use them in
the main program to enter data into two matrices and find the sum of two matrices.

7 Write function programs to find the product of numbers in a M x P and PxN matrices.
Use that function in the main program to find the product of matrices with
dimensions: MxP and PxN.
8 Write function sub programs to INPUT, Print the content of and array containing N
numbers. Write one more function to return the standard deviation of N numbers in
an array. Write the main program in which you use these functions to input, print and
find the standard deviation of N numbers in an array.
StdDev= SQRT ( Σ( Xi – Avg)2/N )
9 Write a program in C to search for a given number in an array
10 Write flowchart and C program to input the Employee ID, Name and Basic
salary of an employee. Calculate GROSS and NET salaries as:
Gross = Basic + DA + HRA
Net = Gross –( IT + PF)
DA = 15% of Basic salary
HRA is 10% of the Basic + DA.
PF = 12% of the Basic.
IT ( Income Tax) is 500 if the (Basic + DA) is below Rs 10,000
It is 500 + 8% for the amount 10,000 and above( Basic + DA), but below
20,000. For any amount equal to and higher than 20,000 IT is 15% of
(Basic+DA).

11 Write function programs to input, print and sort N numbers in an array.


Use these in the main program to input N numbers, Print those numbers
and sort numbers.
12 Write a function program in C to return the SINE of an angle in degrees by
summing the terms of the series till the value of the term generated
become less than 0.001. Use this function in the main program to list the
SINE of angles between o and 180 for every 10 degrees.
13 Write a function program in C to return the COSINE of an angle in
degrees by summing the terms of the series till the value of the term
generated become less than 0.001. Use this function in the main program
to list the COSINE of angles between o and 180 for every 10 degrees.

14 Write function programs to input, print N numbers in an array. Also write


a function program to return the standard deviation of N numbers in an
array. Use these in the main program to input N numbers, Print those
numbers and find the standard deviation of N numbers.
15 Write function sub programs in C to input and print numbers into an NxM
matrix. Also write a function sub program to find the sum of two
matrices. Use these functions in the main program to input numbers into
two matrices and find the sum of those two matrices.
16 Write a program in C to input some names into a character matrix and
sort them using bubble sort.
17 Create a structure data type to with RegNo, Name, marks in 3 subjects,
Total, average and results. Use that structure to input Reg num, name
and marks in three subjects, process the data and print marks card
indicating whether the student has obtained Distinction, or grades A, B, C
or FAILED.
18 Create a structure data type with EID, Name, Basic salary, Gross and Net
Salary as fields. Use this to input EID, Name and Basic salary of the
employee to calculate Gross and Net salary. DA = 20% of Basic, HRA =
10% of Basic and Tax = 8% of Basic. And display the payslip for the
employee.
19 Write a program in C using file to read a list of numbers and calculate the
standard deviation

THEORY QUESTIONS CARYING 4/5 MARKS


1. Write short notes on data types in C
2. What is the use of looping statement in C. With examples explain any two looping
statements
3. What is a conditional statement in C. with examples explain the working of
conditional statements in C.
4. What is pseudocode? Explain the role of pseudocode in solving problems.
5. Why do we use flowcharts in solving coding? Explain with examples.
6. Explain the use of any two string functions.
7. With examples explain the use of BITWISE operators.
8. What is a ternary operator? How is it used?
9. Give the prototypes of the following string functions and explain how you would use
them. A) strcpy() b) strcmp()
10. What is the difference between string functions strchr() and strstr(). Explain with an
example.
11. Write short notes on scope of variables.
12. With examples explain two pre-processors in C
13. What is the difference between a random file and a sequential file?
14 Write short notes on POINTERS.
15. How would you open a text file? Which are the different modes for opening files?
16. What is a UNION?
17. Explain the use of structures in C.
18. With example explain argument by value and argument by reference. Why do we pass
arguments by reference?
19. Explain two function is C which are used to allocate memory.
20  What are the basic Datatypes supported in C Programming Language?
21 What do you mean by the Scope of the variable? ...explain with examples
22  What are static variables and functions?
23 Differentiate between calloc() and malloc()
24 What do you mean by Dangling Pointer Variable in C Programming?
26 Differentiate between Actual Parameters and Formal Parameters.

The Parameters which are sent from main function to the subdivided function are
called as Actual Parameters and the parameters which are declared at the
Subdivided function end are called as Formal Parameters.

26 To store a negative integer, we need to follow the following steps. Calculate the
two’s complement of the same positive integer.

Eg: 1011 (-5)

Step-1 − One’s complement of 5: 1010

Step-2 − Add 1 to above, giving 1011, which is -5


27 What is Preprocessor?

Ans: A Preprocessor Directive is considered as a built-in predefined function or


macro that acts as a directive to the compiler and it gets executed before the
actual C Program is executed.
In case you are facing any challenges with these C Programming Interview
Questions, please write your problems in the comment section below.
28 Mention the features of C Programming Language.

High level language* structured language* has rich library *


pointers through which one can access the memory address*
good memory management * fast execution
29 What is the purpose of printf() and scanf() in C Program?

Ans: printf() is used to print the values on the screen. To print certain values,
and on the other hand, scanf() is used to scan the values. We need an
appropriate datatype format specifier for both printing and scanning purposes.
For example,

 %d: It is a datatype format specifier used to print and scan


an integer value.
 %s: It is a datatype format specifier used to print and scan a string.
 %c: It is a datatype format specifier used to display and scan
a character value.
 %f: It is a datatype format specifier used to display and
scan float value.

30 . What is an array?

Ans. The array is a simple data structure that stores multiple elements of the
same datatype in a reserved and sequential manner. There are three types of
arrays, namely,

 One Dimensional Array


 Two Dimensional Array
 Multi-Dimensional Array

31 What is /0 character?

Ans: The Symbol mentioned is called a Null Character. It is considered as the


terminating character used in strings to notify the end of the string to the
compiler.
32 What is the main difference between the Compiler and the
Interpreter?

Ans: Compiler is used in C Language and it translates the complete code into
the Machine Code in one shot. On the other hand, Interpreter is used in Java
Programming Langauge and other high-end programming languages. It is
designed to compile code in line by line fashion.
33 What is Dynamic Memory allocation? Mention the syntax.
Ans: Dynamic Memory Allocation is the process of allocating memory to the
program and its variables in runtime. Dynamic Memory Allocation process
involves three functions for allocating memory and one function to free the used
memory.

malloc() – Allocates memory

Syntax:

1 ptr = (cast-type*) malloc(byte-size);


calloc() – Allocates memory

Syntax:

1 ptr = (cast-type*)calloc(n, element-size);


realloc() – Allocates memory

Syntax:

1 ptr = realloc(ptr, newsize);


free() – Deallocates the used memory

Syntax:

1 free(ptr);

35 What do you mean by Dangling Pointer Variable in C


Programming?

Ans: A Pointer in C Programming is used to point the memory location of an


existing variable. In case if that particular variable is deleted and the Pointer is
still pointing to the same memory location, then that particular pointer variable is
called as a Dangling Pointer Variable.
36 Where can we not use &(address operator in C)?

Ans: We cannot use & on constants and on a variable which is declared using
the register storage class.
38 Write a simple example of a structure in C Language

Ans: Structure is defined as a user-defined data type that is designed to store


multiple data members of the different data types as a single unit. A structure will
consume the memory equal to the summation of all the data members.
39 ifferentiate between call by value and call by reference.

Ans:
Factor Call by Value Call by Reference

Actual arguments cannot be Operations are performed on


Safety
changed and remain safe actual arguments, hence not safe

Separate memory locations


Memory Actual and Formal arguments
are created for actual and
Location share the same memory space.
formal arguments

Argument Copy of actual arguments


Actual arguments are passed
s are sent

//Example of Call by Value method

40 Differentiate between getch() and getche().

Ans: Both the functions are designed to read characters from the keyboard and
the only difference is that

getch(): reads characters from the keyboard but it does not use any buffers.
Hence, data is not displayed on the screen.

getche(): reads characters from the keyboard and it uses a buffer. Hence, data
is displayed on the screen.
41 What do you mean by Memory Leak?

Ans: Memory Leak can be defined as a situation where programmer allocates


dynamic memory to the program but fails to free or delete the used memory after
the completion of the code. This is harmful if daemons and servers are included
in the program.
42 Explain Local Static Variables and what is their use?

Ans: A local static variable is a variable whose life doesn’t end with a function
call where it is declared. It extends for the lifetime of the complete program. All
calls to the function share the same copy of local static variables
43 What is the difference between declaring a header file with < >
and ” “?

Ans: If the Header File is declared using < > then the compiler searches for the
header file within the Built-in Path. If the Header File is declared using ” ” then
the compiler will search for the Header File in the current working directory and
if not found then it searches for the file in other locations.
44 When should we use the register storage specifier?
Ans: We use Register Storage Specifier if a certain variable is used very
frequently. This helps the compiler to locate the variable as the variable will be
declared in one of the CPU registers.

45 Which variable can be used to access Union data members if the


Union variable is declared as a pointer variable?

Ans: Arrow Operator( -> ) can be used to access the data members of a Union
if the Union Variable is declared as a pointer variable.

46 Mention File operations in C Language.

Ans: Basic File Handling Techniques in C, provide the basic functionalities


that user can perform against files in the system.

Function Operation

To Open a
fopen()
file

fclose() To Close a File

fgets() To Read a File

fprint() To Write into a File

In case you are facing any challenges with these C Programming Interview
Questions, please write your problems in the comment section below.

47 What are the different storage class specifiers in C?

Ans: The different storage specifiers available in C Language are as follows:

 auto
 register
 static
 extern

48 What is typecasting?

Ans: Typecasting is a process of converting one data type into another is known
as typecasting. If we want to store the floating type value to an int type, then we
will convert the data type into another data type explicitly.
Syntax:

1 (type_name) expression;

49 Write a program to swap two numbers without using the third


variable.

Ans:

What are the limitations of scanf() and how can it be avoided?

Ans: The Limitations of scanf() are as follows:

 scanf() cannot work with the string of characters.


 It is not possible to enter a multiword string into a single variable using
scanf().
 To avoid this the gets( ) function is used.
 It gets a string from the keyboard and is terminated when enter key is
pressed.
 Here the spaces and tabs are acceptable as part of the input string.

50 Differentiate between the macros and the functions.

Ans: The differences between macros and functions can be explained as


follows:

 Macro call replaces the templates with the expansion in a literal way.
 The Macro call makes the program run faster but also increases the
program size.
 Macro is simple and avoids errors related to the function calls.
 In a function, call control is transferred to the function along with
arguments.
 It makes the functions small and compact.
 Passing arguments and getting back the returned value takes time
and makes the program run at a slower rate.

You might also like