C PROGRAMMING and DATA-STRUCTURES, exams, Study notes of C programming

B.Tech Semester Supplimentary Examinations, June 2009 C PROGRAMMING AND DATA STRUCTURES getchar and scanf functions, pointer, selection sort, compute Fibonacci numbers, i. Increment

Typology: Study notes

2010/2011

Uploaded on 08/25/2011

kiriakov80
kiriakov80 ๐Ÿ‡ฎ๐Ÿ‡ณ

4.4

(18)

31 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Code No: R05010106 Set No. 1
I B.Tech Semester Supplimentary Examinations, June 2009
Cโ€™ PROGRAMMING AND DATA STRUCTURES
( Common to Civil Engineering, Electrical & Electronic Engineering,
Electronics & Communication Engineering, Computer Science &
Engineering, Electronics & Instrumentation Engineering, Bio-Medical
Engineering, Information Technology, Electronics & Control Engineering,
Computer Science & Systems Engineering, Electronics & Telematics,
Electronics & Computer Engineering, Aeronautical Engineering and
Instrumentation & Control Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
โ‹†โ‹†โ‹†โ‹†โ‹†
1. Write about space requirements for variables of different data types. [16]
2. (a) Distinguish between getchar and scanf functions for reading strings.
(b) Write a program to count the number of words, lines and characters in a text.
[8+8]
3. (a) Explain the process of declaring and initializing pointers. Give an example.
(b) Write a C program that uses a pointer as a function argument. [8+8]
4. (a) How does a structure differ from an array?
(b) Write a C program using structure to read and print the studentโ€™s records of
a class with the following members. [6+10]
Field Name Data Type
name string
reg no integer
major string
result string
5. Write a C program to replace every 5th character of the data file, using fseek( )
command. [16]
6. Write a program to convert a given infix expression to prefix expression using stacks.
[16]
7. Write a C program to insert and delete the elements from a circular doubly linked
list. [16]
8. Explain the algorithm for selection sort and give a suitable example. [16]
โ‹†โ‹†โ‹†โ‹†โ‹†
1 of 1
pf3
pf4
pf5

Partial preview of the text

Download C PROGRAMMING and DATA-STRUCTURES, exams and more Study notes C programming in PDF only on Docsity!

I B.Tech Semester Supplimentary Examinations, June 2009 Cโ€™ PROGRAMMING AND DATA STRUCTURES ( Common to Civil Engineering, Electrical & Electronic Engineering, Electronics & Communication Engineering, Computer Science & Engineering, Electronics & Instrumentation Engineering, Bio-Medical Engineering, Information Technology, Electronics & Control Engineering, Computer Science & Systems Engineering, Electronics & Telematics, Electronics & Computer Engineering, Aeronautical Engineering and Instrumentation & Control Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE Questions All Questions carry equal marks โ‹† โ‹† โ‹† โ‹† โ‹†

  1. Write about space requirements for variables of different data types. [16]
  2. (a) Distinguish between getchar and scanf functions for reading strings. (b) Write a program to count the number of words, lines and characters in a text. [8+8]
  3. (a) Explain the process of declaring and initializing pointers. Give an example. (b) Write a C program that uses a pointer as a function argument. [8+8]
  4. (a) How does a structure differ from an array? (b) Write a C program using structure to read and print the studentโ€™s records of a class with the following members. [6+10] Field Name Data Type name string reg no integer major string result string
  5. Write a C program to replace every 5th^ character of the data file, using fseek( ) command. [16]
  6. Write a program to convert a given infix expression to prefix expression using stacks. [16]
  7. Write a C program to insert and delete the elements from a circular doubly linked list. [16]
  8. Explain the algorithm for selection sort and give a suitable example. [16]

I B.Tech Semester Supplimentary Examinations, June 2009 Cโ€™ PROGRAMMING AND DATA STRUCTURES ( Common to Civil Engineering, Electrical & Electronic Engineering, Electronics & Communication Engineering, Computer Science & Engineering, Electronics & Instrumentation Engineering, Bio-Medical Engineering, Information Technology, Electronics & Control Engineering, Computer Science & Systems Engineering, Electronics & Telematics, Electronics & Computer Engineering, Aeronautical Engineering and Instrumentation & Control Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE Questions All Questions carry equal marks โ‹† โ‹† โ‹† โ‹† โ‹†

  1. (a) Explain the following & illustrate it with an example each. i. Increment & Decrement operator. ii. Conditional operator. iii. Bitwise operator. iv. Assignment operator. (b) State the rules that applied while evaluating expression in automatic type conversion. [12+4]
  2. (a) Write a program to compute Fibonacci numbers which are defined by the recurrence relation. f ibn+1 = f ibn + f ibnโˆ’ 1 for n > 0 (b) What is the scope of variables of type: auto, register and static. [10+6]
  3. (a) What is a pointer? List out the reasons for using pointers. (b) Write a C Program to illustrate the use of indirection operator โ€œ * โ€ to access the value pointed by a pointer. [8+8]
  4. (a) What are Bit fields. What are its advantages. What is its syntax. (b) Write a C program to store the information of vehicles. Use bit fields to store the status information. Assume the vehicle object consists of type, fuel and model member fields. Assume appropriate number of bits for each field.[8+8]
  5. (a) What are the file I/O functions in C. Give a brief note about the task per- formed by each function. (b) Write a program to read an input file and count the number of characters in the input file. 16]
  6. Show how to implement a queue of integers in C by using an array int q[QUEUESIZE] , where q[0] is used to indicate the front of the queue , q[1] is used to indicate its rear and where q[2] through q[QUEUESIZE -1] contain elements on the queue. Show how to initialize such an array to represent the empty queue and write routines remove, insert and empty for such an implementation. [16]

I B.Tech Semester Supplimentary Examinations, June 2009 Cโ€™ PROGRAMMING AND DATA STRUCTURES ( Common to Civil Engineering, Electrical & Electronic Engineering, Electronics & Communication Engineering, Computer Science & Engineering, Electronics & Instrumentation Engineering, Bio-Medical Engineering, Information Technology, Electronics & Control Engineering, Computer Science & Systems Engineering, Electronics & Telematics, Electronics & Computer Engineering, Aeronautical Engineering and Instrumentation & Control Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE Questions All Questions carry equal marks โ‹† โ‹† โ‹† โ‹† โ‹†

  1. (a) Describe in detail the execution of while statement with example. (b) Given a number, write a program using while loop to reverse the digits of the number. For e.g. 12345 should be written as 54321. (c) Write a program to compute the sum of the digits of a given integer number. [4+6+6]
  2. (a) Write a program to compute Fibonacci numbers which are defined by the recurrence relation. f ibn+1 = f ibn + f ibnโˆ’ 1 for n > 0 (b) What is the scope of variables of type: auto, register and static. [10+6]
  3. (a) What is a pointer? List out the reasons for using pointers. (b) Write a C Program to illustrate the use of indirection operator โ€œ * โ€ to access the value pointed by a pointer. [8+8]
  4. Write a C program to compute the monthly pay of 100 employees using each em- ployeeโ€™s name, basic-pay. The DA is computed as 52% of the basic pay. Gross-salary (Basic pay+DA). Print the employees name and gross salary. [16]
  5. Write a program to combine contents of two files. Add line numbers at the begin- ning of each line, in the output file. [16]
  6. Write a C program to convert a given infix expression into postfix expression using pointers. [16]
  7. Explain non-recursive and recursive algorithm for Inoder traversal of a binary tree. [16]
  8. Write in detail about the following:

(a) Exchange sort (b) Binary search [8+8]

I B.Tech Semester Supplimentary Examinations, June 2009 Cโ€™ PROGRAMMING AND DATA STRUCTURES ( Common to Civil Engineering, Electrical & Electronic Engineering, Electronics & Communication Engineering, Computer Science & Engineering, Electronics & Instrumentation Engineering, Bio-Medical Engineering, Information Technology, Electronics & Control Engineering, Computer Science & Systems Engineering, Electronics & Telematics, Electronics & Computer Engineering, Aeronautical Engineering and Instrumentation & Control Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE Questions All Questions carry equal marks โ‹† โ‹† โ‹† โ‹† โ‹†

  1. (a) Draw a Flowchart for the following The average score for 3 tests has to be greater than 80 for a candidate to qualify for the interview. Representing the conditional logic for generating reject letters for all candidates who do not get the required average & interview call letters for the others. (b) Explain the basic structure of C program. [10+6]
  2. (a) What is a preprocessor directive. (b) Distinguish between function and preprocessor directive. (c) What is the significance of conditional compilation. (d) How does the undefining of a pre-defined macro done. [4+4+4+4]
  3. (a) How to use pointers as arguments in a function? Explain through an example. (b) Write a โ€˜Cโ€™ function using pointers to exchange the values stored in two loca- tions in the memory. [8+8]
  4. (a) What are Bit fields. What are its advantages. What is its syntax. (b) Write a C program to store the information of vehicles. Use bit fields to store the status information. Assume the vehicle object consists of type, fuel and model member fields. Assume appropriate number of bits for each field.[8+8]
  5. Write a program to read the contents of three files and write the file with largest number of characters into an output file. [16]
  6. Use the operations push, pop, stacktop, and empty to construct operations on stack, which do each of the following: Given an integer n, set i to the n the element from the top of stack, leaving the stack unchanged Set I to the bottom element of stack, leaving the stack empty.[16]
  7. (a) Explain any two graph representations. (b) Write function for finding the indegree and outdegree of a node in a directed graph. [8+8]