You are on page 1of 4

MCA-I ('2018)

DEPARTMENT OF COMPUTER SCIENCE


ROLLWALA COMPUTER CENTER, GUJARAT UNIVERSITY
FUNDAMENTALS OF PROGRAMMING
ASSIGNMENT-I

1. Given three numbers write a program to determine the maximum of 3 numbers.

2. Admission to a professional course is subject to the following conditions :


(a) marks in mathematics >= 60
(b) marks in physics >= 50
(c) marks in chemistry >= 40
(d) total in all three subjects >= 200
or
total in mathematics and physics >= 150
given the marks in the three subjects , write a program to process the applications to list an eligible candidate.

3. Write a program that reads the percentage obtained by the students and determines and prints the class obtained by the student as per the following rules (use switch case)

Percentage Class

0 - 39 Fail
40 - 59 Second class
60 - 79 First class
80 - 100 Distinction

4. Write a program to calculate the area of circle/rectangle/triangle. Determine whose area is to be calculated by accepting the code from the user. Let (use switch case)
C indicate circle ,
R indicate rectangle,
T indicate triangle.
use symbolic constant to define the value of pie.

5. Write a program to calculate the average of a set of n given numbers.

6. Write a program to swap the values of two variables.

7. Consider the following foreign currencies and their equivalents to one u.s. dollar :

British pound 0.6 pounds per u.s. dollar


Canadian dollar 1.3 dollars per u.s. dollar
Dutch guilder 2.0 guilders per u.s. dollar
French franc 6.0 francs per u.s. dollar
Italian lira 1250 lira per u.s. dollar
Japanese yen 140 yen per u.s. dollar
Mexican peso 1600 pesos per u.s. dollar
Swiss franc 1.4 francs per u.s. dollar
German mark 1.7 marks per u.s. dollar

Write an interactive menu driven program that will accept two different currencies and return the value of the second currency per one unit of the first currency.
8. Generate the following "pyramid" of digits, using nested loops
1
232
34543
4567654
567898765
67890109876
7890123210987
890123454321098
90123456765432109

9. Write a program to generate the following

ABCDEFGHGFEDCBA
ABCDEFG GFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABC DCBA
ABC CBA
AB BA
A A

10. Write a program to find the smallest divisor of an integer.

11. Write a program to find the greatest common divisor of two integers.

12. Write an interactive 'c' program that will convert a date, entered in the form mm-dd-yy (example : 4-12-1996) into an integer that indicates the
number of days beyond January 1,1990.

13. Write an interactive program that will read in a positive integer and determine the following
(1) if the integer is a prime number
(2) if the integer is a Fibonacci number

write the program in such a manner that it will execute repeatedly, until a zero value is detected for the input quantity.

14. The sine of x can be calculated approximately by summing the first n terms of the infinite series
sin x = x - x3 /3! + x 5/5! – x7 /7! + ...........

write a 'c' program that will read in a value for x and then calculates its sine. Continue adding successive terms in the series until the value of the
next term becomes smaller than 10 to the powe -5.

15. A leap year is any year divisible by 4, unless the year is divisible by 100, but not by 400. Write a program to tell if a year is a leap year.
16. A professor generates letter grades using following table

% | grade
_________________
0-60 | F
61-70 | D
71-80 | C
81-90 | B
91-100| A

Given a numeric grade, print the letter.


17. Modify the previous program to print a + or - after the letter grade,
based on the last digitof the score. The modifiers are listed below.

last digit | modifier


___________________________
|
1-3 | -
4-7 | blank
8-0 | +

for example 81 = B+ , 94=A, 62= D-


note : F is only F. There is no F- or F+.

18. Write a program that converts numbers to words. For example , 895 should result in " eight nine five".

19. Modify the previous program to handle numbers 0 through 100 so that all numbers come out as we really say them. For example, 13 would be "thirteen",
85 woud be "eighty five" and 100 would be "one hundred.

20. Write a 'c' program that reads in two matrices and multiply them. Display the resultant matrix.

21. Write a 'c' program that reads in two matrices and add them. Display the resultant matrix.

22. Write a program to read a matrix and determine the following :


(1) wheather the given matrix is upper triangular or not
(2) wheather the given matrix is lower triangular or not
(3) wheather the given matrix is digonal matrix or not

23. Write a 'c' program that reads a unsorted list of numbers in an array. Sort the given array and then searches a given number in the array using
binary search technique.

24. Write a 'c' program to sort a given list of names using insertion sort technique.

25. Write a 'c' program to sort a given list of names using selection sort technique.

26. Write a 'c' program to sort a given list of names using bubble sort technique.

27. Write a 'c' program to merge two given sorted lists of names into single sorted list of names.

28. The annual examination results of 100 students are tabulated as follows
_____________________________________________________________
roll no. Subject1 subject2 subject3
_____________________________________________________________

_____________________________________________________________

write a program to read the data and determine the following :

(1) total marks obtained by each student.


(2) the highest marks in each subject and the roll no. of the student who secured it.
(3) the student who obtained the highest total marks.
29. Write a program to remove the duplicates from an ordered array.

30. Write a program to find the maximum number in the set.

31. Write a program to find the kth smallest number in an array (without sorting the array)

32. Write a program to replace a particular word by another word in a given string. For example, the word "pascal" should be
replaced by "c" in the text "it is good to program in Pascal language".

33. Write a program to find the longest monotone sequence in a given list of numbers.

34. Write a program to generate all permutations of the first n integers taken r at a time. The value of n and r must be greater than zero.
for example if n refers to first 5 integers and they are to be sampled 3 at a time (i.e. R = 3), the first few and the last permutation are listed below
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 2 1
1 2 2
1 2 3
.........
.........
.........
5 5 5

35. Write a program to generate all combinations of the first n integers taken r at a time. The value of n and r must be greater than or equal
to one. The ten combinations of the first 5 integers taken 3 at a time are :
1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5

36. Write a program to test whether a given string is palindrome or not.


37. Write a program to reverse a given string.

38. Write a program to read a string and display no of occurrences of each character present in the string.
39. Write a program to encrypt a string entered by the user. The Encryption table for random encryption should be given in the program and used for encryption.

40. Write a program to sort a given list of names without using string functions.

41. Given a score of n students examination marks ( in the range 0 to 100) make a count of the number of students that obtained each possible mark
and show the result in the form of the histogram.

_______________________________________________________________________________

You might also like