Prev Year Questions

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

A) Explain different phases in the programming process.

B) Write an algorithm to calculate the factorial of a number.

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.

i) What will be the output of the following program?

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);
}

ii) What would be the output of the following program?

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.

J) What would be the output of the following program?


int main()
{
int x = 1;
while (x == 1) {
x = x - 1;
printf("\n%d", x);
}
}

K) Differentiate between exit() and break

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?

O) Write a program in C to create a structure named Books consisting of title, author,


subject, and book_id as its members. Read the details of five books from the user and
then display the data entered by the user on the screen (use an array of structures).

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.

B) Explain the various phases of the programming process in detail.

C) Convert the given flowchart into a C program.

Q2

A) Write logical expressions to test whether a given character variable in C is:

1. A lowercase letter.
2. An uppercase letter.
3. A digit.
4. Whitespace (includes tab, space, newline).

B)

1. Evaluate the expression: 1 && 0 % 10 >= 0 && 30 % 10 <= 3. Show evaluation


steps.
2. Compute the values of:
o 'F' – 'C'
o 2.0 + (float)(5/3)

OR

Explain the following bitwise operators with examples:

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:

• 0–200 Calls: Rs. 0.50 per call.


• 201–400 Calls: Rs. 100 + Rs. 0.65 for each call beyond 200.
• 401+ Calls: Rs. 230 + Rs. 0.80 for each call beyond 400.

OR

Write a program to compute the digital root of a number.

B) Differentiate between:

1. while loop and do...while loop.


2. break and continue statements.

Q4

A) What will be printed by the following program?

int f(int a){


printf("%d,", a);
a++;
return a;
}
int main(){
int a = 5, b;
b = f(a);
printf("%d,%d\n", a, b);
return 0;
}

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)

1. What do you mean by recursion?


2. Provide the syntax of a function call and function definition, including the role of the
function prototype.
3. Explain one static storage class with an example.
Q5

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}.

C) Create a structure named Employee with fields {empCode, name, department,


address, salary}. Write a C program to input data for five employees and display it.

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.

B) Write a program in C to create a structure named Employee consisting of {empCode,


name, department, address, salary} as its members. Use an array of structures to read
the details for five employees from the user and then display the data entered by the user on
the screen.

C) Date is an entity which consists of {hours, minutes, seconds}. Account is a second


entity which consists of {acct_no, acct_type ('S' for saving and 'C' for
current), name_of_account_holder, balance, date_of_lastpayment} which is
already defined using the Date entity. Write a syntax in C from the given data and also
initialize the value for every element using the dot operator.

Q1

A)

1. What is an array? (2 Marks)


2. Define Secondary storage device. (2 Marks)
3. What is a compiler? (2 Marks)
4. Write the syntax of a for loop with an example. (2 Marks)
5. Explain any 4 keywords in C Language. (2 Marks)

Q2

A) What is a programming language? Explain different types of programming languages. (5


Marks)

B) Explain C tokens with appropriate examples. (5 Marks)

C) State errors, if any, in the following statements and provide the correct version:

1. Scanf("% d", number);


2. Scanf("%f", & total);
3. prinjf("How is the paper\n");
4. printf("Smart City');
5. Scanf("%C", & name);
(5 Marks)
Q3

A) Write a C program to read a number and check whether it is a prime number. (8 Marks)

B) What is a user-defined function in C? Explain the general form of a function with an


example. (7 Marks)

Q4

A) Explain the syntax of a while loop with a suitable example. (5 Marks)

B) Write a C program to read a number and check whether it is positive or negative. (5


Marks)

C) What is the output of the following program?

#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.

1. a) Explain operator precedence and associativity in ‘C’ Programming .


b) What is use of GOTO statement ? Give example.
2. Write display larger among three. Give flow- chart and algorithm.

3. Explain sorting al gorithm : Bubble sort.

4. Differentiate 'While' and 'Do-While' statement with suitable example

5. Write short notes on the following


i) Parameter passing
ii) 2D array.

6 Write a program to display reverse of the string. Also define string.

7. What is function ? Write a program to find factorial of a given number by using


function

8. Define pointer and explain use of pointer.

9. Give syntax of :
i) Switch ...... Case statement
ii) Structure.

You might also like