Answer any fifteen questions. All questions solved below.
What is the C character set?
The C character set includes upper and lowercase alphabets (A-Z, a-z), digits (0-9), and special characters like +, -, *, /, %, &, and punctuation marks.
What are keywords in C?
Keywords are reserved words in C that have a predefined meaning to the compiler and cannot be used as identifiers.
Name three classes of data types in C.
The three classes are Primary (Built-in), Derived, and User-defined data types.
Write the general format of scanf function.
scanf("control_string", &variable1, &variable2, ...);
What are logical operators in C?
Logical operators include AND (&&), OR (||), and NOT (!).
Value of: 5+5 == 10 && 2+3 > 5?
(5+5 == 10) is True (1); (2+3 > 5) is False (0). Since 1 && 0 is 0, the value is False.
Write the C expression for sqrt(b² - 4ac) > 0.
sqrt(b * b - 4 * a * c) > 0
Write the general syntax of simple IF statement.
if (expression) { statement; }
What is an exit-controlled loop?
A loop where the test condition is evaluated at the end of the loop body (e.g., do-while loop).
What are void functions?
Functions that do not return any value to the calling function.
What is the first subscript of an array in C?
The first subscript (index) is always 0.
Answer any five questions.
Rules for naming identifiers in C.
Difference between ++i and i++.
++i (Prefix) increments the value first and then uses it in the expression.
i++ (Postfix) uses the current value in the expression first and then increments it.C program to check whether a number is odd or even.
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n % 2 == 0) printf("Even");
else printf("Odd");
return 0;
}
Answer any five questions.[span_42](end_span)
(a) Sum of first n natural numbers using while loop.
#include <stdio.h>
int main() {
int n, i = 1, sum = 0;
scanf("%d", &n);
while (i <= n) {
sum += i;
i++;
}
printf("%d", sum);
return 0;
}
(b) Difference between exit-controlled and entry-controlled loop.[span_44](end_span)
In an entry-controlled loop (for, while), the condition is checked before entering the loop.
In an exit-controlled loop (do-while), the body is executed at least once before checking the condition.(a) Explain switch statement with example.
The switch statement allows a variable to be tested for equality against a list of values (cases).
switch(choice) {
case 1: printf("One"); break;
default: printf("Other");
}
(b) Difference between break and continue.[span_49](end_span)
Break terminates the loop or switch entirely.
Continue skips the current iteration and jumps to the next iteration of the loop.C program for Factorial using Recursion.
int fact(int n) {
if (n == 0) return 1;
return n * fact(n - 1);
}
Centigrade to Fahrenheit/Kelvin.[span_53](end_span)
F = (C * 9/5) + 32; K = C + 273.15.
Program to find sum of array elements.
#include <stdio.h>
int main() {
int a[10], n, sum = 0;
scanf("%d", &n);
for(int i=0; i<n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
printf("Sum = %d", sum);
return 0;
}
Would you like me to create a flowchart illustrating the difference between entry-controlled and exit-controlled loops?