PCP Lab Questions
PCP Lab Questions
________________________________________________________________________
Do it yourself (Homework):
1. If a five-digit number is input through the keyboard, write a program to calculate the sum
of its digits.
2. A cashier has currency notes of denominations 10, 50 and 100. If the amount to be
withdrawn is input through the keyboard (in multiples of 10 only & maximum 990), find
the total number of currency notes of each denomination the cashier will have to give to
the withdrawer.
Do it yourself (Homework):
1. Write a C program to check a given year is leap-year or not.
2. Write a C program to input the coefficients of a quadratic equation and find the roots of an
Equation.
Do it yourself (Homework):
1. WAP to print number in words (Using while and switch statements).
2. Write programs to print following patterns-
* 0
* * * 1 0 1
* * * * * 2 1 0 1 2
* * * * * * * 3 2 1 0 1 2 3
1
22 1
33 3
232
4 4 4 4
5 5 5 5 5 34543
4567654
*
* * 1
* * * 1 1
* * * * 1 2 1
* * * 1 3 3 1
* * 1 4 6 4 1
* 1 5 10 10 5 1
___________________________________________________________________________
Do it yourself (Homework):
1. Write a program to find largest and smallest number from matrix.
2. WAP to find the multiplication two matrices A and B. Print appropriate message in case
matrices A and B are not compatible for multiplication.
________________________________________________________________________
Do it yourself (Homework):
1. WAP to convert decimal number into binary number using function.
2. WAP to perform following operation on matrix (3*3) using function and pointer
1. transpose of matrix
2. check weather symmetric or not
__________________________________________________________________________
1. WAP to find the multiplication of matrices A and B into matrix C where the initialization
of matrices A and B should be done by a function initMat(), printing of matrices should
be done by printMat() and multiplication should be done by mulMat(). You need to pass
the matrices into functions according to need.
2. Write a program to print Fibonacci series using recursive function.
3. Write a program to print factorial of a number using recursive function.
4. Write a program to print sum of digits of an integer number using recursive function.
Do it yourself (Homework):
1. WAP to swap two number using function
1.using call by value
2.call by reference
2. WAP program for passing an array as a pointer into a function where the function will sort
the elements of the array into ascending order and sorted array is returned from the function.
___________________________________________________________________________
Do it yourself (Homework):
1. Find the smaller of three nos using #IF #ELSE #ELIF directive.
2.Write a program to print error message using #err directive
___________________________________________________________________________
Do it yourself (Homework):
1. Define a structure data type called DATE for storing dates. The type contains three
integer members: day, month and year. Implement the following operations for the
defined data type:
(i) Isvalid: Check whether the entered date is valid or not, e.g. 31-2-2018 is
not valid date since February does not have 31 days.
(ii) Nextdate: Finds the next date e.g. if the current date is 31-1-2018, then
the result of Nextdate operation is 1-2-2018.
(iii)Datediff: Finds the difference between two dates.
2. Define structure data type TRAIN_INFO. The type contains:
i. Train No: interger type
ii. Train name: string
iii. Departure time: aggregate type TIME
iv. Arrival time: aggregate type TIME
v. Start station: string
vi. End station: string
The structure type TIME contains two integer members: hours and minute. Maintain a
train timetable and implement the following operations:
(i) List all the trains (sorted according to train number) that depart from
particular station.
(ii) List all the trains that depart from a particular station at particular point.
(iii)List all the trains that depart from a particular station within next one
hour of a given time.
(iv) List all the trains between a pair of start station and end station.
______________________________________________________________________
1.WAP in C to read name and marks of 10 students from user and store them in a file.
2.WAP in C to create two files and add the content of one file at the end of another file.
3 Write a program to read multiple number of strings from the user and write them to a file
using fputs() and read the same strings from file using fgets() and display on the output screen.
4. Write a program to receive detail (like name, roll no. etc) of students and write them into
file. Also display these records of students on screen.
Do it yourself (Homework):
1. Suppose there is a file containing records of employees and each record contain Employee
id, Name and Basic salary. Write a program to read these records and display them in sorted
order by Employee id.
Assume that the end of a word may be a space, comma or a full-stop followed by one or more
spaces or a newline character.