PPS Lab
PPS Lab
Practice sessions:
a. Write a simple program that prints the results of all the operators available in C (including pre/
post increment , bitwise and/or/not , etc.). Read required operand values from standard input.
b. Write a simple program that converts one given data type to another using auto conversion and
casting. Take the values from standard input.
Page 16 of 154
R22 B.Tech. CSE Syllabus JNTU Hyderabad
Expression Evaluation:
a. A building has 10 floors with a floor height of 3 meters each. A ball is dropped from the top of
the building. Find the time taken by the ball to reach each floor. (Use the formula s = ut+(1/2)at^2
where u and a are the initial velocity in m/sec (= 0) and acceleration in m/sec^2 (= 9.8 m/s^2)).
b. Write a C program, which takes two integer operands and one operator from the user, performs
the operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch
Statement)
c. Write a program that finds if a given number is a prime number
d. Write a C program to find the sum of individual digits of a positive integer and test given number
is palindrome.
e. A Fibonacci sequence is defined as follows: the first and second terms in the sequence are 0
and 1. Subsequent terms are found by adding the preceding two terms in the sequence. Write
a C program to generate the first n terms of the sequence.
f. Write a C program to generate all the prime numbers between 1 and n, where n is a value
supplied by the user.
g. Write a C program to find the roots of a Quadratic equation.
h. Write a C program to calculate the following, where x is a fractional value.
i. 1-x/2 +x^2/4-x^3/6
j. Write a C program to read in two numbers, x and n, and then compute the sum of this geometric
progression: 1+x+x^2+x^3+ ............... +x^n. For example: if n is 3 and x is 5, then the program
computes 1+5+25+125.
Files:
a. Write a C program to display the contents of a file to standard output device.
b. Write a C program which copies one file to another, replacing all lowercase characters with
their uppercase equivalents.
c. Write a C program to count the number of times a character occurs in a text file. The file name
and the character are supplied as command line arguments.
d. Write a C program that does the following:
It should first create a binary file and store 10 integers, where the file name and 10 values are
given in the command line. (hint: convert the strings using atoi function)
Now the program asks for an index and a value from the user and the value at that index should
be changed to the new value in the file. (hint: use fseek function)
The program should then read all 10 values and print them back.
Page 17 of 154