Programming Fundamentals Full Syllabus Test
### Unit 01: Programming Fundamentals
1. Which component of the computer executes instructions?
a) Memory
b) Input Unit
c) CPU
d) Output Unit
Answer: c) CPU
2. Which number system is not commonly used in computer systems?
a) Binary
b) Decimal
c) Octal
d) Roman
Answer: d) Roman
3. Firmware is a type of:
a) Hardware
b) Software
c) Embedded software
d) Network protocol
Answer: c) Embedded software
---
### Unit 02: Types of Programming Languages
4. Machine language instructions are written in:
a) High-level language
b) Assembly language
c) Binary code
d) Natural language
Answer: c) Binary code
5. What is the output of a compiler?
a) Source file
b) Object file
c) Executable file
d) Pseudo-code
Answer: b) Object file
6. Which of the following is a translator for assembly language?
a) Interpreter
b) Compiler
c) Assembler
d) Macro processor
Answer: c) Assembler
---
### Unit 03: Programming Techniques
7. The step-by-step solution to a problem is called a/an:
a) Algorithm
b) Flowchart
c) Program
d) Pseudo-code
Answer: a) Algorithm
8. Which symbol is used to represent a decision in a flowchart?
a) Rectangle
b) Oval
c) Diamond
d) Parallelogram
Answer: c) Diamond
9. What is pseudo-code?
a) Code written in a programming language
b) Human-readable steps of a program
c) Machine instructions
d) A type of compiler
Answer: b) Human-readable steps of a program
---
### Unit 04: C Language
10. Which of the following is not a valid C keyword?
a) int
b) float
c) string
d) void
Answer: c) string
11. What is the output of the following code?
#include <stdio.h>
int main() {
int a = 5, b = 10;
printf("%d", a + b);
return 0;
a) 10
b) 15
c) 5
d) Compilation error
Answer: b) 15
12. Which operator is used for conditional expressions?
a) ?:
b) ||
c) &&
d) ==
Answer: a) ?:
---
### Unit 05: Control Statements and Derived Data Types
13. Which of the following loops is guaranteed to execute at least once?
a) for
b) while
c) do-while
d) None of the above
Answer: c) do-while
14. How do you declare a pointer in C?
a) int* p;
b) int p*;
c) *int p;
d) int p;
Answer: a) int* p;
15. Which of the following is used to represent multiple values of the same data
type?
a) Pointer
b) Array
c) Structure
d) Union
Answer: b) Array
---
### Unit 06: Functions and File Handling
16. What is the default return type of a function in C if not specified?
a) int
b) void
c) float
d) char
Answer: a) int
17. What is the output of the following code?
#include <stdio.h>
void fun(int n) {
if (n == 0) return;
printf("%d ", n);
fun(n-1);
int main() {
fun(3);
return 0;
a) 3 2 1
b) 3 2 1 0
c) 0 1 2 3
d) Compilation error
Answer: a) 3 2 1
18. Which function is used to write data to a file in C?
a) fopen
b) fwrite
c) fscanf
d) fclose
Answer: b) fwrite
---
### Programming Questions
1. Write a C program to calculate the factorial of a number using recursion.
#include <stdio.h>
int factorial(int n) {
if (n == 0) return 1;
return n * factorial(n - 1);
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
printf("Factorial of %d is %d\n", num, factorial(num));
return 0;
2. Write a C program to reverse a string using pointers.
#include <stdio.h>
#include <string.h>
void reverse(char* str) {
int len = strlen(str);
for (int i = 0; i < len / 2; i++) {
char temp = str[i];
str[i] = str[len - i - 1];
str[len - i - 1] = temp;
}
int main() {
char str[100];
printf("Enter a string: ");
scanf("%s", str);
reverse(str);
printf("Reversed string: %s\n", str);
return 0;
3. Write a C program to read and display a file.
#include <stdio.h>
int main() {
FILE *file;
char filename[100], ch;
printf("Enter the filename to open: ");
scanf("%s", filename);
file = fopen(filename, "r");
if (file == NULL) {
printf("Cannot open file \"%s\"\n", filename);
return 1;
printf("File contents:\n");
while ((ch = fgetc(file)) != EOF) {
putchar(ch);
fclose(file);
return 0;