Prev Year Questions
Prev Year Questions
Prev Year Questions
C)
i) Draw and explain two symbols used to draw a flowchart.
ii) Define the following:
a) Compiler
b) Linker
D) Define variable. What are the rules for constructing the variable name? Is the variable
name _age valid or invalid? (4)
E)
i) Explain arithmetic operators in C with a suitable example.
ii) Write a short note on the conditional operator.
void main()
{
int i = 2, j = 3, k, l;
float a, b; k = i / j * j;
l = j / i * i; a = i / j * j;
b = j / i * i;
printf("%d %d %f %f", k, l, a, b);
}
void main()
{
int p = 8, q = 20;
if (p == 5 && q > 5)
printf("\nWhy not C");
else
printf("\nDefinitely C!");
}
G)
i) Write a program using a function that receives marks obtained by a student in 3
subjects and returns the average of these marks. Call this function from main()
and print the results in main().
ii) Write a program to calculate overtime pay for 10 employees. Overtime is paid
at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. Assume
that employees do not work for a fractional part of an hour.
H) Write the syntax of:
i) if-else statement
ii) for loop
iii) do-while loop
iv) while loop
I) What is a function in C? Write the syntax for a function prototype, function definition,
and function call.
L) Define an array. What are various types of arrays? Give the syntax of any two of them.
M)
i) Write a program to read 10 elements using an array and display all the
elements in reverse order. Receive the input from the user.
ii) Write a program to find the maximum number in an array containing five
elements of integer type.
N) Define a string in C. Write the syntax to declare a character array. How to initialize a
character array? What is the use of gets() function?
P) Define a structure named State that contains four fields: name, population,
lit_rate, and income. Declare a structure variable as st1. Assign the values for your
structure as abc, 100000, 5.8, 6000.00, respectively.
Q1
A)
1. What do curly braces denote in C? Why does it make sense to use curly braces to
surround the body of a function?
2. Rewrite the statement double ans = 10.0 + 2.0 / 3.0 – 2.0 * 2.0; inserting
parentheses to ensure ans = 11.0 upon evaluation.
3. Explain why the statement #include"stdio.h". is incorrect and fix it.
Q2
1. A lowercase letter.
2. An uppercase letter.
3. A digit.
4. Whitespace (includes tab, space, newline).
B)
OR
1. Left Shift.
2. Bitwise AND.
3. Right Shift.
4. Bitwise Complement.
C) Define a variable in C. What are the rules for declaration? Provide examples of variable
declaration and initialization.
Q3
A) Write a program to calculate telephone charges as per the following rules:
OR
B) Differentiate between:
Q4
B) Write a program in C that takes an integer number x from the user and determines if the
number is an Armstrong number. Implement a function void armstrong(int n) that does
not return a value and outputs the result.
C)
A) A teacher has to enter marks for 5 subjects for a student and calculate the average. Write a
C program to take input, calculate the average, and display all the data.
B) Define a structure in C named Student with fields {name, age, gender, department}.
Declare a variable for this structure and assign the values {xyz, 23, Male, Computer}.
D) Use two related structures for Date and Account. The Date structure contains {hours,
minutes, seconds}. The Account structure contains {acct_no, acct_type,
name_of_account_holder, balance, date_of_lastpayment}. Write a C syntax to define
and initialize these structures.
Q6
A) Define a structure in C named Student which contains four fields as {name, age,
gender, department}. Declare a variable as your name of struct Student. Assign the
values for your structure as xyz, 23, Male, Computer respectively.
Q1
A)
Q2
C) State errors, if any, in the following statements and provide the correct version:
A) Write a C program to read a number and check whether it is a prime number. (8 Marks)
Q4
#include <stdio.h>
int main() {
int x;
for (x = 1; x <= 7; x++) {
if (x == 3)
break;
printf("%d", x);
}
return 0;
}
(5 Marks)
Q5
A) What is a two-dimensional array? Explain how to take input and display the 2-D array. (7
Marks)
B) Write a C program to sort 10 numbers using the bubble sort method. (7 Marks)
Q.1
a) What is the use of the address operator (&) and the indirection operator (*)?
b) Define strings.
c) What is a union? Give an example.
d) How does a structure differ from an array?
e) Explain two ways of initializing a string variable.
f) What is a file?
g) What is wrong in the following structure declaration?
struct
{
int number;
float price;
}
main()
{
----
----
----
}
Q.2
a) Write a C program to put strings together without using the strcat() function.
b) Write the syntax of the following and explain briefly:
i. gets()
ii. puts()
iii. getchar()
iv. putchar()
Q.3
a) Write a program using an array of structures to store information about three books and
print it on the terminal.
b) Explain command-line arguments.
Q.4
a) What is free software? Explain with four types of freedom for free software.
b) Explain the various principles of open-source software.
Q.5
a) Write a C program for call by reference.
b) Explain the modes of operation for files.
9. Give syntax of :
i) Switch ...... Case statement
ii) Structure.