0% found this document useful (0 votes)
28 views176 pages

BEI I-I

The document outlines examination questions for a Computer Programming course (CT 401) at Tribhuvan University, covering various topics such as software types, programming concepts, C programming syntax, data structures, and file handling. Candidates are required to provide answers in their own words, attempt all questions, and assume suitable data where necessary. The questions include programming tasks, theoretical explanations, and the development of algorithms and flowcharts.

Uploaded by

srnsigdel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
28 views176 pages

BEI I-I

The document outlines examination questions for a Computer Programming course (CT 401) at Tribhuvan University, covering various topics such as software types, programming concepts, C programming syntax, data structures, and file handling. Candidates are required to provide answers in their own words, attempt all questions, and assume suitable data where necessary. The questions include programming tasks, theoretical explanations, and the development of algorithms and flowcharts.

Uploaded by

srnsigdel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 176
‘TRIBHUVAN UNIVERSITY [Exam INSTITUTE OF ENGINEERING Level BE Examination Control Division | programme ia are BAR 2080 Baishakh [ear /Part 1/1 ‘Subject: - Computer Programming (CT 401) Candidates are required to give their answers in their own words as far as practicable. Attempt All questions. The figures in the margin indicate Full Marks, Assume suitable data if necessary, NS a) How is an application software different from system software? Explain with examples, b) How is code in source file is converted to the executable file? Explain with key steps involved. 2. a) How is constant different than a variable? b) Write a C program to read an integer 'd! from the user. If 'd' is the radius of a circular ground in meters, then this program should calculate and display the area of the circle in square meter. 3. What are formatted input/ output functions? Explain each in detail with examples. 4, a) Differentiate between library function and user defined functions. Provide relevant examples. b) What is a function prototype? Write a C program to find sum of first 10 naturel numbers using recursion, 5. a) Write a program to read marks of 48 students in a class and display the second highest mark. b) How can we copy one string to another string without using any string handling function? 6, What do you meen by array of structure? Write a program to create a structure named "Student" having members Roll, Name, Address and Marks, Use this structure to read the information of 48 students in a class and display the information of only those stadents whose marks is between 50 and 70. 7. What are pointer arithmetic? Explain with example, Write a C program that uses pointer to read m%n matrix from user. Pass it to function that finds the transpose of the matrix. 8. a) Howis a binary file different than a text file? Write the syntax and use of fseek () and rewind() fimetions in C. b) Write a C program to read the name, year_of release, and language of 3 movies. Save the movie data of all ‘English’ language movies in a data file, 9. What is the use of FORMAT statement? Explain 1 and F format with example, Write a program in FORTRAN to read « number from user and check whether it is a prime number or not. 10, Write short notes on: a) While and do-while statement b) String manipulation in C. one ie} a 4 2] [6] [2+4] 8) (144) 1] 65] [248] [444] [242] 2] [4+4] [2x3] Examination Control Division | Programme A145 pas Marks | 3 raorovanunensry [Exam EAE INSTITUTE OF ENGINEERING Level {BE Full Marks | 80 2079 Bhadra ‘Year/Part 1/1 “Time {3 hrs, PSASA ‘Subject: - Computer Programming (CT 401) Candidates are required to give their answers in their own words as far as practicsable. Attempt All questions. : ‘The figures in the margin indicate Full Marks, Assume suitable data if necessary. 8) Differentiate between system software and application software, Provide relevant ‘examples for each of them. b) List the steps involved in solving a problem using ¢ computer. Why do we need an, algorithm before writing program code? 22] a) Define fokens in C programming language. How are variables declared as constant? Explain with example. 242) b) Write the output of the following: (6) # include int main () { char strl [50], ste2 [50] = {'N' sean ("% [A-Z]" , str] ) 5 printf ("%s\n", str) ; printf (°% 0.5 s\n", str2) 5 printf ("% 5.3 s\n", str2)5 printf ("% 0.3 s" , stt2) : return 0; } Input string: KATHmanDU low are break and continue statements used to jmp out ftom the loop? Write a program tov ywaluate the following series until the term value becomes less than ae ee 10% cose) =1- 54S - 545 [446] . a) Write a syntax of function ‘declaration, function definition and function call inc programming. Can a main funtion be called recursively in C? Justify your opinion BH] ). Explain the use of recursive function with a suitable example, 4] . a) Differentiate between array and string. Explain how to declare and use multi dimensional arrays in C. (3+2] 1) Write a C program to read a sting from the user. Pass the sting #0 1 fimetion and sort ihe alphabets in descending order. For example, ifthe user entered "exam" then the program should display "xmea' (3) a) What is the meaning of data type used in pointer declaration? Define a fumetion in ‘your program to swap two integers using pass by reference, (143) 1) Write a program to find the frequency of a number in array. Explain the relation of pointer and array using this program. 4 |. Write the purpose and syntax of fopen 0) and felose () function. WAP to create a structure book with its member name price and author. Read 10 records from user write it to a file named "book.dat". Read information from book.dat file, search author name "Gotterftied", If found copy the records to a file "gotterftied.dat" B+] What are the datatypes available in FORTRAN? Write a program in FORTRAN 10 check a number is palindrome or not. (345) ). Write short notes on: [2x4] a) Associativity in C +) Entry and exit control loop ‘TRIBHUVAN UNIVERSITY, (Bx INSTITUTE OF ENGINEERING | Level BE Full Marks | 80 32 Examination Control Division | Programme Gana BAR | pass Marks 2079 Baishakh [Wear 7Part [1/1 [Time Thrs.| Subject: - Computer Programming (CT 401) Candidates are required to give their answers in their own words as far as practicable. Attempt All questions. The figures in the margin indicate Full Marks, Assume suitable data if necessary. SA68 . Explain the program development and compilation process in detail. Draw a flowchart to find all possible roots of a quadratic equation, 2, Describe fimdamental data types in the C programming language. Whet are relational and (444) logical operators? Explain their precedance, associativity and their uses with example. [3+1+4] 3. Explain how scanf() and printf() are used. Write syntax and use of gets(), getcharQ, scanfi) and getche(); 4, Discuss the difference between while and dowhile structure with examples. Write a program to find the following sum of following series up to n terms. 1 sum= 147 5. Give the necessary condition for a function to be a recursive, Write a program to generate Fibonacci series up n terms. You need to make a recursive function to generate the each term of Fibonacei series. 6. Why do we need array in programming? Write a program to display the addition of two matrix. Your program should include one function named input to enter the values of two matrix, one function named add to perform addition of two matrix and one function named display to show the result obtained after addition of two matrix. 7. What is difference between array and structure? Create a structure TIME containting hour, minutes and seconds as its member. Write a program that uses this structure to input start time and stop time. Pass structures to a function by reference that calculates the sum and difference of start and stop time. Display the sum and difference from calling function. 8. How is an array related with pointer? Write a program to read a string containing letters, numbers and special characters, transfer only letters contained in it into another string using pointer, finally display the second string containing only alphabets. 9, Discuss “a”, “r” and “w” modes used in data file operations. Write a program that reads numbers from a file containing series of numbers and separates odd numbers from even numbers and writes them on two separate files. 10. How are one dimensional array declared in FORTRAN. Write a program in FORTRAN to read and compute the transpose of any matrix. [4+4] +5] [B+5] +7) (2+6] (246) [2+6] [2+6] Examination Control Division SASK ‘TRIBHUVAN UNIVERSITY INSTITUTE OF ENGINEERING Fall Marks 2078 Bhadra { Year/Pa Sa = = Computer Programming (CT 401) Candidates are required to give their answers in their own words as far as practicable. Aitempt All questions. The figures in the margin indicate Full Marks, Assume sititable data if necessary. @) What i a program? Explain different types of programming language in brief. (143) b) What is an algorithm? Explain how does algorithm and flowchart helps in computer programming. a) Explain Temary operator in C with an example. Define following terms. [242 (@) Preprocessor directives Gi) Keywords b) Write the output of the following C program. (4 int a,b; : = double c= 123.55667788 char str{]= "I enjoy programming”; seani{" %3d%2d", &a, &b); printf("a = %5\n b=%-7d",a,b); printf{"n%10.7s",str); printi("\n%0.3f",¢); printf("\n%-10.6P",¢); ‘input:123456 789 Write the difference between formatted UO and unformatted VO functions in C-programming. Write the syntax for following functions. (@ getche . (ii) getchar(Q) Gi) scanf() 2) What do you mean by iteration? Explain the operation of break and continue statement with a suitable example. : . b) Write aC program to check whether an entered word is a palindrome or not without using library function, (6) a). What do you mean by a function header? Explain the function parameters and its types. b) Write a C program to calculate the sum of digits of a given number unless the sum becomes a single digit using recursion. (Hint: 9785 => 29 => 11 => 2] 4] a) What is an array? Why is it necessary inc programming? (142) b) Write a program which display following pattern. [5] H HE HEL HELL HELLO HELL HEL HE H (143) [2+4] 1143} (143) 7. Is there any relation between array and pointer? If yes, show the relation between array and pointer with a suitable example, 43] 8. What is structure? Write a program to read a structure named "Faculty" having StafflD, Name, Address and ServiceYear as member. Where ServiceYear is another structure having DurationInYear as member. Now display the details of those faculties whose service duration is more than 10 and less than 30 years. [7] 9. a) Why do we need file handing? Write different modes of file opening, (43) ) What is the purpose of fseek and vite a program to write the name, roll no, and age of five students into a disk file name "STUDENT.DAT". Gy 10, Describe X format and T format in FORTRAN, Differentiate between unconditional goto and computed goto in FORTRAN. Write a program in FORTRAN to sort elements of a TD array in ascending as well as descending order. [24246] oF ‘TRIBRUVAN UNIVERSITY INSTITUTE OF ENGINEERING BE Full Mi Examination Control Division | Programme | All except BAR, Pass Marke, 32 2078 Kartik [Wear 7Pare [171 Time ah. ‘Subject: - Computer Programming (C7401) = Candidates are required to give their answers in their own words as far as practicable, Attempt All questions. ‘The figures in the margin indicate Full Marks, Assume suitable data if necessary. SAAS 2) ‘Discuss the recent software trends. Explain in details about the features that a softwaré should include. - 22] b) List out the general rules for flowcharting, What are the erors that might occur during debugging? 2." a) What are pre-processor directives? Explain compilation process with suitable block diagram. : b) Why do we need to analyse the problem before solving i? Define tokens, expression and identifiers. 3. a) Whats the control statement? Write dov the classification of control statements. [427 (4) (242) (143) [143] b) Write down the syntax of a given function, @ printf) scanf() 6 Gii)getchar) Giv)getchO 4.8) Write the output of following program: : BI int main float gravity = 9.815 printf("%4%d26%fin"); printf("%10d\n", g)s printi("%3c\n", ch); printi("%.3fn", gravity); printi("%-10.1f%6d\n", gravity, 2)s return 0; 1 b) Define and write syntax of the following: @) gets) Gi) putchar) Gii)sconf) 5, Why dd we need loop for programming? Write, a program to evaluate the following series. : Gel] [24] _ bnterms 10. ML. ‘Why do we need to declare a function? Défine formal parameter and actual parameter. Evaluate following series using recursive function. (24244) 4,1, 111, 1111, 11111, a) Define an array of string with an example. Distinguish between an array and a pointer, b) Write a C program to insert an element to a desired position to an array using function. The new element to be inserted and desired position should bé givae by user. a) Define a void pointer with an appropriate example. b) Write a C program that uses pointer to represent iwo 2-D array of size of mxn and xq respectively. Find the product of these two matrices if possible otherwise display a message "Calculation cannot be performed” using function, Discuss about neSted structure with a suitable exemple. Create a stricture called "student" ‘with data member name, address and id.pass structure to function and sort the information of student on'the basis of alphabetical order of “name” and display the result in main() function. Write a © program to create a new file named "employee.dat" which consist the information of 10 employees. Employée information includes empName, salary and post. ‘Read the file back to search the word "manag Explain different format types used in FORTRAN. Mention different data types used in FORTRAN. nterms [242] {6 2) (6 [26] (6 BY] ‘TRIBHUVAN UNIVERSITY Exam. INSTITUTE OF ENGINEERING | Level BE FulMarks | 80 | Examination Control Division | programme | AL 5° PAS pass Marks | 22 2076 Chaitra Year /Part_[ 1/1 Time [Shes ‘Subject: - Computer Programming (CT 401) Candidates are required to give their answers in their own words as far as practicable, v Y Attempt All questions. Y. The figures in the margin indicate Full Marks. ¥ Assume suitable data if necessary. ‘What are different types of computer software? What do you mean by high level and low Ievel programming languages? A long with the block diagram explain the steps involved uring compilation of e source code. [24244 2, Explain different types of error that usually appears during the programming. Define preprocessing directive and explain its type with example. Write the algorithm and draw the flowchart to find the reverse of given number. (24244) 3, Why are formatted output important in C language? Write a program to print all the roots (Even imaginary roots) of quadratic equation. 4, Explain the importance of a switch case statement. Compare switch-case with if-else adder, Write a program to find sum of numbers from I to 100 which are exactly divisible by 5 and not by 3. [24244] '5, How is function declared? Why is function prototype necessary? Write recursive function segment thet retums the sum of numbers from I to n given by the user. [2H45] 66. How can you pass one dimensional array to fimetion and what does name of an array in function call represents? Write a program to-find the largest and smallest element of an array using a single function and display the result in calling fiction. an be defined and structure variables can be declared in C. Write roll numbers, program and marks obtained in five subjects by ! and display the stadent detail and total marks obtained by +5] 345] 7. Explain how a structure ¢: a progidi that reads name, students until the user enters 'e each student. 8, What is pointer? behaves stropy() fimetion using pointer as arguement. 9. Explain different modes in opening file. Write a program fo read a string, write it into a file and display the content of file into a screen. 10, Explain different data types available in FORTRAN. Write a program in FORTRAN to cheek whether a number given by user is palindrome or not. a8 +5] Discuss its relationship with an array. Write a fimetion program that [14245] [4+4] (2+6] Examination Control Division | programme | AU Gx? PAR] pass Maris | 32 ‘TRIBHUVAN UNIVERSITY INSTITUTE OF ENGINEERING BE Full Marks | 80 2076 Ashwin ‘Year/Part {1/1 ‘Time 3 hrs. RNAS © b) What is an expression? Write a program to display the smallest number between three Subject: - Computer Programming (CT 401) Candidates are required to give their answers in their own words as far as practicable. Attempt All questions. The figures in the margin indicate Full Marks, Assume suitable data if necessary. a) Define a language processor. Explain the main types of language processor in detail. [2+3] 'b) List the basic step of problem solving using computer. Write an algorithm and draw a flowchart to find the sum of N natural number. t+) a) Define formatted and unformatted /O functions. Write the operations of following functions: [243] @ getchO i) getche() i)getchar() integers entered from user using conditional operator. [144] a) Differentiate between while and Do-while looping statement with example. (4) b) Write a program to evaluate the following series up n term. Prompt the user to input value of n and x. f(x) = 1x/21+x4/41-x 6145/8) “up tonterms. {61 a) “What are the different types of functions available in C? What do you mean by pass by reference and pass by value. (23) b) What are the similarities and difference between iteration and recursive function? Give Suitable example. (51 How do you matrices of size mxn and pxq respectively. Pass these mat the product matrix. Display the product matrix in the main Q) fimetion, [28] a) What is a structure? When do we use structure? [2+ ) Write a program using pointer to swap the value of two variable where the swapping operation is performed in separate function. {6 a) Why are fgets(), fputs0, fgete() and fputc() used? 4 b) Write a program to display the record in sorted order, sorting is performed in ascending order with respect to name using data files concept. (4 a) Compare Logical IF and Arithmetic If statement in FORTRAN with example, a. b) Write a FORTRAN program to sort 10 integers given from user and display the second largest integer, ee ‘TRIBHUVAN UNIVERSITY __ INSTITUTE OF ENGINEERING Full Marks | 30 JExamination Control Division | Programme All (Except BAE) Pass Mariss | 32 2075 Chaitra [Mear/Part [UT [time [Bhrs. | ‘Subject: - Computer Programming (C7401) 7 Candidates ae required to give their answers in their own words as fares practicable, YY Attempt ALE questions. : Y The figures in the margin indicate Full Marks, Y Assume suitable data if necessary. La) What is computer programming tnd coinputer software? Explain about types of programming languages and software. : py 1b) What do you. mean by compiler? Explein in brief the steps involved during compilation process along with block diagram. 24] 2, a) Whatis expression? What kindof information i represented by expression? 2) 1b). What is the purpose of the putchar function? Hoiv is it used within a C program? : Compare with the getchar function with example, is) 3. 2)’ Compare nested. control stucture-with elseif led strucore along with Dowehart. [4] b) Write a program to read a number from user, count the number of even digits contained in it and display whether the resulting count is prime or not. (6) 4, a) Write « prograis to generate the following output. 16} 3123454321 1234321 : 42321 24 1 b) What js fmetion? What type isthe min Q fiction? Explain sof parameter and formal parameter with example. (4142] 5, a) Write a program to read one dimensional array ofa elements, pass it to 2 function for processing so that, the program should display the largest and smallest elément of an array from the main function. ( b), How can we intilize 2D aray of charecter deta type during compilation? Iustrate ‘with suitable exaaaple. ‘a 6. a) Whot isa structure? Explain nested structure with an exemple, (2) 1) Waite a program to define a structure named Person with Name, edeess salaty as its ceanbes Enter values’ for five persons. Pass ‘the structure to a fonetién which sremases the salary by 15% each. Display the updated information in the mein Q funetion. : m 7. a) Write the output of the following. a 10 b ce address: 65510 address; 65550 address: 65580 int a=10,%b, **; printf(“%d\t%d\n", c, sey printi(Yed\t%d”, *b+5, &ct2); b) What do you mean by Generic pointer, Null pointer and File pointer? 8. a) Explain the FORTRAN structure, What arc data types in FORTRAN?. }) Writea program to print the Fibonacci series until the term is less than 500, ate (6] 4) [ae] {6 oy IBHUVAN UNIVERSITY Exam. INSTITUTE OF ENGINEERING [Level BE Ful Examination Control Division | Programme | All (Except B. Arch)} Pass Marks ™ 2075 Ashwin Year /Part_| 1/1 ‘Time ‘Subject: ~ Computer Programming (CT#01) Y Candidates are required to give their answers in their own words as far as practicable. v Attempt All questions. Y The figures in the margin indicate Full Marks, Y Assume suitable data if necessary. 1. a) What is computer program? Discuss in brief about different generation of programming languages. . [i+4] b) Why is algorithm and flow chart development important in problem solving? Write an algorithm end draw flow chart to test a number entered by user whether it is even or not: [243] 2. a) What is the identifier? What are the ways to give value to variable? Explain with ‘example? [14241] b) Explain about input and output function available in C with syntex and example of ‘each part. {2+242] 3. a) Write algorithm, draw flow chart and program to input a number check ‘it is Amstrong or not. [24242] yb). What do-you meen by-selective and repetive statement? Why do we need break end continue statement? [242] 4. a) What do you mean by "call by value and call by reference"? Explain it with suitable example. [4] b) Can we pass whole array element from the function? Write the program to pass an - > axray to function and sort them, {6] 5, a) Write’ program that finds the largest word in a given sentence, (4) b) Differentiate between the methods of passing argument to function with example. ‘What ate their advantages and disadvantages? (1 6. What is structure? Why is it necessary? Write a program to add two distances given in feet and inch format using structure. [+146] 7. a) Whats null pointer? What will be the output of following program, explain. =, [143] ie * Hinclude int mainQ { if(! NULL) printf("C programming is easy"); else printf("C programming is not easy"); return 0 ; } b) Write a program to calculate the length of string without using string handling function. i) 8. A file name employee.txt stores employee name, employee id and employee salary. Write a program to display the detail of all employees in the order of their salary. [8] 9. Write a program in FORTRAN to read 10 integers from user and short them in ascending order and display it in soreen. a aoe oy} TRIBHUVAN UNIVERSITY Exat INSTITUTE OF ENGINEERING _[Tevel E Examination Control Division | Programme | All xcept B. Arch) 2074 Chaitra Year /Part_| 171 ‘Subject: - Computer Programming (CT#01) Y Candidates are required to give their answers in their own words as far as practicable. Y. Attempt All questions. Y The figures in the margin indicate Full Marks, Y Assume suitable data if necessary. 1. a) What is a programming language? What is the difference between source code and object code. [242] b) What is debugging and testing? What are the step that need to be followed for developing the application-software, 242] 2. a) What is the difference between variable declaration and variable definition? Explain with example, 4 b) What do you mean by macro expansion and file inclusion in C? Explain with example. 4] 3. What are functions used for formatted and unformatted output? Write down its syntax. ‘Write down the output of printf() function for the following sections of statements, [44] float a= 5.7891; int b = 6789; printi("s=%4f and b=%-7d from first line’, a,b); printi('a=%-7.2f and b=%07d from second line", a,b); printf("2=%.2f and b=%2d from third line", a,b); 4, a) Explain about while loop with its syntax and flowchat. [4] ): Write a program to convert a decimal number into binary number. (aI 5. a) Cana fiction return an array to the calling function? Explain with example. 4 b) Write a program to read a mxn matrix of integers and to find the largest elements of each row. Store the largest elements of the row in a one-dimensional array of m integers before displaying them. (6) 6. a) How does a structure differ from an airay? What are the different ways to access structure member? 4] b) Create a structure named Student that has name;'roll and marks as members. Assume appropriate types and size of members. Use this structure to read and display records of 10 students, Crete two fimnctions: One is to read information of students and other to display the information. (6) 7. a) Define following term: 6] i) int*p; ii) int p(char*a) iii) int(*p(char*a)) iv) int *p(void) ¥) int*(*p[10})char a) b) Write the advantages of using pointer in C- programming. B) 8. Write a program to copy to copy content of one file source.txt. to_another destination. tet. 8] 9, a) Explain the FORTRAN structure, What are different types on FORTAN? [243] b) Write a FORTRAN program to read N number to find second largest number among them. 6) 2 © TRIBHUVANUNIVERSITY INSTITUTE OF ENGINEERING | Level BE Fall Marks | 80 Examination Control Division | Programme | alt Except B ach) | Pass Marks | 32 2074 Ashwin Year Part [T/T ‘Time Shs | Subject; - Computer Pro; gramming (CT401) Y Candidates are required to give their answers in their own words as far as practicable. Y Attempt All questions. Y The figures in the margin indicate Full Marks, ¥ Assume suitable data if necessary. 1. What ate computer programs and computer programming? Explain the steps that are required to’build a computer program for solving a certain problem. 2. Explain with an exemple the role that precedence and associativity play in the execution of an expression. Rewrite the following program by correcting any errors, if present anid also write down the output of the corrected code. Define MAX‘? int main {) { int casefMAX}={2,3,5,4,10),;sum=0; for{i-0,iMAX,it=1) ft : rintf("Case sod = %3.2d\n'j,ceseli); sum +=* caseti; . Xk © average = sum/Miax; printf("06.2F" average); return 3; , 3. a) Compare if-else-if ladder and switch construct with example and flowchart. b) Write program in C to generate following pattem using unformatted input/output functions only. N cee PPPPP aaaaaaa LLLLLELLE 4, Write a program in C to find out whether the n'® term of the Fibonacei series is a prime number or not. Read the value of n from the user and display the result in the main function. Use separate user-defined functions to generate the n® Fibonacci term and to check whether a number is prime or not [246 [+4] [5] 6) [8]

You might also like