0% found this document useful (0 votes)
79 views14 pages

C-past-questions

The document consists of examination questions for Computer Programming courses at Tribhuvan University, covering various topics in C and FORTRAN programming languages. It includes questions on programming concepts, data structures, control structures, file handling, and recursion, among others. Candidates are instructed to provide answers in their own words and assume suitable data where necessary.

Uploaded by

Pawan Bhugai
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)
79 views14 pages

C-past-questions

The document consists of examination questions for Computer Programming courses at Tribhuvan University, covering various topics in C and FORTRAN programming languages. It includes questions on programming concepts, data structures, control structures, file handling, and recursion, among others. Candidates are instructed to provide answers in their own words and assume suitable data where necessary.

Uploaded by

Pawan Bhugai
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/ 14
TRBHUVAN UNIVERSITY INSTITUTE OF ENGINEERING Examination Control Division 2081 Baishakh ——. —___ _ Subject: - Computer Programming (C7 19) Candidates are required to give their answers in their own words as fa i < Mitemp All questions as far as practicable. Rgwes in the margin indicate Full Marks damume sxitabie data if necessary. Demiae Programming language. Draw a flowchart to find the factorial of a positive omeger [1+3] 2 Whatare Preprocessor directives in C? What are the basic rules of identifier naming in C? [2+2] Define the shorthand operator in C. Explain the correct order of precedence of arithmetic operators in C. {143} + Explain different components of the control string in C. Bj ®) DiSireatiate between break and continue in loop. Write a program in C to display the B* temm of the Fibonacci series. (Hint: nes idle seaTot Gate ae mambers, where the first two terms are always 0 and 1B [2+4] ©) Display the following pattem using the concept of nested loop in C B} 3s 343 5432 54321 ©) What is an array index? Write a program to read values of 1D amay and check whether the largest element is even or odd. (+3 5) Write a program to concatenate two strings without using string handling function. a ©) Write @ program to read S numbers in an array and then use the concept of pointer to display the array elements. B) * #) Write @ program in C to reverse a number entered by user using the concept of function with return type and arguments. 4] Define register storage class in C. Find the HCF of 2 numbers using Recursion in C (Hint: HCF is « number that divides both the numbers exactly} Usa] Write a C program to create a structure named BOOK with its members Name and Price. Input 10 records of book. Create a function named maxPrice() which displays the record with maximum price. The entire structure to the function is passed from main. 6] 9 What is the purpose of °w" and ‘a’ mode in text file? Write a program in C that creates a structure named VEHICLE with its member year, brandName. Read ‘n’ number of vehicle information and write it to a file named Vehicle dat. (+4) 19 What ate the short comings of procedure-oriented programming language? Explain the 5 key features of Object-Oriented Programming Language (13) . my Ex TRIBHUVAN UNIVE! INSTITUTE OF ENGINEERING Level B Fall Marks 80 Examination Control Division | programme ans Ce Pass Marks 32 2081 Baishakh Year /P: uit Ti “3h “Subject: - Computer Programming (CT 401) ¥- 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. Discuss about compilation process in C. Draw a flowchart to calculate the sum of digits contained in a number entered by the user. 2, Explain about declaring variables and constants in C and FORTRAN. 3. Write a syntax to use else-if ladder and do-while in C. Write a program in C to generate the given pattern using concept of loop control 1 2 36 5 48 12 16 4. Write a program using recursive function to compute x” and explain how this program works. 5. Explain about “toupper ()" and “tolower ()" function used in C. Write a C program to read the name of N countries and display the name of these countries in alphabetical order. 6. Discuss about the initialization and declaration of pointers with examples, Write down about pointer arithmetic, 7. Write a program in C (16-bit compiler) to create a structure name “karmachari” with members: ID_Number (6-digit), Name and salary of 40,000 employees. Create « funetion name “search ()”. Where, the user inputs a value of salary within the records, if found display the records 8. Write a program in C to write all the prime numbers within the range nl to n2 into a first file, copy the content of first file into second file and display the content of second file Your first file name should be “Source” and second file name should be “Destinaion” 9. Write a program in FORTRAN to display Fibonacci sequence upto n" term, Read n from the user. {Fibonacci sequence: 0, 1,1, 2,3, 5,8, 13... 10. Compare switch statement with user defined function. Write w program in C to find the transpose of NXN matrix. . es] ia] 2+6) [2-6) Ls} DF INSTITUTE OF ENGINEERING | Tevel AIL exeept BAS" pagy mathe | 32 Examination Control Division programme! Ay si Stes Lvenr/Part L101 2080 hate | ene wubject. Computer Programming (C740) 26 practicable {Candidates ive required to give their answers in theit ow words/as f4¥'3s Attemps Al questions he figures in he margin indicate Full May Assume suitable data if necessary. raw a flowchart to 1 Write about generation of Computer Programming with angle, Dean 5 ow Csleulate the area of tiangle, where the values of three sides are rea NS BE=F ands =(a tb + 4e)/2 [404] associativiy 8), What are the fundamental datatypes in C? Explain about precedence and y of an operator with examples, Him: Area i sts b {rte down the output of following sepment of aC program Void main ) inc n=90; Brint(“%104 a"); Print (96-24 nny Print "A prin%-10d ny sete Re reat art iar wih svc satemen. We « program to check whethe the satered numbers palindrome or nox ss) (Hint: Paindrome number for example is 12521 ‘ result in 1D array 26) » ke) Sy RQUam (16it compile) to read nae, somber (erst be a six cig umber) and marks obtained in five subjects of N students using structure. Where, N is tie, nPal provided by the use. Display the deus Stiles as well us the wtal manne 2rd percentape obtained by each seccsn ts) © 2) Compare call by value and call by rezence with example (4) 5) Writ the cut ofthe program show hese i # include int main () ( Variable Vatue ess int 10, *purt, **pir2: _ . pir aa > pu2 = & pny 7 Dri (a 0, aay, vn Print (Yed\ %al\ 9% pte. pet); —— = Pei C78 RLSM, gy 2 ea oo. punt (a En 7, Write the concept of string handling functions. Write @ program in C to concatenate two strings without using string handling functions. Write a program in C to create a structure book using its members: Name, Price and Author. Read one record from the user “book.txt”, Read back the information from “book.txt” and display it. 9. Compare about the control structure available in Cand FORTRAN, 10. Write a program in FORTRAN to sort an array of 100 numbers in ascending order. ey snuBHUVAN UMIVERSETY _ INSTITUTE OF ENGINEERING | Level Fall Mario 60 Examination Control Division (Programme away PAR page Maris 32 12080 Balshakh {Year Part 1/1 Time “3s Subject: - Computer Programming (c'T' 401) % Candidates are required to give their answers in their own words af farms} Y tempt All questions D The figures in the margin indicate Full Marks 2% NCE Y assime suitable data if necessary LIBRARY }, a) How is an application software different from system software? Explain with examples. 14) How is code in source file is converted to the executable file? Explain with key steps involved. 4] 2. a) Howis constant different than a variable? (2) b) Write @ 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. 6) detail with examples. [2-4] ‘What are formatted input’ output functions? Explain eae! 4. a) Differentiate between library function and user defined functions. Provide relevant ‘examples. BI ‘b) What is a function prototype? Write a C program to find sum of first 10 natural 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 mean by atray’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 students whose marks is between 50 and 70. 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 .) Write the syntax and use of fseek () and 6) (2-8) [4-4] 4. a) How is a binary file different than a text file’ rewind() functions in C. b) Write a C program to read the name, year_of_rclease, the movie data of all ‘English’ language movies in a data 9. What is the use of FORMAT statement? Explain | and F format with example program in FORTRAN to reat) a mumber from user and check whether is 4 Prime | umber or not, 3) and language of } movies. Save Write a 40 Write short notes on’ a) While and do-while statement 5) String manipulation in C. FP SKAS “TRIBHUVAN UNIVERSITY Exam. INSTITUTE OF ENGINEERING [Level ‘omputer Prog Candidates are required to give their answers in their own words asifat us practiesable. Attempt All questions. ‘The figures in the margin indicate Full Marks, LIRE Assume suitable data if necessary. eee 2) Differentiate between system software and application software. Provide relevant examples for each of them, | b) Liat the steps involved in solving a problem using a computer. Why do we need an algorithm before writing program code? a) Define tokens in C programming language. H Explain with example. b). Write the output of the following: low are variables declared as constant? #include int main () { char stri [50], str2 [50] = { 'N,1 seanf ("% [A-Z]" str] ): printf ("2%s\n" , str1) printf ("% 0.5 s\n", str2) print (°% 5.3 s\n", str2): printf (°% -0.3 s" str2) 5 return 0; } Input string: KATHmanDU cout from the loop? Write a program How are break and continue statements used to jump becomes less than to evaluate the following series until the term value 10% costa) = 1-4 StF «) Write a syntax of function declaration, function definition and function eal ip c programming. Can a main function be called recursively in C? Justify your opinion. 'b) Explain the use of recursive function with a suitable example. ‘) Differentiate between array and string. Explain how to declare and use multi dimensional arrays in C. b) Write a C program to read a string the alphabets in descending order. For example, program should display "xmea'" a) What is the meaning of data type used in pointer declaration? Define a function in your program to swap two integers using pass by reference. 1) Write @ program to find the frequency of a number in array. Explain the relation of pointer and array using this program. Write the purpose and syntax of fopen () and felose () function. W: took with its member name price and author. Read 10 records fo named "book.dat” Read information from book.dat file, searc! "Gotterfried”, If found copy the records 10a file "gotterfried dat” What are the datatypes available in FORTRAN? Write a progzam in FORT RAN to check a number is palindrome or not. Write short notes on: a) Associativity in C ) Entry and exit control loop Fy from the user. Pass the string to a function and sort if the user entered "exam" then the /AP to create a structure wm user write it to a file ch author name 4) {242} (2 (6) [446] Br 4 64] (51 (13) 4) {3-7} [345] [2x] y !IUVAN UNIVERSIFY [Exam INSTITUTE OP ENGINEERING ii . amination Control Division | Prorram 2078 Bhadi a Subject: - 1 as practicable. Condisates are required to give their answers in their own words as far as pr fc1empy All questions, The figuces inthe margin indicate Full Marks, Assume suitable data if necessary. in brie. (431 of programming language ©) What isa program? Explain different ype : ywchart helps in computer >) What is an algorithm? Explain how does algorithm and flowchart helps (3) rograraming ; se 2) Explain Ternary operator in C with an example. Define following terms. t (Preprocessor directives (i) Keywords . ‘Write the output ofthe following C program. int a,b; double c= 123,55667788 char stf} = "I enjoy programming"; seanfi" %34%2d", da, &b); printf("a = %S\n b=%-7d",a,b); printi("\n%10.7s",ste), printt("%0.30%¢); rintf("Wn%-10.6P"0); inputs123456 789 Cente be difference between formatted VO snd unformatted 0 functions in (C-programming, Write the syntax for following functions, @ etched ii) getchar) i) sean) 8) What do you mean by iteration? statement with a suitable example, © Wit a program to check whether an entered word is a palindrome or not without using library function, ©) Nhat do you mean by a function header? Explain the function Parameters and its ‘ypes. {24} [43] {6 .n (143) » eas a C Program to calculate the sum of digis ofa given number unk becomes single digit using recursion, (Hint 9785 <> 6 = 8) What san array? Why isi necessary in pro ®) Mhite «program which display folowing pate H ME. HEL HELL, HELLO HELL HEI, HW 4] ramming? mn, 38 ater? If yes, show the relation between aray >. Is there any relation between array and poi and pointer with 2 suitable example. a 7 ture? Write a rogram to read a structure name faculty” having Stafftp. Le ea ad Hea Peemg ener Where ServiceYeat i8 another stuctur pa Durationtn Year as member. Now display the details of those faculties whose eevice duration is more than 10 and Jess than 30 years. by 9. a) Why do we need file handing? Write different modes of file opening. 7 b) What is the purpose of feeek and write a program to write the name, roll no, and age offive students into a disk file name "STUDENT.DAT". A 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 {24246} ID array in ascending as well as descending order. he sinltVANUNIVERSITY sriTuTF OF ENGINEERING pint ision candidates are required fo iV their answers in their own words as far as practicable. ae al guest. sc ip marin te El Mars Te a abe data if neces 2) Discuss the recent software ‘trends, Explain in details about the features that a software should include. b) Listout the general rules for flowchartng ‘What are the errors that might occur during. debugging? 2) What ae pre-processor directives? Explain com diagram. +) Why do.we need to analyse the problem before solving i? Define tokens, expression and identifiers. 2) Whatisthe conrl stetement? Write down the classification of control statements. {1*2] {4x1} (242) {242} ipilation process with suitable block (3) 143] +) Write down the syntax of a given function. (© print) — Gi) sean) Nerve (igetchard) 2k Fe) i INCE 2) Wiite the output of following program: BA int main char ch=G' int p10; float gravity = 9.81; print("%6%€24% Ain") print(*%10d\2", 2); print{("%3c\n", ch); Prin'%. fin", gravity); rint{(%-10.14%d\n", gravity, 8): retum 0; 7 Bat! ) Define and waite syntax of the following (i gets) Why do we nced oop for programing? Writs a program to evaluate the OWING seties, pet cos(x)= + terms ° Why do we need to declare a function? Define formal parameter and aciual parameter Evaluate following series using recursive fun 120 TL, 111, oem terms 2) Define an array of string with an example. Distinguish between an array andl a pointer. rit to desired position to an array using desired position should be givne by b) Write a C program to insert an el function. The new element to be inserted user. a) Define a void pointer with an appropriate exampie. bb) Write a C program that uses pointer to represent two 2-D array of size of mn and pq respectively. Find the product of these two matrices if possible otherwise display message "Calculation cannot be performed” using function. 9, Discuss about nested structure with a suitable example. Create a structure 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() fonction. 10. Wiite a C program to create a new file vamed "employee.dat" which consist the information of 10 employees. Employee information includes empName, selary and post. ‘Read the file back to search the word "manager", 11. Explain different format types used in FORTRAN. Mention different data types used in FORTRAN. [2424] 293) +6) (6) B+2) UVaN naveRstrY (Exam INSTITUTE OF ENGINEERING | Level BE ; Sie = Seeept BAG Examination Control Division | programme | \!) 2076 Chaitra i Full Marks ‘Subject: - Computer Programming (CT 40) Candidates are required to give their answers in their own words py for as practigpble. Attempt All questions The figures in the margin indicate Full Marks. Assume suitable data if necessary. § 654K What are different types of computer software? What do you mean by high level and low {evel programming languages? A long with the block diagram explain the steps Seen uring compilation of a source code. Tacaa 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, {2+2+4} 3. Why are formatted output important in C language? Write a program to print all the roots ' (Even imaginary roots) of quadratic equation, : (3+5] 4. Explain the importance of a switch case statement, Compare switch-case with ifelse {adder. Write a program to find sum of numbers from 1 10 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 that retums the sum of numbers from 1 to n given by the user. [2+1+5] 6 How can you pass one dimensional array to function 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 function, [3+5] 7. Explain how a structure can be defined and structure variables can be declared in C. Write 4 props that reads name, roll numbers, program and marks obtained in five subjeons by Students until the user enters and display the student detail and total marks obteined by each student. 35) 8. What is pointer? Discuss its relationship with an array, Write a function program that behaves strepy() function using pointer as arguement (12+5) 9 Explain diferent modes in opening file, Write a program to read a string, write it into a file and display the content of a file into a screen, leg 10. Explain different data types available in FORTRAN. Write a program i FORTRAN to check whether a number given by user is palindrome or not Res wee 2 ‘TRIBHUVAN UNIVERSITY. INSTITUTE OF ENGINEERING Examination Control Division | Program 2076 Ashwin ear 7 ¥ Attempt All questions. ¥ The figures in the margin indicate Full Marks, v Assume suitable data if necessary. 4 Be |. 2) Define a language processor. Explain the main types of language Processor in de ») List the basic step of problem solving using computer. Write ; : an algorit flowchart to find the sum of N natural number orth and raw a) Define formatted and unformatted functions: (i) getchQ) (ii) getche() (iii)getchar() b) What is an expression? Write a program to display the smallest number between tree integers entered from user using conditional operator. ( 3. a) Differentiate between while and Do-while looping statement with example. 4b) Write a program to evaluate the following series up n term. Prompt the user tiaput value of n and x. f(x) = 1-x7/214x'/41-x/61+x4/8!. -up to n terms. [ 4. 8) What ate the different types of functions available in C? What do you mean by is by reference and pass by value. pe b) What are the similarities and difference between iteration and recursive function? Give suitable example. initialize a 2D array? Explain with an example. Write a program to input (wo Soon eased pug repentaly Pass theo aafocr 1 the Reoen a coeaoe the product matrix, Display the product matrix in the main () function, 6. a) What isa structure? When do we use structure? . i 1 wap value of two variable where the swapping program using pointer to swap the va © Ya aera eae aio “ s(), fgetc() and fputc() used? ( 1s(), fputsO, figeteO ans aca 10 display the record in sorted order, sorting is performed ia R th Y/O functions. Write the Operations of following wv a 218 7. a) i rogram sim ita files conce [0 BW Proter with expect Wo namie using dat les concept wl Logical IF and Arithmetic If statement in FORTRAN with example, } 6. 8) Compare Lo FORTRAN program wo sort 10 integers given from user and display the Write @ » second largest integer qyvan vnvenstt¥ nut OF ENGINEERING [Lave IST Control Division | Prog nation Con! spain’ ors Chitra “Subject: - Computer Programming (T40)) in jive their answers in th fa gates are required 10 give in their own word 4 catgut. rort te ft apace, seer eas inthe margin indicate Full Marks f Tf ibe dteifnecessar : «a What is computer programming and computer sofware ing tenguages and software Explain about types of programma 4 ' (2+2] + do yoo mean by compiler? Explain in brief the step i | lion process along with Dock diagram, Steps volved. during 1 Whaisexpesia? What kindof nforston steps by expen? Ha 2 . a el 1) What eth pape of the putchtr function? Hoi i it used wit » Compare wit the getchar function with exemple, eed +») Compare sexed contol structure wih elseif eddersrucure slong wih fovea, 7 tt b) Wie a program to read a number from user, count the number of even dy CS sein tend Gsplay whether the resting count isprimeornot eg 4. 9) Wie program to generate the following output ‘ 123454321 : 2 21 i 1 343 232 det 1 1) What is a function? What type is the main () function? Explain actual parameter and formal parometer with example. [I+1+2] 5. a): Write a program to read one dimensional array of elements, pass it to a function for processing so that, the program should display the largest and smallest element of an array from the main function. s ) How can we initialize 2D array of character data type during compilation? Iustate With suitable example, e ®) What is structure? Explain nested structure with an example Qe ¥) Write a program to define a strcture named Person with Name, adress salary 21 ‘member. Enter values for five persons. Pas the structure 10 + function which inseases the salary by 15% each, Display the updated information ia the main Q function 0 7, a) Write the output of the following. tt address: 65510 address; 65550 address: 65580 int a=10.*b, **c; beda c=&b; printh(“%d\t%d\n"b,*c);, printf(%odit%din", ¢, **c); printh{"%dW%d", *b#5, &c+2); b) What do you mean by Generic pointer, Null pointer and File pointer? It 8, a) Explain the FORTRAN structure, What are data types in FORTRAN? (2 b) Write a program to print the Fibonacci series until the term is less than 500. { ae

You might also like