Saturday, December 24, 2011

questions of CSit


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.

  1. Find the value of “a” in each of the following statements:
    http://1.bp.blogspot.com/-8T3XiVM6Rlc/Tr3X4s7R4fI/AAAAAAAAAO4/Fge1wkuy5Og/s1600/image001.png
    http://1.bp.blogspot.com/-e-bmQZJJ5Cw/Tr3X8k3Qv-I/AAAAAAAAAPA/jVsg_w2n5AA/s1600/image002.png
    1. http://2.bp.blogspot.com/-fAR7GHBqh38/Tr3YA13d29I/AAAAAAAAAPI/U3_JP6Augx8/s1600/image003.png
    2. http://3.bp.blogspot.com/-7HEclOPA3P0/Tr3YFH8c06I/AAAAAAAAAPQ/O4_9c9PFkx8/s1600/image004.png
    3. http://1.bp.blogspot.com/-6xYh_KDhyaw/Tr3YJdGXV3I/AAAAAAAAAPY/FaRCPb5yTyA/s1600/image005.png
    4. http://3.bp.blogspot.com/-Cnfis-cSmic/Tr3YRXmp-SI/AAAAAAAAAPg/XEryxO7zNzI/s1600/image006.png
    5. http://2.bp.blogspot.com/-ZAFOjNj8Rrw/Tr3YU7semeI/AAAAAAAAAPo/m3aiiPgDVLw/s1600/image007.png
    6. http://4.bp.blogspot.com/-L9o-1KtKuBo/Tr3YWonx3EI/AAAAAAAAAPw/6otvodoHFcM/s1600/image008.png

  1. 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?

  1. 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?

  1. 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.

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.

  1. Write a program to obtain the product of the following matrices:
    http://3.bp.blogspot.com/-cpq1yG4kJPc/Tr3YY5oNUnI/AAAAAAAAAP4/mRIC757iDvQ/s1600/image009.png

  1. Write a program to transpose the following matrix.
    http://2.bp.blogspot.com/-WDEZ3DVNfYQ/Tr3YbaV24GI/AAAAAAAAAQA/nAfUTo4EAC4/s1600/image010.png

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

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

  1. 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.

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

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

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

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

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

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

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

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

  1. 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.

  1. Given a text file, create another text file deleting all the vowels (a, e, i, o, u).
C Programming Paper 2065
Tribhuvan University
Institute of Science and Technology
2065

Bachelor Level/ First Year/ First Semester/ Science                      Full Marks: 60
Computer Science and Information Technology (CSc 102)     Pass Marks: 24
(Fundamental of Computer Programming)                                      Time: 3 hours.
Candidates are required to give their answers in their own words as for as practicable.
All questions carry equal marks.
Attempt all questions.
  1. Draw the flow chart for finding largest of three numbers and write an algorithm and explain it.
  2. Find the value of “a” in each of the following statements:
 http://2.bp.blogspot.com/-FOo2DQ2TvcY/TrwDT5BfvVI/AAAAAAAAAMQ/hIuCeNbj8Ws/s1600/image001.png
 http://2.bp.blogspot.com/-Gte5Ot7IxKk/TrwDVFkxrgI/AAAAAAAAAMY/M6mQO_VSu4k/s1600/image002.png
    1. http://2.bp.blogspot.com/-Mqng64R-D70/TrwDWgu2iFI/AAAAAAAAAMg/nWw2CeSLHEU/s1600/image003.png
    2. http://3.bp.blogspot.com/-MDGJ5JTx5xU/TrwDYOaO7II/AAAAAAAAAMo/k0998qfnCKQ/s1600/image004.png
    3. http://3.bp.blogspot.com/-onYV8EYTB_s/TrwDaArRiAI/AAAAAAAAAMw/aaXlY4NJeAY/s1600/image005.png
    4. http://2.bp.blogspot.com/-2dJeUdd3LIw/TrwDcLuZWiI/AAAAAAAAAM4/XrkwkbQSvi8/s1600/image006.png
    5. http://4.bp.blogspot.com/-_ZO14Hu7JjI/TrwDduXnfmI/AAAAAAAAANA/8xwxvvk3rZQ/s1600/image007.png
    6. http://1.bp.blogspot.com/-p9Hh16OK03g/TrwDe1NGrLI/AAAAAAAAANI/M0phn1rLML8/s1600/image008.png.
  1. Write a program for the interest charged in installments for following case. A cassette player costs Rs. 2000. A shopkeeper sells it for Rs. 100 down payment and Rs. 100 for 21 more months. What is the monthly interest charged?
  2. Write a program that uses a “for” loop to compute and prints the sum of a given numbers of squares.
  3. Write a program to obtain the product of the following matrices and explain it: http://1.bp.blogspot.com/-rUXxSx-0j14/TrwDkyRwMSI/AAAAAAAAANQ/ZryhjNjsrOk/s1600/image009.png
  4. Write a function to add, subtract, multiply, and divide two complex numbers http://3.bp.blogspot.com/-KqasrAzPM-4/TrwDl6XaOmI/AAAAAAAAANY/G3MC3zawReY/s1600/image010.png and http://4.bp.blogspot.com/-B7TMns8pq-w/TrwDnHI7M9I/AAAAAAAAANg/g0HYlk_thLw/s1600/image011.png.
  5. Write a program which will read a line and delete from it all occurrences of the word “that”.
  6. What is a pointer and explain its applications? Write a program that uses pointers to copy an array of double.
    OR
    Define a pointer. Write a function that is passed an array of 'n' pointers to the maximum of the 'n' floats.
  7. Define a structure of employee having data members name, address, age, and salary. Take data for 'n' employee in an array dynamically and find the average salary.
  8. Given a text file, create another text file deleting the following words “three”, “bad”, and “time”.
    OR
    Why do you require graphical function? Explain the basic graphical function with suitable program.
C Programming Paper 2066
Tribhuvan University
Institute of Science and Technology
2066

Bachelor Level/ First Year/ First Semester/ Science                              Full Marks: 60
Computer Science and Information Technology (CSc 102)             Pass Marks: 24
(Fundamentals of Computer Programming)                                                Time: 3 hours.
Candidates are required to give their answers in their own words as for as practicable.
All questions carry equal marks.
Attempt all the questions.
  1. Why flowchart is required? Explain different symbols used in the flow chart and explain with suitable example.

  1. Determine which of the following are valid identifiers? If invalid, explain why?
    (a)    record1                                   (b)  1record
    (c)    file_3                                      (d)   return
    (e)   #tax                                          (f)   name
    (g)    goto                                        (h)  name and address
    (i)      name-and-address                  j)   123-45-6789
    (k)    void                                         (l)   name_address

  1. Find the error in the given program and explain it. Write the correct program.
    #include<stdio.h>
    include<math.h>
    main
    {
    float p, r, n;
    printf(“Please enter a value for the principle (P):”);
    scanf(“%f”, &p);
    printf(“Please enter a value for the interest rate (R)”);
    scanf(“%f”, &r);
    printf(“Please enter a value for the number of years (n):”):
    scanf(“%f”, n);
    f = p * pow + r/100),n);
    printf(\n The final value (F) is: %. 2f\n”, f);

  1. Write a program that uses a “while” loop to compute and prints the sum of a given numbers of squares. For example, if 4 is input, then the program will print 30, which is equal to 12+22+32+42.

  1. Write a program to enter two 3x3 matrices and calculate the product of given matrices.

  1. Explain the use of two dimensional arrays. Illustrate it with suitable program and explain it.

  1. Write and test the following power() function that returns 'x' raised to the power 'n', where 'n' can be any integer:
     double power (double  x, int p)

  1. Justify the pointer is jewel of C language. Write a function that is passed an array of 'n'  pointers to floats and returns a newly created array that contains those 'n'  float values in reverse order. Assume any necessary data.
    OR
    Explain pointer with suitable diagram. Write a function that uses pointers to search for the address of a given integer in a given array. If the given integer is found, the function returns its address; otherwise it returns NULL.

  1. Why structure is required? Make a program using structure of booklist having data member’s title, author, and cost. Enter four data and calculate total cost.

  1. Create a text file and enter “to write a good program is very time consuming job”. Create another text which contains reverse of above text.
    OR
    Explain the use of graphical function. Make a program that contains basic graphic functions.
C Programming Paper 2067
Tribhuvan University
Institute of Science and Technology
2067
Bachelor Level/ First Year/ First Semester/ Science                                          Full Marks: 60
Computer Science and Information Technology (CSc. 102)                         Pass Marks: 24
Fundamental of Computer Programming)                                                              Time: 3 hours.
Candidates are required to give their answers in their own words as for as practicable.
All questions carry equal marks.
Attempt all questions.
  1. Draw the flowchart for the solution of a quadratic equation and write an algorithm and explain it.

  1. Find the value of “a” in each of the following statements:
    http://2.bp.blogspot.com/-1ByYHM1yKnI/Try_6h3QO7I/AAAAAAAAANw/9a_Eu3lvfhA/s1600/image002.png
    http://1.bp.blogspot.com/-1hMrNi28F54/Try_8kJkwCI/AAAAAAAAAN4/KL_fhhpBlgw/s1600/image003.png
    1. http://1.bp.blogspot.com/-GW7teCOAHMQ/Try_-aNwK1I/AAAAAAAAAOA/kchnVZcnEJ4/s1600/image004.png;
    2. http://2.bp.blogspot.com/-vXZw5wAN9y8/TrzAAf9UHfI/AAAAAAAAAOI/b39gmGxZYwI/s1600/image005.png;
    3. http://3.bp.blogspot.com/-YetECa0IWP8/TrzACNvabcI/AAAAAAAAAOQ/SkAMWbl_SFY/s1600/image006.png;
    4. http://4.bp.blogspot.com/-MlF0XI78O3w/TrzAD3hef7I/AAAAAAAAAOY/Syjt8QRsgxk/s1600/image007.png;
    5. http://2.bp.blogspot.com/-NdfxdvWhNFw/TrzAFK2FSBI/AAAAAAAAAOg/BtXr_AvYWkI/s1600/image008.png;
    6. http://1.bp.blogspot.com/-vphv47fxR-s/TrzAGdElBMI/AAAAAAAAAOo/9lLBs0-I1Go/s1600/image009.png;

  1. A machine is purchased which will produce earning of Rs. 20000 per year while it lasts. The machine costs Rs. 120000 and will have a salvage value of Rs. 20000 when it is condemned. If the 12 percent per 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?

  1. Write a program to transpose the following matrix.
    http://2.bp.blogspot.com/-w9ePXe5M6vI/TrzAH3e8gEI/AAAAAAAAAOw/V0aiiE1oH1o/s1600/image010.png

  1. Write a program that uses a do…while loop to compute and prints the sum of squares given n numbers.

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

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

  1. Why pointer is called jewel of C language? Write a program that uses pointers to copy an array of integer.
    OR
    Explain the importance of pointer. Write a function that is passed an array of n pointers to floats and returns a newly created array that contains those n float values.

  1. Define a structure of student having data members, name, address, marks in C language, and marks in information system. Take data for n students in an array dynamically and find the total marks obtained.

  1. Some text file is given; create another text file replacing the following words “Ram” to “Hari”, “Sita” to “Gita”, and “Govinda” to “Shiva”.
    OR
    What are the uses of graphical function? Explain the basic graphical function with suitable program.