Saturday, November 12, 2011

C Programming Sample Questions (BSc CSIT)

TRIBHUVAN UNIVERSITY
INSTITUTE OF SCIENCE AND TECHNOLOGY
FUNDAMENTAL OF COMPUTER PROGRAMMING
SAMPLE QUESTIONS

In the final examination, there will be 10 questions covering all chapters according to their class weightage. Two selected questions will have option.
  1. Draw the flow chart and write an algorithm for finding smallest of three numbers and explain.

  2. Find the value of “a” in each of the following statements:


  3. A machine is purchased which will produce earning of Rs. 10000 per year while it lasts. The machine costs Rs. 60000 and will have a salvage value of Rs. 20000 when it is condemned. If the 12 percent annum can be earned on alternative investments what should be the minimum life of the machine to make it a more attractive investment compared to alternative investments?

  4. The interest charged in installments buying is to be calculated by a computer program. A tape recorder costs Rs. 2000. A shopkeeper sells it for Rs. 100 down and Rs. 100 for 21 more months. What is the monthly interest charged?

  5. Obtain decision tables for simulating an automatic stamp vending machine with the following specifications:
    1. It should dispense 25, 15, and 10 paisa stamps.
    2. It should accept 50, 25, 10, and 5 paisa stamps.
    3. It cannot accept more than one coin for each transaction.
    4. If more than one coin of the same denomination is to be returned as change after dispensing the stamp, the machine cannot do it. Instead the coin should be returned and a “no change” signal turned on.
    5. The machine should dispense the stamp and the right change and must indicate exceptional cases such as “insufficient amount tendered”, “no stamp available”, “no change available”, etc.

    6. Write a program to simulate the machine. The input to the program would be amount tendered and stamps requested. The output of the program should be whether stamp is dispensed or not, the value of the stamp dispensed, the denomination of the coins returned (if any) and no change signal if no change is returned and no stamp if the stamp is not available.

  6. Write a program to obtain the product of the following matrices:

  7. Write a program to transpose the following matrix.

  8. Write a program to find the sum of squares of elements on a diagonal of a square matrix.

  9. Write a function to add, subtract, multiply and divide two complex numbers (x + iy)  and (a + ib).

  10. Write a function to multiply a square-matrix by a vector. Assume a n x n matrix and a 'n' component vector. The call would give the size of the matrix and the names of the matrix and a vector.

  11. Write a function to multiply two n x n matrices.

  12. Write a function to short a set on n numbers in ascending order of magnitude. How would this routine be called?

  13. Write a program to delete all vowels from a sentence. Assume that the sentence is not more than 80 characters long.

  14. Write a program to count the number of words in a sentence.

  15. Write a program which will read a line and squeeze out all blanks from it and output the line with no blanks.

  16. Write a program which will read a line and delete from it all occurrences of the word “the”.

  17. Write a program to count the number of occurrences of any two vowels in succession in a line of text. For example, in the following sentence:
    “Please allow a studious girl to read behavioral science”
    Such occurrences are ea, io, ou, ie.
    Observe that in a word such as studious we have counted “io” and “ou” as two separate occurrences of two consecutive vowels.

  18. Define a structure Employee having data members name, address and salary. Take data for n employee in an array dynamically and find the average salary.

  19. Define a structure Coordinate having data members x and y for x and y coordinates. Take values for two points and find the distance between them. Use a function to calculate the distance but the result should be displayed in main function.

  20. Define a structure student having data members name, class, section and marks for six subjects. Use array within structure to represent the marks in different subjects. Take the information for the n numbers of students given by user dynamically and display their percentage.

  21. Define a structure Table having data members length, breadth and height. Represent different measurements by another structure Measurement having data members meter and centimeter. Take data for some table and find their volume.

  22. Define a structure Table for Vehicle Owner having data member name, address, telephone number, vehicle number and license number. Take the data for ten owners write them in file “Own.txt”. Read the data from the file and display them.

  23. Given three variables x, y and z, write a function to circularly shift their values. In other words if x=5, y=9 and z=8, after circular shift y=5, z=9 and x=8. Call the function with variables a, b and c to circularly shift their values.

  24. Write a function to solve a quadratic equation a2+bx+c=0. The input to be the function are the values a, b and c and the outputs of the function should be stored in variable names p and q appropriately declared.

  25. Write a function which will take as its input a matrix mat of size (m x n), where (m < 10, n < 5) and return the same matrix with all its elements replaced by absolute values.

  26. Suppose a store has a number of items in their inventory and that each item is supplied by at most two suppliers. Create inventory and supplier files. Find the address of all suppliers who supply more than 10 different items. Discuss any changes in the data structure you suggest to simplify solving this problem.

  27. Arrange the master file in descending order of average marks and create a new file.

  28. Assume that at the end of the year a set of student join the class and another set leaves. Using the roll number and an appropriate code to add or delete student update the master file. The updated file should be in ascending order of the roll number.

  29. Given a text file, create another text file deleting all the vowels (a, e, i, o, u).

0 comments:

Post a Comment