This document provides the question format and questions for the final examination of the Computer Science and Technology (CST-104) course at the University of Computer Studies, Mandalay for the 2015-16 academic year. It consists of 8 questions testing a variety of programming concepts like loops, arrays, functions, structures, files and more. Students have 3 hours to complete the exam by answering all questions. The questions involve writing and analyzing code that performs tasks like finding minimum values, comparing strings, calculating distances, printing tables, performing linear searches and more.
This document provides the question format and questions for the final examination of the Computer Science and Technology (CST-104) course at the University of Computer Studies, Mandalay for the 2015-16 academic year. It consists of 8 questions testing a variety of programming concepts like loops, arrays, functions, structures, files and more. Students have 3 hours to complete the exam by answering all questions. The questions involve writing and analyzing code that performs tasks like finding minimum values, comparing strings, calculating distances, printing tables, performing linear searches and more.
This document provides the question format and questions for the final examination of the Computer Science and Technology (CST-104) course at the University of Computer Studies, Mandalay for the 2015-16 academic year. It consists of 8 questions testing a variety of programming concepts like loops, arrays, functions, structures, files and more. Students have 3 hours to complete the exam by answering all questions. The questions involve writing and analyzing code that performs tasks like finding minimum values, comparing strings, calculating distances, printing tables, performing linear searches and more.
This document provides the question format and questions for the final examination of the Computer Science and Technology (CST-104) course at the University of Computer Studies, Mandalay for the 2015-16 academic year. It consists of 8 questions testing a variety of programming concepts like loops, arrays, functions, structures, files and more. Students have 3 hours to complete the exam by answering all questions. The questions involve writing and analyzing code that performs tasks like finding minimum values, comparing strings, calculating distances, printing tables, performing linear searches and more.
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 2
University of Computer Studies, Mandalay
2015-16 Academic Year
Final Examination Question Format (CST-104) Time Allowed-3 hours
Answers all questions.
1. Identify and correct the errors in each of the following statements. (Note: There may be more than one error per statement.)(3mks) (a) if ( x = y ); printf( %d is equal to %d\n", x, y ); (b) While ( x <= 100 ) total += x; ++x; (c) Assume int b[ 10 ] = { 0 }, i; for ( i = 0; i <= 10; ++i ) { b[ i ] = 1;} 2. (a) Write a program that writes your name on the monitor ten times. Write this program three times, once with each looping method.(4mks) (b) Write a program that will count from 1 to 100 and print only those values between 32 and 39, one to a line. (4mks) (c)Define a character array and use "strcpy" to copy a string into it. Print the string out by using a loop with a pointer to print out one character at a time. Initialize the pointer to the first element and use the double plus sign to increment the pointer. Use a separate integer variable to count the characters to print. (4mks) 3. (a) Write a recursive function recursive Minimum that takes an integer array and the array size as arguments and returns the smallest element of the array. The function should stop processing and return when it receives an array of one element. (5mks) (b) Write a program that uses function "strcmp" to compare two strings input by the user. The program should state whether the first string is less than, equal to or greater than the second string. (5mks) (c) Write a function distance that calculates the distance between two points (x1, y1) and (x2, y2). All numbers and return values should be of type double. (5mks) 4. Write a program that uses looping to print the following table of values. Use the tab escape sequence, \t, in the printf statement to separate the columns with tabs. (10mks)
5. Modify the program of Fig. 6.18 to use a recursive linearSearch function
to perform the linear search of the array. The function should receive an integer array, the size of the array and the search key as arguments. If the search key is found, return the array subscript; otherwise, return 1. (15mks) 6. Write a program that inputs four strings that represent integers, converts the strings to integers, sums the values and prints the total of the four values. (15mks) 7. Write a program that use only uppercase letters in enumeration constant names and print the number of months of year. (15mks) 8. Write statements that accomplish each of the following. Assume that the structure struct person { char lastName[ 15 ]; char firstName[ 15 ]; char age[ 4 ]; }; has been defined and that the file is already open for writing. a) Initialize the file "nameage.dat" so that there are 100 records with lastName = "unassigned", firstname = "" and age = "0". b) Input 10 last names, first names and ages, and write them to the file. c) Update a record; if theres no information in the record, tell the user "No info". (15mks)