0
Programming in C and Data Structures : Question Paper May 2016 - First Year Engineering (C Cycle) (Semester 1) | Visveswaraya Technological University (VTU)

## Programming in C and Data Structures - May 2016

### First Year Engineering (C Cycle) (Semester 1)

TOTAL MARKS: 100
TOTAL TIME: 3 HOURS
(1) Question 1 is compulsory.
(2) Attempt any four from the remaining questions.
(3) Assume data wherever required.
(4) Figures to the right indicate full marks.
1(a) Define Pseudo code. Write a Pseudo code to find sum and average of given three numbers .(5 marks) 1(b) What is an identifier ? What are the rules to construct identifier ? Classify the following as Valid /invalid Identifiers.
i) num2
ii) \$num1
(6 marks)
1(c) Write a C program to find area of rectangle.(5 marks) 10(a) What is dynamic memory allocation ? Write and explain the different dynamic memory allocation functions in C.(6 marks) 10(b) Explain stack and Queue data structures along with their application.(6 marks) 10(c) Explain how pointers and arrays are related with example.(4 marks) 2(a) Explain print and scant functions with example.(4 marks) 2(b) List all the operators used in C. Give examples.(8 marks) 2(c) Write the output of the following C code
i) void main ( )
{
int a =5, b=2, res1 ;
float f1 = 5.0, f2 = 2.0, res2;
res1 = 5/2.0 + a/2 + a/b;
res2 = f1/2 * f1-f2 ;
print f ("res1 = %d res2 = %f ", res1,res2) ;
}
ii) void main ( )
{
int i = 5 , j = 6 , m, n;
m = ++ i + j ++ ;
n - - - i + j - - ;
printf ("m =%d n = %d" , m, n) ;
}
(4 marks)
3(a) List all the conditional control statement used in C . write a C program to find the biggest of three numbers.(8 marks) 3(b) Write a C program to find the reverse of an integer number NUM and check whether it is PALINDROME or NOT .(8 marks) 4(a) Explain the switch satement with syntax and example .(8 marks) 4(b) List the difference between the while loop and do - while loop . Write a C program to find sum of Natural numbers from 1 to N using for loop .(8 marks) 5(a) What is an array? Explain the declaration and initialization of single and double dimensional arrays with example .(8 marks) 5(b) Write C program to search a name in a list of names using Binary searching technique.(8 marks) 6(a) Explain any Five string manipulation library functions with example.(8 marks) 6(b) Write a C program to read N elements and find biggest element in the array.(8 marks) 7(a) What is structure? Explain the syntax of structure declaration and initialization with example.(5 marks) 7(b) Write a C program to maintain a record of ' n ' employee detail using an array of structures with three fields (id, name, salary) and print the detail of employees whose salary is above 5000.(7 marks) 7(c) Explain fprint and fscanf functions with syntax.(4 marks) 8(a) Explain structure with in a structure with an example.(7 marks) 8(b) What is a file ? Explain fopen and fclose functions.(5 marks) 8(c) Explain fgets and fputs functions.(4 marks) 9(a) What is a pointer ? Explain how the pointer variable is declared and initialized.(4 marks) 9(b) Explain any two preprocessor directives in C with example.(6 marks) 9(c) Write a C program to swap two numbers using call by pointers (address) method.(6 marks)