You are on page 1of 8

List of programs

IIIT KOTA
C programming (batch-B1 & B2)
(Assignment 1)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS
Write a program for the following:

1.
2.
3.
4.
5.
6.
7.

8.
9.
10.
11.
12.
13.
14.
15.

Batch- B1
(basic operators)
2nd September 2015
Basic structure of a program.
Display/ print "welcome to IIIT Kota".
Reads the ASCII code of a number and prints out the symbol associated with the code.
Calculate simple interest and compound interest without using scanf.
Implement all basic operators: arithmetic, logical, relational, conditional, bitwise, post and pre-increment and
decrement.
Swap values of two variables using third variable and without using third variable.
If the marks obtained by a student in six different subjects are input through the keyboard, find out the average and
percentage obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject
is 50.
Calculate area of the triangle, base and height are user defined.
Ram's basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent
allowance is 20% of basic salary. Write a program to calculate his gross salary.
Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature
into Centigrade degrees.
Convert given number of days to a measure of time given in years, weeks and days. For example 375 days is equal to 1
year 1 week and 3 days (ignore leap year).
If a 4-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the
modulus operator '%')
The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate
the area & perimeter of the rectangle, and the area & circumference of the circle.
If a 5-digit number is input through the keyboard, write a program to obtain the sum of the second and second last digit
of this number.
In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of
the total population, write a program to find the total number of illiterate men and women if the population of the town
is user define.

(Assignment 2)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS

16.

17.

18.
19.
20.

Batch- B1
(control statements)
9nd September 2015
Write a program to print given pattern using print function only:
A
A
B
A
B C
A
B C D
Print given pattern using print function only:
*
**
***
**
*
If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to
find the cost price of two items.
If length of sides of a square is input through the keyboard, write a program to print area of the square.
Write a program to receive Cartesian co-ordinates(x, y) of a point and convert them into polar coordinates (r, q).

21. If a 5-digit number is input through the keyboard, write a program to print a new number by adding one to first digit,
two in second, three in third, four in fourth, five in fifth digit of number. For example if the number that is input is
11111 then the output should be displayed as 23456.
22. Enter an integer through the keyboard and find out that given number is Armstrong or not.
23. Program to find the largest of three Numbers using if-else statement.
24. Any integer is input through the keyboard. Write a program to find out whether it is an odd number or even number
using if-else statement.
25. If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the youngest of the
three.
26. Program to find whether a given number is zero or non-zero integer.
27. Find a number which is divisible by 6 but not divisible by 4.
28. Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not.
29. Enter 5 digits number through the keyboard and calculate the sum of all digits by using single variable.
30. Program to read age and gender through keyboard, identify and display the number of child, young and old peoples
based on input data, also find the number of male and female.
31. Write a program to round off an integer i to the next largest multiple of another integer j . For example, 256 days when
rounded off to the next largest multiple divisible by a week results into 259.
32. If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller
has made profit or incurred loss. Also determine how much profit he made or loss he incurred.
33. Any 5 digit number is input through the keyboard. Write a program to find out whether the sum of digits is an odd
number or even number.
34. Paper of size A0 has dimensions 1189mm x 841mm. Each subsequent size A(n) is defined as A(n-1) cut in half parallel
to its shorter sides. Write a program to calculate and print paper sizes A0,A1,A2,A3,A4...A8.
35. A five-digit number is entered through the keyboard. Write a program to obtain the reversed number and to determine
whether the original and reversed numbers are equal or not.
36. Write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered through the
keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees.
37. Program to use switch statement. Display Monday to Sunday.
38. Program to design calculator using switch case statement.
39. Using conditional operators determine:
(1) Whether the character entered through the keyboard is a lower case alphabet or not.
(2) Whether a character entered through the keyboard is a special symbol or not.
40. university has the following rules for a student to qualify for a degree with A as the main subject and B as the
subsidiary subject:
(a) He should get 55 percent or more in A and 45 percent or more in B.
(b) If he gets less than 55 percent in A he should get 55 percent or more in B. However, he should get at least 45 percent
in A.
(c) If he gets less than 45 percent in B and 65 percent or more in A he is allowed to reappear in an examination in B to
qualify.
(d) In all other cases he is declared to have failed.
Write a program to receive marks in A and B and Output whether the student has passed, failed or is allowed to reappear
in B.
41. In a company, worker efficiency is determined on the basis of the time required for a worker to complete a particular
job. If the time taken by the worker is between 2 & 3 hours, then the worker is said to be highly efficient. If the time
required by the worker is between 3 & 4 hours, then the worker is ordered to improve speed. If the time taken is
between 4 & 5 hours, the worker is given training to improve his speed, and if the time taken by the worker is more
than 5 hours, then the worker has to leave the company. If the time taken by the worker is input through the keyboard,
find the efficiency of the worker.
42. An Insurance company follows following rules to calculate premium.
(1) If a person's health is excellent and the person is between 25 and 35 years of age and lives in a city and is a male
then the premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2 lakhs.
(2) If a person satisfies all the above conditions except that the sex is female then the premium is Rs. 3 per thousand and
her policy amount cannot exceed Rs. 1 lakh.
(3) If a person's health is poor and the person is between 25 and 35 years of age and lives in a village and is a male then
the premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000.
(4) In all other cases the person is not insured.
Write a program to output whether the person should be insured or not, his/her premium rate and maximum amount for
which he/she can be insured.

(Assignment 3)

Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS

43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.

54.
55.
56.
57.
58.
59.
60.

Batch- B1
(loop statements)
16th September 2015
Write a program to accept a string and an integer from the user and print the string as many times as the value of the
integer. The execution should continue until the user presses q to quit.
Program that displays the first 10 multiples of 5 in a single line using for loop.
Write a program to find the sum, and the sum of squares of the first 15 positive, natural numbers using for loop.
Write a program to find the sum, and the sum of squares of 15 positive, natural numbers (count from 2 to 30 in steps of
two) using for loop.
Program to calculate the sum all even numbers from 0 to 100, and display the resultant value.
Program to calculate the sum all odd numbers from 0 to 100, and display the resultant value.
Write a program that accepts a number from 0 to 9 along with a string to be displayed a specified/number of times. Use
the switch-case construct.
Program to accept characters until q is presses. Display each character immediately after it is accepted.
Write a program to calculate factorial of any given number.
Write a program to print all the ASCII values and their equivalent characters using a while loop. The ASCII values vary
from 0 to 255.
Write a program that accepts 0,1, or 2. if 0 is entered by the user, accept the necessary parameters (radius, height, etc.)
to calculate the volume of a cylinder. Input 1 and 2 correspond to cylinder and cone, respectively. Note that the above
process must go on until the user enters q to terminate the program.
Write a program that, for all positive integers i, j , k, and l from 1 through 1000, finds and prints all combinations of i, j
, k, and I such that i + j + k = l and i < j < k < l.
Write a program to generate the first hundred terms of the Fibonacci series.
Program to find and display the even and odd numbers in between 0 to 100.
Program to compute exponential series up to N terms.
Write a program to generate the first fifty terms of the Fibonacci series and print their sum and average.
Write a program to check if an integer input from the user is positive or negative (for n terms). (include 0 with the
positive numbers).
Write a program to generate all combinations of 1, 2 and 3 using for loop.

(Assignment 4)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS

61.

62.
63.
64.
65.
66.
67.
68.
69.

Batch- B1
(looping)
23rd September 2015
Write a program to read the names, register number and , marks for 3 subjects of each student in a class. Let the number
of students be entered by the user. Compute the average marks of each student and display the result in the following
format.
------------------------------------------------------------------------------Name
Register Number
Average Result
------------------------------------------------------------------------------The result is Passed if the average is greater than or equal to 40 and the marks for each subject is greater than or equal
to 35. Otherwise display Failed.
Write a program to find the smallest of 3 numbers using while loop. Note that the above process must go on until the
user enters q to terminate the program.
Write a program to find the largest of 4 numbers using do-while loop. Note that the above process must go on until the
user enters q to terminate the program.
Write a program that reads in N numbers and finds the smallest number among them.
Program to check if an entered number is prime or not.
Program to find all the prime numbers till N.
Program to print all even number from 0 to 100.
Program to find the prime numbers between two numbers A and B entered by the user. Ensure that the values entered
for A is less than that for B.
Write a program that finds N prime numbers from N onwards i.e; if N=13, starting from 13, thirteen prime numbers
have to be found.

70.
71.
72.

73.
74.
75.
76.
77.
78.

79.
80.

Write a program to print cosine series using while loop.


Write a program to find the sum of squares of the digits of a number. For example, if the number is 12, the answer
should be 12 + 22 = 5.
Write a program to find the sine and cosine of an angle given in degrees. Remember that the argument for sin and cos is
in radians. So the value in degrees will have to be converted to radians using the relation :
Angle in radians = (angle in degrees * pi)/ 180 .
Write a program to accept numbers from user till their sum exceeds 50.
Write a program to fill the entire screen with a smiling face. The smiling face has an ASCII value 1.
Write a program to check whether a given number is palindrome or not by using for loop.
Write a program to find all the numbers between 1 and N that are divisible by 5 and 13.
Design and implement a program to accept three sides of a triangle and determine it's type. Note that the above process
must go on until the user enters q to terminate the program.
Write a program for a matchstick game being played between the computer and a user. Your program should ensure
that the computer always wins. Rules for the game are as follows:
- There are 21 matchsticks.
- The computer asks the player to pick 1, 2, 3, or 4 matchsticks.
- After the person picks, the computer does its picking.
- Whoever is forced to pick up the last matchstick loses the game.
Write a program to find the sum, mean and percentage deviation from the mean of N numbers.
Following is a while construct to input a series of numbers, and exit the loop when the sum of the numbers entered so
far is divisible by 5.
int i, sum=0;
while(1) /*infinite loop*/
{
scanf(%d, &i);
sum += i;
if (sum % 5 == 0)
break;
}
Rewrite the statements using a do-while construct. Do not use the break statement. Does it make any difference if
you input all numbers on a single line separated by spaces or input them by pressing the enter key after each number?

(Assignment 5)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS
Batch- B1
(looping)
7th October 2015
Note: Write a program to produce the following patterns using for loop where number of lines entered by the keyboard: (Q
81 to Q 92)
81.

82.

*
**
***
****

*
**
***
****
83.

If input is 4:

84.

SSSS
SSSS
SSSS
SSSS
85.

SSSS
S
S
S
S
SSSS
86.

1234
123
12
1

1234
567
89
0

87.

i.e. if input is 7:

88.

*
**
***
****
***
**
*
89.

91.

*
**
***
****
***
**
*

If input is 7 then:
*
***
*****
*******
*****
***
*

90.

If input is 5:

92.

If input is 8:
*
***
*****
*******
*******
*****
***
*

1
234
56789
012
3

If input is 6:
6 7 8 9 10 11 10 9 8 7 6
567898765
4567654
34543
232
1

Note: write a program to produce the following patterns using while loop, number of lines entered by keyboard: (Q 93
to Q 104)
93.

94.

0
10
010
1010
01010
95.

12345
1234
123
12
1
96.

1
121
12321
1234321
97.

If input is 5:

7654321
54321
321
1
98.

1
123
12345
1234567
123456789
99.

If input is 8:

123456789
1234567
12345
123
1
100.

*
**
***
****

*
**
***
****

****
***
**
*

****
***
**
*
101.

If input is 6:

102.

1
234
56789
01234
567
8
103.

If input is 5:

If input is 6:

10 9 8 7 6 5 4 3 2 1 0
10 9 8 7 5 3 2 1 0
10 9 8 5 2 1 0
10 9 5 1 0
10 5 0
5
104.

1
11
121
1331
14641

1
23
456
7 8 9 10

(Assignment 6)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS

Batch- B1
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.

(array)

14th October 2015

Program to read the age of 5 persons, printing them out individually and computing the average using array.
Find out the greatest element in an array of N size.
Write a program to compute addition of two arrays.
Write a program to print alternate element of an array.
Program to compute multiplication of two arrays.
Program to print reverse of an array.
Program to arrange array elements in an ascending order.
Write a program to count the number of elements in an array.
Write a program to insert a value in the given array at position N. (array elements and position are user defined).
Write a program to calculate mean, variance and standard deviation for N items by using array and looping.
Write a program to input and print 5 x 5 matrix (2D array).
Write a program to input and print N x M matrix.
Write a program for addition of two user defined (n x m) matrices.
Write a program to find the smallest element in a 3 x 3 matrix.
Write a program to calculate sum of diagonal elements of a matrix of ( n x m ) order.
Write a program to calculate the sum of all elements of N x M matrix, and display the resultant value of sum.
Write a program to perform matrix multiplication.
Write a program to compute Transpose of a matrix.

(Assignment 7)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS

Batch- B1
123.
124.

125.
126.
127.
128.
129.
130.
131.
132.

133.
134.

135.
136.
137.

(array & string)

21st October 2015

Program for illustration using a string literal. (Hint: use string initialization and print that string).
Write a program, which reads your name from the keyboard and outputs a list of ASCII code, which represent your
name.
Write a program to convert the string from upper case to lower case.
Write a program to sort the characters of a string.
Write a program for concatenation of two different strings.
Write a program to copy one string to another.
Write a program to find the length of a string.
Write a program to compare two strings.
Write a program to display 2D-array of strings where that array of string initializes with 5 names.
Write a program to do the following:
a) To output the question who is the inventor of C?
b) To accept an answer.
c) To print out Good and then stop, if the answer is correct.
d) To output the message try again, if the answer is wrong.
e) To display the correct answer when the answer is wrong even at the third attempt and stop.
Write a program which will read a string and rewrite it in the alphabetical order. (example: the word STRING should
be written as GINRST).
Write a program to extract a portion of a character string and print the extracted string. Assume that m characters are
extracted, starting with the nth character.
Write a program to delete duplicates in a vector.
Write a program which will read a text and count all occurrences of a particular word.
Write a program to calculate grades of N students from three different tests. (Consider string for name and float type
2D-array for calculation).

(Assignment 8)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS

Batch- B1
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.

(function and pointer)

28st October 2015

Write a program to print hello world, using pointers.


Write a program to calculate multiplication of two numbers using pointers.
Write a program to convert a floating point number into an integer using pointers.
Write a program to find the biggest of three numbers using pointer.
Write a program to print a character. Also print its ASCII value and rewrite the character in upper case.
Program to find square of a number using functions.
Program to swap two numbers using functions.
Program to find biggest of three integers using function.
Program to calculate area of a circle using function.
Program using functions, to find whether a number is even or odd.
Program to convert time to minutes using function.
Write a program to print descending order of a given array using function.
Program to show table of a number using (a). call by value , (b). call by reference.
Program to find factorial of a number using (a). call by value, (b).call by reference.
Write a program to add two numbers using (a).,call by value, (b).call by reference.
Write a program to swap the values of two numbers using call by reference.
Write a program to input 5 digits integer and print the sum of digits using recursion.
Write a program to product two numbers using recursion.

Write a program to calculate factorial of a number using recursion.


157. Write a program to print reverse of a number using recursion.
158. Write a program to print Fibonacci series using recursion.
156.

(Assignment 9)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS

Batch- B1
159.
160.

161.
162.

163.
164.
165.
166.
167.

168.

(structure and union)

4th November 2015

Define a structure type, struct personal that would contain person name, date of joining and salary. Using this
structure, write a program to read this information for one person from the keyboard and print the same on the screen.
Write a program to illustrate the comparison of structure variables.(Hint: consider two structure variables and do
comparison between both).
Write a program to declare a structure to store customer information.(example: customer ID, name, address, phone
number, DOB).
Write a program to implement a structure to save and display student marks records for N different subject along with
subject name.
Write a program to declare a structure to store information of a particular date.(example: day, month, year)
Write a program to print salary structure of an employee using union.
Write a program using union to save n print information about a student.
Write a program to declare a union to store information of a book.(example: title, author, pages, price, edition, year of
publication)
write a program to read and display the information of all the students in the class. Then edit the details of the i th
student and redisplay the entire information by using union.
Write a program to read, display, add, and subtract two heights. Height should be in feet and inches.(a). using structure
(b). by using union.

(Assignment 10)
Please maintain softcopy of your codes and prepare a Lab Record consisting these program by hand (no print-out).Also
prepare flow chart for the same in lab record.
//C STARTUP PROGRAMMS

169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.

Batch- B1
(file handling)
18th November 2015
Write a program to input information of a student (name, roll number, etc.) from one file to another file by using
fscanf().
Write a program to read a file character by character, and display it simultaneously on the screen.
Write a program to count the number of characters and number of lines in a file.
Write a program to print the text of a file on screen by printing the text line by line and displaying the line numbers
before the text in each line. Use command line argument to enter the filename.
Write a program to copy one file into another. Copy one character at a time.
Write a program to copy one file into another. Copy multiple characters simultaneously.
Write a program to read some text from the keyboard and store it in a file.
Write a program to read the details of a student and then print on the screen as well as write it into a file.
Write a program to read the details of a student from a file and then print it on the screen
Write a program to delete the record of a particular student.
Write a program to store records of an employee in employee file. The data must be store using binary file.
Write a program to append a record in the employee file (binary file).