Total Page: 4 KNU/2020/BCAC102
UG 1st - Semester Examination- 2020
Award: Bachelor of Computer Application
Discipline: Computer Application
Course Type: Core
Course Code: BCAC102
Course Name: Programming in C
Full Marks: 80 Time: 4 Hours
The figures in the right hand margin indicate full marks.
Candidates are required to give their answers in their own words as far as practicable.
Illustrate the answers wherever necessary.
1. Answer any ten questions. 10 X 1=10
a) What are library functions?
b) How does x++ differ from ++x?
c) Which are the operators which represents bitwise AND & bitwise OR operator?
d) What is the purpose of ‘,’ operator in C?
e) What is the use of sizeof () in C?
f) What is the use of getche () function?
g) What is header file in C? Give example.
h) Which function is used to open a file in input mode?
i) What is the difference between ‘x’ and “x” in C?
j) What is the purpose of switch statement?
k) Describe the purpose of the qualifier volatile.
l) What are enumeration variables?
m) Find errors, if any, in the following looping segments. Assume that all the
variables have been declared and assigned values.
while(count!=10);
{
count=1;
sum = sum + x;
count = count + 1;
}
n) What do you mean by scope of a variable?
o) What do mean by pre-processor directive?
p) What is escape sequence in C? Give example.
1
2. Answer any ten questions. 10 X 2 = 20
a) What do you mean by storage class? Give examples.
b) What do you mean by ternary operator? Explain with example.
c) Write the statements to swap the values of two strings.
d) What is the difference between break and continue statement?
e) What is null character? What is its ASCII code?
f) What is the difference between pointer to an array and array of pointers?
g) Why arrays are easier to use compared to a bunch of related variables?
h) What is the difference between local and global variables?
i) Differentiate between entry-controlled loop and exit-controlled loop.
j) What is recursion?
k) Explain the purpose of the following declarations:
float *x(int (*a)[]);
float (*x)(int (*a)[]);
l) What is the output of the following program?
void main()
{
int p = 4, q, r;
q = p = 15;
r = p < 15;
printf("p = %d q = %d r = %d\n", p, q, r);
}
m) What is the purpose of register variable in a C program? What is its scope?
n) Differentiate between structure and union.
o) What is operator precedence and associativity? Explain.
p) What is the difference between strcmp() and stricmp()?
3. Answer any six questions. 6 X 5 = 30
a) Explain static and dynamic memory allocation in C with examples.
b) How can a structure be declared within another structure? Explain with an
example.
c) Write a program which will read a string and rewrite it in the alphabetical order.
For Example the word BCA should be written as ABC.
d) Write a C program to count total number of vowels, consonants, digits, spaces
present in a text.
e) Write a C program to find maximum of each column of a matrix of any order.
2
f) Write a program that displays the following:
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
g) Write a program in C to calculate and print the Electricity bill of a given customer.
The customer id and unit consumed by the user should be taken from the keyboard
and display the total amount to pay by the customer. The charges are as follow:
Unit Charge/unit
upto 199 @1.20
200 and above but less than 400 @1.50
400 and above but less than 600 @1.80
600 and above @2.00
If bill exceeds Rs. 400 then a surcharge of 15% will be charged and the minimum
bill should be of Rs. 100/-
h) Write a program in C to merge two sorted arrays into a third sorted array. Assume
first array contain 1,7,12,30 and 40; the second array contain 15,35,60,80 and 100.
The merged array will contain 1,7,12,15,30,35,40,60,80 and 100.
i) What is pointer? What are its uses? Explain the relationship between pointers and
arrays by taking suitable example.
j) Write a program in C to convert a given integer (in seconds) to hours, minutes and
seconds. Eg. if input is 10000 output will be 2 Hours 46 Minutes and 40 Seconds.
4. Answer any two questions. 2 X 10 = 20
a) Write a C program to calculate the HCF and LCM of two numbers by using
recursive functions.
b) i) Write a program that reads a string from the keyboard and determines whether
the string is palindrome or not. (A string is a palindrome if it can be read from left
and right with the same meaning. For example, Madam and Liril are palindrome
strings. Ignore capitalization).
ii) Write a C program that will count the number of occurrences of a specified
character in a given line of text. 5+5
3
c) i) Write down the syntax and explain the operation of else if ladder statements in
C with suitable example.
ii) What are the differences between if and switch statement?
iii) Write a program to find the minimum of any three given real numbers. 3+3+4
d) i) Write a program to print all Perfect numbers up to a given limit.
ii) Write a program to print all four-digit Armstrong numbers. 5+5
e) i) How do you declare and initialize two-dimensional array?
ii) Write the notation to access the element at row ‘i' and column ‘j’ of a two-
dimensional array ‘m’ using pointer.
iii) What do you mean by row-major representation of matrix?
iv) Write a program to check whether a given square matrix is symmetric or
not. 2+2+2+4
f) What do you mean by command line arguments in C? Write a function in C to
copy the content of one file to another file. Write a program to test the above
function using command line arguments. 2+4+4
----0----