Jul 2021 AN Answer Key
Jul 2021 AN Answer Key
F Pages: 2
Reg No.:_______________ Name:__________________________
Page 1 of 2
01EST102052002 B
b) What do you mean by Formatted Input? Explain in detail the prototype of (7)
‘scanf()’ function in C including its argument list and return type.
15 a) Explain any 4 string handling functions in C programming. (7)
b) Write a C program to perform linear search on an array of numbers (7)
OR
16 a) Write a C program to find second largest element in an array. (7)
b) Write a C program to check whether a string is palindrome or not without using (7)
string handling functions.
17 a) What are different storage classes in C? Give examples for each. (7)
b) Write a C program to: (7)
(i) Create a structure with fields: Name, Address, Date of birth.
(ii) Read the above details for five students from user and display the details
OR
18 a) What is recursion? Write a C program to display Fibonacci series using (7)
recursive function.
b) Write a C program to sort N numbers using functions. (7)
19 a) Explain any 5 file handling functions in C. (7)
b) Write a C program to reverse a string using pointers. (7)
OR
20 a) Differentiate between array of pointers and pointer to an array. (7)
b) Write a C program to count number of lines in a text file. (7)
****
Page 2 of 2
01EST102052002 B
function. They are local to the block. The default value of static variables is zero.
The static variables are alive till the execution of the program.
1. Static defined local variables do not lose their value between function
calls. In other words they are global variables, but scoped to the local
function they are defined in.
2. Static global variables are not visible outside of the C file they are
defined in.
void Print()
{
printf("Welcome to Programming");
}
int main()
{
Print();
return 0;
}
The fseek() function seeks in an open file. This function moves the file pointer
from its current position to a new position, forward or backward, specified by the
number of bytes.
PART B
Answer any one Question from each module. Each question carries 14 Marks
11 a) Flowchart- 6 Marks (6)
b) Any 4 functional units.2 marks each (8)
OR
12 a) Registers-1 Mark (6)
five important registers in CPU along with functions (5 marks)
b) Algorithm- 4 marks Flowchart -4 marks (8)
13 a) Arithmetic operators with example -2.5 marks (7)
Logical operators with example - 2.5 marks
Bitwise operators with example - 2marks
#include <stdio.h>
int main()
{
int i, originalNum, num, lastDigit, sum;
long fact;
originalNum = num;
sum = 0;
return 0;
}
OR
01EST102052002 B
while (decimalnum!=0)
{
rem = decimalnum%2;
decimalnum = decimalnum / 2;
binarynum = binarynum + rem*temp;
temp = temp * 10;
}
return binarynum;
}
int main()
{
int decimalnum;
printf("Enter a Decimal Number: ");
scanf("%d", &decimalnum);
printf("Equivalent Binary Number is: %ld", decimalToBinary(decimalnum));
return 0;
}
break;
}
}
if (c == n)
printf("%d isn't present in the array.\n", search);
return 0;
}
OR
16 a) Correct Program-7 Marks (7)
#include <stdio.h>
void main(){
int arr1[50],n,i,j=0,lrg,lrg2nd;
lrg=0;
for(i=0;i<n;i++)
{
if(lrg<arr1[i])
{
lrg=arr1[i];
j = i;
}
}
/* ignore the largest element and find the 2nd largest element in the array */
lrg2nd=0;
for(i=0;i<n;i++)
{
if(i==j)
{
i++; /* ignoring the largest element */
i--;
}
01EST102052002 B
else
{
if(lrg2nd<arr1[i])
{
lrg2nd=arr1[i];
}
}
}
void main()
{
char string[25], reverse_string[25] = {'\0'};
int i, length = 0, flag = 0;
OR
01EST102052002 B
NOTE: Marks may be awarded for programs conveying correct logic. Sample programs
are included in scheme.