WorksheetsVIVA
Total questions: 16
Worksheet time: 11mins
1. What is the purpose of a function in C?
a) To define a variable
b) To divide code into reusable blocks
c) To store data
d) To print output
2. What is the correct syntax to declare a function in C?
a) function int add();
b) int add();
c) add() int;
d) int = add();
3. Which of the following is a valid function definition?
a) int sum(a, b) {
return a + b;
}
b) int sum(int a, int b) { return a + b;
}
c) sum(int a, int b) return a + b;
d) function sum(int a, int b) { return a + b; }
4. What is the return type of a function that does not return any value?
a) void
b) empty
c) null
d) int
10. What keyword is used to exit a function and optionally return a value?
a) exit
b) return
c) break
d) stop
What will print?
s
m
d
e
0
1
5
10
What will print?
0
1
100
101
The __________, also known as the address operator, returns the memory address of a variable.
asterisk (* )
ampersand ( & )
percent sign ( % )
exclamation point ( ! )
In a C program,
int a = 20;
*ptr = &a;
**dptr = &ptr;
printf ("%d", **dptr);
prints
address of a
address of ptr
value of a
address of dptr
What is a structure in C programming?
A special character in C programming
A built-in function in C programming
A user-defined data type that allows you to combine data items of different types.
A type of loop in C programming
What is the syntax for inputting data into a structure in C?
structName->memberName = value;
structName.memberName = value
structName.memberName = value;
structName.memberName : value;
How do you access the member variables of a structure in C?
Using the asterisk (*) operator
Using the dot (.) operator
Using the hash (#) operator
Using the plus (+) operator
Write a C program to input data for a student using the 'Student' structure.
Define a structure named 'Student' with the required fields and use the scanf function to input the data for the student.
Define a structure named 'Person' instead of 'Student' to input the data
Use the 'printf' function to input the data for the student
Create a function named 'Student' to input the data
How do you declare a structure variable of type 'Student' in C?
struct Student student1;
Student = student1;
int student1;
Student student1;
What is required to declare a structure variable in C?
The variable name only
The keyword 'struct' followed by the structure tag
Only the structure tag
The keyword 'class'
