The Bhawanipur Education Society College
Department of Computer Science
Problem Solving Using C Programming (DSCC-2)
Assignments List
Group A (For Even UID numbers)
IF ELSE:
1. (a) WAP in C to convert temperature given in Celsius to Fahrenheit scale or vice-versa as
per user input.
(b) WAP in C to find out the roots of a quadratic equation and keep provision for imaginary
roots.
(c) WAP in C to check the type of the given triangle whether it is equilateral, isosceles or
scalene.
(d) WAP in C to take the marks obtained by a student in 4 subjects as input, and calculate
the total marks, average and grade obtained by the student. The grade chart is given below:
Average Marks Grade
91.0 – 100.0 O
81.0 – 90.0 A
71.0 – 80.0 B
61.0 – 70.0 C
51.0 – 60.0 D
41.0 – 50.0 E
BELOW 40.0 F
SWITCH CASE:
2. WAP in C to make a calculator which performs addition, subtraction, multiplication,
division and modulus operations.
LOOPS:
3. (a) WAP in C to check whether a given number is Palindrome or not.
(b) WAP in C to check whether a given number is Armstrong or not.
(c) WAP in C to check whether a given number is Krishnamurthy or not.
(d) Write a C program to display Fibonacci series up to n terms.
SERIES:
4. (a) WAP in C to evaluate: S = 1 + x + x2 + x3 + x4 + …. Up to n terms.
(b) Write a C program to evaluate: S= (1) + (1+2) + (1+2+3) + (1+2+3+4) + ... +
(1+2+3+4+...+n) up to n terms.
(c) WAP in C to find the summation of ex = 1 + x + x2/2! + x3/3! + …
PATTERNS:
5. Write a C program to display the following patterns:
(a) (b)
1 *
23 **
456 ***
7 8 9 10 ****
*****
ARRAYS:
6. (a) WAP in C to search if an element is present in the array or not. If found, then it should
print the position of the element. (Linear Search)
(b) WAP in C that will separate the even positioned elements in one array and the odd
positioned elements in another array from a given input array. Please note that the input
array would be unaffected.
(c) WAP in C to sort the elements of an unordered array in descending order.
(d)WAP in C to read two matrices and multiply them and store the result in the third matrix.
FUNCTIONS:
7. (a) Write a program in C to read two matrices and add them (use separate functions to read
and display matrices).
(b) Write a C program to find nCr . [Hint: Write a factorial function and use it]
(c) Write a program in C which reads a positive integer and generates all prime factors of
it. Use a function to check prime.
(d) Write a C program to display all Perfect numbers within a given range.
RECURSION:
8. (a) Write a C program to compute the exponent of a given number using recursion (xy).
(b) WAP in C to find the GCD of two numbers using recursion.
STRING:
9. (a) WAP in C to find the frequency of each character in a given string.
(b) WAP in C to search for a given word from the input string and replace it with another
word that will be taken as input from the user.
(c) Write a C program to print the initials of a name.
Example- Input: Mahendra Singh Dhoni
Output: M. S. Dhoni
(d) WAP in C to reverse a given string. Please note that the original string would be
unaffected. Further, extend this program to check whether the string is palindrome or not.
BITWISE OPERATOR
10. WAP in C to do the following using bitwise operators. [ In all cases the output should be
in the binary format. You may use a decimal to binary conversion function to do this]
(a) Toggle a specific bit of an integer number.
[Input: The number (n, say) and bit position (p, say) . Output modified number in binary
form]
(b) Set a specific bit of an integer number.
[Input: The number (n, say) and bit position (p, say) . Output modified number in binary
form]
(c) Find the value of x * 2n
[Input: Both x & n are integers. Output: The value of x * 2n ]
POINTERS
11. (a) Write a C program to swap two numbers using a function (call by reference).
(b) Write a function that will accept a character array as parameters and return the
number of characters in the array. [use pointer arithmetic]
(c) WAP that declares an integer variable, a pointer to the integer, and a pointer to the
pointer. Modify the value of the integer using the pointer to pointer. [Pointer to Pointer]
FILE HANDLING
12. (a)WAP in C to convert contents of a file from lowercase to uppercase and store the result
in a separate file. Please note that the original file contents would be unaffected.
(b)WAP in C to read a matrix from a file and check whether it is a diagonal matrix or not.
STRUCTURE:
13. (a) Write a C program to add two complex numbers using structures.
(b) Write a C program to read the employee information from a file and store it in an array
of structure. Employee structure should contain the following information:
i. EmpID (datatype: Integer)
ii. EmpName (datatype: String)
iii. DOJ (datatype: date; nested structure.)
iv. Salary (datatype: float)
Display the information of the employees based on the EmpID as input from the user.
UNION:
14.