F:/Academic/27 Refer/WI/ACAD/10 SHRI RAMSWAROOP MEMORIAL COLLEGE OF ENGG. & MANAGEMENT PAPER ID: 1602 (Following Paper ID and Roll No. to be filled by the student in the Answer Book) Roll No. B.Tech. SEM II (CE, EN, EC, EI & EE) MID SEMESTER EXAMINATION, 2011-12 COMPUTER CONCEPTS AND PROGRAMMING IN C (ECS-201) Time: 3 Hours Max. Marks: 100 Note: 1. The question paper contains three sections. 2. Section-A is compulsory, Section B and C contains internal choice. 3. There can be more than one solution/logic to a particular program. Solution to a program in the solution set refers to one particular solution. There can be many other valid approaches. 4. Assume a 16 bit turbo C/C++ compiler. SECTION-A Question 1 Attempt all parts of the following: [2 X 10 = 20] (a) What do you mean by Operating System? Explain the functions of it. (b) Draw the flowchart to find the reverse of any number. (c) Evaluate the following arithmetic expression in C and find the value of s: int s=5/2*5.2/6-7%4%1*7.0 (d) Differentiate between implicit and explicit type casting with example. (e) What will be the output of the following code? main() { int a,b,c; a=5;b=6; c=--a>b && --b>5; printf("%d%d%d",a,b,c); getch(); } Page-1
(f) What will be the output of the following code? main() { int a,b; a=8,b=12; printf("%d%d%d",a=b,a>b,b=5); getch(); } (g) Define structure. How it is dissimilar from union? (h) What do you mean by pointer? Explain its importance. (i) What will be the output of the following code? #define midsem(x) x*x*x main() { int a,b;clrscr(); a=8,b=12; b=512/midsem(a); printf("%d %d",a,b); getch(); } (j) Discuss any four string handling functions. SECTION-B Question 2 Attempt any three parts of the following: [10X3=30] (a) i) Explain the following : [2. 5 *2=5] i. GUI and CUI interface. ii. Structured programming ii) Write a program in C to read two matrices of the order r1xc1 and r2xc2 respectively and checks whether they can be multiplied or not. If yes, multiply them and display the resultant matrix. [ 1+4=5 ] Page-2
(b) i) What are various data types in C language? Explain the range, memory size of each with its format specifier. [ 1+4=5 ] ii) Write a program in C that read a floating point number and display the difference of last digit of integral part and first digit of fractional part. (For example if the number is 148.76 then program should display 8-7=1). [ 5 ] (c) i) Write a program in C to read a number having more than 5 digits and print whether the given number is divisible by 11 or not, by using algorithm which states that a number is divisible by 11 if and only if the difference of the sums of digits at odd position and even positions is either zero or divisible by 11. [ 5 ] ii) What is linked list? What are the advantages of linked list over array? Discuss various types of linked list. [1+2+3=5 ] (d) i) Define recursion. Write a recursive function in C to count the number of digits of an inputted number. [ 1+4=5 ] ii) Write a program in C to find whether the inputted string is palindrome or not, without using string library functions. [ 5 ] (e) i) Write a program in C to copy the contents of one file to another file. [ 5 ] ii) Write an algorithm to sort an array using bubble sort approach. [ 5 ] SECTION-C Attempt All Questions [10X5=50] Question 3 Attempt any one part of the following: [10] (a) Differentiate between following: [5 * 2=10] Page-3
i. Compiler and interpreter ii. High level language and low level language (b) Convert the following showing all steps: [2 * 5=10] i. (1011) 10 = ( ) 8 ii. (13911) 10 = ( ) 16 iii. (53) 7 = ( ) 5 iv. (ab) 16 + (cd) 16 = ( ) 16 v. (-7) 10 = ( ) 2 Question 4 Attempt any one part of the following: [10] (a) (i) Differentiate between precedence and associativity of operators. [4] (ii)determine the value of each of following logical expression if a=5, b=10 and c = -6: [2+2+2=6] i. a = = c b > a ii. b > 15 && c < 0 a >0 iii. ( a/2.0 = = 0.0 && b/2.0!= 0.0) c < 0.0 (b) An ATM machine which has 1000, 500, 100 and 50 rupees notes. As the ATM machine is rural area it always try to deliver at least one 100 rupee note and one 50 rupee note if possible. Write a program in C which prompts for withdrawal amount and delivers minimum number of notes if amount is less than 40000 otherwise display the message Maximum limit is reached. [10] Question 5 Attempt any one part of the following: [10] (a) Declare a two dimension character array and initialize it with the values Zero, One, Two, Three, Four, Five. upto Nine. Write a program that read a number and display it in words. For example if number is 3450 then with help of the array it should display Three Four Five Zero. [10] (b) Write a program to read a number and check whether the inputted number is equivalent to sum of the power of its total number of digits. (Let k be the number of digits in a given number n, and d 1,d 2,d 3,d 4..d k. be the digits of n then program should check whether n=d 1 k+d 2 k+d 3 k+d 4 k+- - - d k k or not. For example if the number is 1 or 153, the sum is calculated as shown below: Page-4
1=1 1, 153=1 3 +5 3 +3 3 [10] Question 6 Attempt any one part of the following: [10] (a) Create a structure to specify data of customers in a bank. The data to be stored is: Account number, Name, Balance in account. Assume that there are maximum of 200 customers in the bank. i. Write a function to print the Account number and name of each customer with balance below Rs. 100. ii. If a customer request for withdrawal or deposit, it is given in the form: Acct. no, amount, code (1 for deposit, 0 for withdrawal). Write a program that checks the amount at the time of withdrawal and if it is less than 100 give a message, The balance is insufficient for the specified withdrawal. [2+3+5=10] (b) What is Dynamic Memory Allocation? How it is different from static memory allocation? Use any Dynamic Memory Allocation functions to develop variable length array and find sum of all the elements. [2+2+6=10] Question 7 Attempt any one part of the following: [10] (a) Write a program in C that read a string and count the number of vowels in it. If n is the number of vowels, calculate c using following formula c = n n 2 + 2 1 If n is even If n is odd Also display the c th character of string as following example: If string is education, here number of vowels are 5(odd) then c=(5+1)/2=3 then c th ( 3 rd ) character of sample string is u. The expected output is u uu uuu uuuu [4+1+5=10] Page-5
(b) Explain the following in brief: [2.5 * 4=10] i. Conditional Compilation ii. Sequential Search iii. C Preprocessor iv. Command line arguments HARD WORK IS KEY OF SUCCESS Page-6