CS100 QP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

01000CS100092001 Pages: 3

Reg No.:_______________ Name:__________________________


APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY
B.Tech Degree S1,S2 (S,FE) Examination May 2021 (2015 Scheme)

Course Code: CS100


Course Name: BASICS OF COMPUTER PROGRAMMING (CS,IT)
Max. Marks: 100 Duration: 3 Hours
PART A
Answer all Questions. Marks
1 Write the value of the following expressions in C language: (3)
(i) 5 ? 6 : 7 (ii) 2 == 3
2 Point out the purpose of break and continue statements in C. (3)
3 Write a C program to accept a string and display it after converting all (3)
lowercase letters to uppercase.
4 Compare structure and union in C language. (3)
5 Write the output of the following C program code. (3)
void main() {
int a[] = {30, 20, 10};
printf(“%d %d %d\n”, *a, *a+1, *(a+1));
}
6 Write the C language statements for the following: (3)
(i) Define an array of pointers for storing the names of months.
(ii) Define an array of structure for storing the register number, name and 4
marks of 50 students in a class.
7 Define a function in C for counting the number of digits of a counting number (3)
passed to it.
8 Write a recursive function for finding the n! (factorial of n). (3)
9 Compare the features of automaic and static variables in C. (3)
10 Write a function to check whether a given character is present in a string. (3)
Character and string are passed to the function. If the character is present return
1 otherwise return 0.
11 What do you understand by command line arguments? How it is implemented (3)
in C language?

Page 1 of 3
01000CS100092001

12 Given, fp is a file pointer pointing to a text file opened in read mode. Write the (3)
fseek() for moving the file pointer (fp) to :
(i) the last charater in the file (NOT the end of file).
(ii) move to the beginning of the file.
(iii) move to the just previous character.
13 Write the syntax of fwrite() function and point out what are the arguments. (2)
14 Suppose a is an unsigned integer variable whose value is 0x5978. What will be (2)
the value of b, after executing the statement, b = a << 5;
(Give the value of b in hexadecimal form.)

PART B
Answer any four questions. Each question carries 8 Marks
15 Write the syntax and explain the working of different iterative statements in C (8)
language.

16 a) Write a program for finding the largest element in a MxN matrix of integer (5)
numbers. Display the largest number and its position.
b) Write a program to count the digits in a string. (3)
17 a) Suppose S is a structure variable, SP is a pointer to structre and is pointing to S (3)
and m is a member of structure. Write the two different expressions in C
language for accessing the member m using SP.
b) Define a function, using pointers, for concatenating two strings passed to it. (5)
Second string is concatenated to the first one. Do not use any library functions.
18 Write a function for checking whether a counting number is prime or not. Using (8)
this function write a program for displaying the prime numbers in first N
counting numers.
19 a) Write a C program for finding the smallest of N integer numbers. (4)
b) Write a recursive function for finding the kth fibonacci number. Fibonacci (4)
series is 1, 1, 2, 3, 5, 8, 13, 21, ........

PART C
Answer any two full questions. Each carries 14 Marks
20 a) Write a program to sort a set of N student names in alphabetical order. A (8)
student name may contain space.

Page 2 of 3
01000CS100092001

b) Write a program to check whether a given number is present in a set of N (6)


numbers. If the number is present display the position of the number in the list.
If not present display suitable message. Repeat the search operation if the user
wants to continue.
21 a) Using command line argument copy the content of one text file to another. (6)

b) Implement wc command in UNIX. The wc command displays the number of (8)


lines, words and characters in the specified file.
( usage is wc <filename>)
22 a) Point out the difference between external variable definition and external (3)
variable declaration.

b) You are given a two byte unsigned number. Illustate how bitwise operators can (4)
be used to separate the low order byte and high order byte from the given
number.

c) An unformated file named “NUM.DAT” contains a set of integer numbers (7)


written to the file using fwrite() function. Write a C program for displaying the
numbers stored in the file and also find the average of these numbers.

*****

Page 3 of 3

You might also like