C Program Solution
C Program Solution
char str[100]="Hello World"; How many bytes are allocated by the above declaration?
Answer: a) 100
int main() {
int i = 5;
return 0;
Explanation:
The sizeof operator is evaluated at compile time and does not evaluate its operand, so ++i is not
incremented. The size of an int in most systems is 2 bytes.
Answer: b) Compilation error (if sizeol is a typo)
Otherwise, the correct result is 2,5.
The smallest integer that can be represented using 16-bits in signed 2's complement system is:
Answer: b) -32768
13. Write a C program to print all the prime numbers > 100 and < 200.
#include <stdio.h>
if (num % i == 0) return 0;
return 1;
int main() {
if (isPrime(i)) {
return 0;
#include <stdio.h>
int main() {
int num;
if (num < 0) {
} else {
factorial *= i;
return 0;
15. If the starting address of a 1D character array of size 10 is 2000, what will be the address of
a[7]?
16. Write a C program that converts a given long integer (representing time in seconds) into hours,
minutes, and seconds.
#include <stdio.h>
int main() {
long seconds;
scanf("%ld", &seconds);
seconds %= 3600;
return 0;
17a. Draw the flowchart for the area and perimeter of a rectangle.
Steps:
1. Start
6. End
X = 776057
X=8
X = 5021
X = 1121
18b. Analyze the difference between 2's complement and 1's complement with examples.
1. 1’s Complement:
o Represents negative numbers by inverting all the bits of the positive number.
2. 2’s Complement:
Key Difference:
• 2’s complement eliminates the need for separate “+0” and “-0” representations.
#include <stdio.h>
int main() {
scanf("%d", &num);
original = num;
while (num != 0) {
remainder = num % 10;
num /= 10;
if (original == reversed) {
} else {
return 0;
19. Write a C program that takes a data type in the command line and computes its size.
This requires a C program with sizeof() to determine the size of types. Let me know if you'd like this
example elaborated.
20a. Write a C program to find the largest and smallest number among a list of numbers taken as
input.
#include <stdio.h>
int main() {
scanf("%d", &n);
scanf("%d", &num);
scanf("%d", &num);
return 0;
20b. Write a program in C to calculate the Fibonacci series up to a user-given number using
recursion.
#include <stdio.h>
int fibonacci(int n) {
if (n <= 1) return n;
int main() {
int n;
scanf("%d", &n);
return 0;
20c. What is an operator? What are the different types of operators used in C?
1. Arithmetic Operators: +, -, *, /, %