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:
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfLCrhyphenhyphenUFRhPuIorCaaOhnsbOPbYvZerm9jG1omVa4AMOKZINHq0RLBQ7LhWnBRPg4gXbA63qJzrwS1tHXTjAGSaXir0IHMX-LIrWwhbGXIDHCzo7v4veOoipqCmA1zEKzt6HzVkSD5JE/s1600/image001.png
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfynC9eX-cnz1N3HgUG7b7dzCzecWO8V3ca2ZjkbUncXWl7D8vjJTbj0mR6ZSsl_XrHLMGmZyhWttUeyENcduPst4H7EbxHKMjPlUKDxotJ0ImKRoi-_Aag4KVVVocjrSyQmsMoXXAYPM/s1600/image002.png
    1. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZCUUpT8sPbkW_cHgA1W8zkbPG-3pkAOmcHKJblIH0thdQSLL1Z8WadbD1Zg5SdjSqpjOXVxOedA-_bk-3U5H8nUCniO0Y6LMMq1hqgKzE94FySiTAd2E_8LbTBvybwA8r15QK7PXOANw/s1600/image003.png
    2. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsBGCSFqoqu2eYHvCwsXd5XmhhPr59CmwaDt_THMJlFJ7vjlIOOr9fLdHKUboZUAFHB5qMVDLfmuvAXJ9j-A4aG9IChBU7B30UPItzZe98CRpMJ-KDoLWR_RtlyVbVQZW_dBk5nvh_K2M/s1600/image004.png
    3. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjW-I2Todlul7iCAJUjiAAewdLH63oIWF6APO-ExWWz3fS7HtQGxyd1OqqO16J2KntDwsDb1Wk_P41Atvl5_5HP1imD-ziY-RvwbyDNPA2UxrdTHJyuht4JOiRPWbM5hf8jBmoDCGCgt18/s1600/image005.png
    4. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_vGI9ttrpjpObpvXfzTwCUPRiYs30mbFLdI1bzQyR0pEbg1IbbqLuZTppk6qKMkRd3XQiGJ6ksvlIsllPvrTwhMCOHG04Jzv_UzyQGDj-IRdyroDMe4BVa2DzKhwkSwx1EUfGyO9SWHc/s1600/image006.png
    5. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJAc62YG4I2o2T7Lnav37vy0glFyEvp_0SUffgy4djZOMNqYcNXojvyfUi4fPQ4QrQRXbdSeAkacHlEOvfwT2vLMJDzicOszhXVV7nnm-P3X5QYWY2-nXOQ45_xJi_Dv0jQ0VRZii8VQc/s1600/image007.png
    6. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrWLVuvz72pG24kRxMnRXYc-Nh5n6rw1mGrVpcu5H3gxSS4mDeLhHLf-vclKF-jRvtNf54pKG2mw19g7XHNmQ26PR3eMoqJmY0ErivqeAhAhWhw8kOlftd8e87Hm4px2kWIscxHksBNUU/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:
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilEdWCAZ55Tiy6k-Q7MFErluiZeu2GiF5LmwoorWdsWbT8zMQAotN-KRzt4KjTY9T2J-g6dLWMq2R9EHTSZyuKDmL9SNbTJ5IPD82XrOaPoT0uDNYLurq7hGPqL0XlA4KdtSSOZf8kHdI/s1600/image009.png

  1. Write a program to transpose the following matrix.
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjSWnpT218-Ocg-upJyWbd43NJ8HjsZ75nHgJKsBw4kYyj4Jjbbeqp2eKBS-XS0BMTXGN9pTwDkLV9Ad2xjjv_4xmKRzDCKoDrHnbORkhJwKK0UzF7gue1dInzlegXjxHWATsM8J-DZMQ/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:
 https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8eP3ZSd1VrpDZ_PefO7bk_lvZJMl9_7SsPje_ZwQ8zm2UUa4uFQPe-gYIECkSlV1x6dXbyaDnhEH8QvlJPTJIkF_oeC76CTdakzszLKrMpRSQVv0cAd-LdO49ylVJ6UyUTfhwnUl5unE/s1600/image001.png
 https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYfXyJUY-ja4jhDidX_mINdIG4cGYERx6-v5b7TZDPBrhCXG8TRgHV83a-N1GCXclFhNDhUyw2h0qwEMWBT0wudYLz6C7iTdqcS84GPcNslPSjS1pz-_9Z7Cm_4osYN3QPbKz3N9lqLl4/s1600/image002.png
    1. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRSsjzsG2rrLU-YmYazMeRk3OGVBOdquT5TD937XaN-7-BouoDDp2j_Sfjgob1cZ7yi-Do9AhSmYEz0pTvBL8Xw5HjI-Gn9syW8f855Qhim-Qbg2B7kPLD6AvdEqOUH4vgZI_noCu5HEI/s1600/image003.png
    2. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUHnXm38U10aBGbU1vOrt_zUNg0wyGHMMPzNoArh_iRIr-aZOags-J9g5MjUhEKVwdwUnq4YWjNwYFyAMyPgpKAJ6RyQ5Od0sNRNtH2Wq5WsI-VvSd1HoR8FBBgA5j8mrqRv-nVoRjhS0/s1600/image004.png
    3. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZNV1IBk3LTETy4P53CeO61UPA9o5CxzqIW7EoszN1WHqkMlcJi7P7GPz1SztF8IzA_p08DHOEYCoQClRCn4chvtfXv1gEwLIOdRWg4jmjQbDImZvQyHvGvK_2D_3b4krw4c50-R6LoVQ/s1600/image005.png
    4. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYR6nh8WQRTlkinb4V2WS-GgsXYaNWnkKNytxWYVAIr5hLaJrZ4I-QRYZMn8eK-G0dZhaHV0q80eew1v-yH0vlZZdM6ozqPWWW-uOCOjDkUW_rou3u6JdC1gjWkUiyrnAqPzWt5EQySFc/s1600/image006.png
    5. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnnIHI8Pf6KhOGMVVmeZtyZuPtmd77DZDI_kPKHY9A8qxlx0EEM2IxXE9K7Bbvmky1xyy29OCxlTNvDoumKTndgCHC4Z-Bg0S-by3of8qVq8RK5HGZWZZrKnNAHHaXcpHid12buaisC8A/s1600/image007.png
    6. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMj4LzOaktFScIC_nT5rN0u33m5CtvgyT1VGCDLdE-GPvlEQAI_0gVKax-ovCyNpGmlNbiuFNG_3R2Nao1mloK322oemhS82PMHNVM24opFDESzZ1md-nT8tl94DzCoL5M5NZX3MILebs/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: https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZzbZ04A86DYs04oEFdK_cjFcpYfHUZSFH-XgMe47FNia7zwzFZ9241srmcNsiZR1XKaG7kfUxRB2oKhJ3fm3VEMtx9U2S9K1iMHUiZBR2wBhquFC3v_VGiOqcRfFK3deCjlrh7vGUOF8/s1600/image009.png
  4. Write a function to add, subtract, multiply, and divide two complex numbers https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWVunqvG6-IDuKRE6cbG43GJc6CaQaT8nYGij1bAd2zU38GTCtqSnZewfwewiZ9tV5Yt_1VXyQT7nmezOmowsT2n0h8tXS9rrtWRA5TJ5LhB07XrsKr3nqlinYlvWpz1YIINJQuG7YZ78/s1600/image010.png and https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqTV-HUiaXBSE7RcLp9I19OYNvZUqQ59lXVO_8PPeQlUA3vYbBQhxAjYdJ6M7SG9smwgS6hG0U50zLp-pVDGH8zVXEWCVRzdfy1C1B6CIwmlRYAm2pbBcWL972rQMNDSgpXD7zsQ8D1A4/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:
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4XygNjGy9d3YUUXhsVyQzYbvyHZS4-iTUoOJtFLW2FzNKGHFYVRKlxzMd3I8yKWPepDFPUoKctNZwTsy7lN8uRGhCcNCmmXuXM81Xpns1sApvrietfYGLAc1PLe4-vSrOcd3geDg0Ktc/s1600/image002.png
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZv4Irz7mOfflXZMplpqrDZY5gZSv0cUYHJqxcN4dc8lcVv8w2gs8nY1_5Gg6VJwVeSiDGMBdm0QEhptIc3ZccHEJJZCbcdAuyHlSsvm_rr-5rJ0f03E6vvic_xTXWkkJFKFFHsAC7tGo/s1600/image003.png
    1. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwZeL7nTmvHW-E05STdtJ0rSaGr4qoT7zV9zrL07rTZF45DjAwV3OFfqcyFJIEDC4jjuOlf8DmKzogIPDUBjLkBJhw3NQPLKwVCtkBfjfa6Sugt5bMgBiaKMiTPC4iiDJKS9aaNKXB_Wc/s1600/image004.png;
    2. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxDJcr531gX_CmfnluTKOj5wkPed0LJQe4JaihcBKP0216TYaniPDT4-zhJ3_Vffw8fKykF43jxAJ-ADrm2ujtObkCu2NmFAw8kJTT2sF1rjalRnjFGSeyCd_k4hcdL-I8Gat-rG-0AOs/s1600/image005.png;
    3. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7nVRoEtck4WaXnXRZAwTAvYOGNwH43MPIWS2EH07VCeF-kFcCx-m-cPAHdmNGdLcpwUSkL_28OtLsV-Ywt3FUdR01gntZivmTZbxNJKYXq4YgzQXBCMfh_KhFZvAnrN7bquISeoNHjSE/s1600/image006.png;
    4. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmM7rfXdW0Jzct_0SSExoX0MyNoFBFp5bk5qtRSCJO2rL2eBp16W5gaPqq9DP87J7YDYA3E9QhCktwpIj8JiQ3a5qepTx7PkhLtASDIPKwk3zf4p7-0GZwddQ9s-aZmnV4YmKSSAkgSJA/s1600/image007.png;
    5. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif2RrkC1LZRJZwaCMkwWxnD6r7EOlqLtefI8SWtuhyYr2EMDXYJ8s7KAaP7sPZ-GHT3ejTNedFodo_E0degMrd_Hwil-2NNopsI8nnMIbce_lyYCij5TjyWUA7KOnB50NjenFnIqPfUEo/s1600/image008.png;
    6. https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVUdIDpcnPtMvRUnybGI96w7j8bRtReONfK62eWdAnXVpdsCC_nE08oVyAKHk7OZ3jRNxQiTfQBsUzfAN2Wr3AYpXjHcIqUN-Z06qUa3EGgjJxKppXuS3FrRhKcysKh_ooXi09z9TIL0o/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.
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpSVUA5R77F39m2kWM9puJLyClh1nwH2l4bygttcYOPuuiepWXjXzBmPBTnbBt4btXIz_uXWwUxOu8Mhnkech6atU0JQSoaAZX8a8UGQSYPsbt3pASRA0ghHPfvQqD0D0jN8KM_ekUsr0/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.