BCA Sem 1 C Programming Exam Tips 2026 – VNSGU Complete Guide with Solved Programs & MCQs
Ankit Singh
2 July 2026· BCA Study Guides

Why C Programming is Both the Easiest and Most Failed Paper in BCA Sem 1
C Programming is the first real programming language most BCA students encounter. It is also paradoxically both the easiest paper to score in and one of the most frequently failed. The reason is straightforward: students who practice writing programs by hand score 80%+. Students who only read theory without writing code tend to blank out in the practical and struggle to produce compilable programs in the theory paper.
The VNSGU BCA Sem 1 C Programming paper rewards hands-on practice above memorization. Every Section C question asks you to write a program. You cannot fake your way through it with definitions.
📌 Download 5 years of official VNSGU BCA Sem 1 question papers from our BCA Sem 1 Papers page and practice writing programs under timed conditions before your exam.
VNSGU BCA Sem 1 C Programming Exam Pattern 2026
| Section | Type | Marks | Strategy |
|---|---|---|---|
| Section A | 5 compulsory short answers (definitions, differences) | 2×5 = 10 marks | Answer all 5. Keep answers to 3–4 lines each. |
| Section B | 3 out of 5 medium questions (programs or explanations) | 5×3 = 15 marks | Pick 3 where you can write complete working code. |
| Section C | 2 out of 3 long questions (complex programs + theory) | 10×2 = 20 marks | Attempt sections even if you cannot complete fully — partial marks are awarded. |
| External Total | — | 70 marks (3 hours) | — |
| Internal | Attendance, assignments, class tests | 30 marks | Attend all labs. Submit every assignment on time. |
| Practical | C lab — write and run a program, viva voce | 50 marks (separate) | Practice 30+ programs by hand. Know how to compile with gcc. |
Unit 1: Introduction to C — Important Questions
Q1. What are the features of C language? Why is C called a middle-level language?
Answer: C is a structured, general-purpose programming language developed by Dennis Ritchie at Bell Labs in 1972. Key features:
- Middle-Level Language: C combines the power of low-level languages (direct memory access using pointers, bit manipulation) with the readability of high-level languages (structured programming, functions). It is used to write both application software and operating systems (Unix/Linux).
- Structured Programming: Programs are organized into functions, supporting modular design.
- Portability: C programs can be compiled and run on different hardware platforms with minimal changes.
- Rich Library: The C Standard Library provides built-in functions for I/O, string manipulation, math, and memory management.
- Efficient: C compiles to highly efficient machine code and provides direct hardware control through pointers.
Q2. Explain the structure of a C program with a complete example.
/* 1. Preprocessor Directives */
#include <stdio.h> // Standard I/O library
#include <string.h> // String library
/* 2. Global Variable Declaration */
int globalVar = 10;
/* 3. Function Prototype */
int add(int a, int b);
/* 4. Main Function — Program Execution Starts Here */
int main() {
/* 5. Local Variable Declaration */
int x = 5, y = 3;
int result;
/* 6. Statements & Expressions */
result = add(x, y);
/* 7. Output */
printf("Sum = %d
", result);
return 0; // 8. Return statement
}
/* 9. Function Definition */
int add(int a, int b) {
return a + b;
}
The preprocessor directives (#include, #define) are processed before compilation. The main() function is the entry point — every C program must have exactly one main().
Q3. What is the difference between printf() and scanf()?
| Feature | printf() | scanf() |
|---|---|---|
| Purpose | Outputs (prints) formatted data to the screen | Reads (inputs) formatted data from the keyboard |
| Format specifier | Used to format output: %d, %f, %c, %s | Used to specify input type: %d, %f, %c, %s |
| Address operator | Not required: printf("%d", x); | Required for most types: scanf("%d", &x); |
| Return value | Number of characters printed | Number of items successfully read |
Unit 2: Control Structures and Loops — Important Questions
Q4. Explain the difference between for, while, and do-while loops with examples.
| Feature | for | while | do-while |
|---|---|---|---|
| Use when | Number of iterations known | Iterations depend on a condition | Loop must execute at least once |
| Condition check | Before first iteration | Before first iteration | After first iteration |
| Guaranteed execution | No (if condition false, skips) | No | Yes (always runs at least once) |
// for loop — print 1 to 5
for (int i = 1; i <= 5; i++) {
printf("%d ", i);
}
// while loop — same output
int i = 1;
while (i <= 5) {
printf("%d ", i);
i++;
}
// do-while — same output, but always executes once
int j = 1;
do {
printf("%d ", j);
j++;
} while (j <= 5);
Q5. Write a C program to check whether a number is prime.
#include <stdio.h>
int main() {
int n, i, isPrime = 1;
printf("Enter a number: ");
scanf("%d", &n);
if (n < 2) isPrime = 0;
for (i = 2; i * i <= n; i++) {
if (n % i == 0) {
isPrime = 0;
break;
}
}
if (isPrime)
printf("%d is a prime number.
", n);
else
printf("%d is not a prime number.
", n);
return 0;
}
Exam Tip: The optimized condition i * i <= n (instead of i <= n/2 or i < n) is the professionally correct approach. Using it shows the examiner you understand algorithm efficiency.
Unit 3: Functions — Important Questions
Q6. What is the difference between call-by-value and call-by-reference? Write a swap program to demonstrate both.
#include <stdio.h>
// Call-by-value — does NOT swap the original variables
void swapByValue(int a, int b) {
int temp = a;
a = b;
b = temp;
printf("Inside swapByValue: a=%d, b=%d
", a, b);
}
// Call-by-reference — DOES swap the original variables
void swapByReference(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int main() {
int x = 10, y = 20;
swapByValue(x, y);
printf("After swapByValue: x=%d, y=%d
", x, y); // x=10, y=20 (unchanged)
swapByReference(&x, &y);
printf("After swapByReference: x=%d, y=%d
", x, y); // x=20, y=10 (swapped)
return 0;
}
Q7. What is recursion? Write a recursive program to calculate factorial and Fibonacci.
Definition: Recursion is a programming technique where a function calls itself with a smaller input to solve a problem. Every recursive function must have a base case (stopping condition) to prevent infinite recursion.
#include <stdio.h>
// Recursive Factorial
int factorial(int n) {
if (n == 0 || n == 1) return 1; // Base case
return n * factorial(n - 1); // Recursive call
}
// Recursive Fibonacci
int fibonacci(int n) {
if (n == 0) return 0; // Base case 1
if (n == 1) return 1; // Base case 2
return fibonacci(n-1) + fibonacci(n-2); // Recursive call
}
int main() {
printf("5! = %d
", factorial(5)); // Output: 120
printf("Fib(6) = %d
", fibonacci(6)); // Output: 8
return 0;
}
Unit 4: Arrays and Strings — Important Questions
Q8. Write a C program to sort an array using Bubble Sort.
#include <stdio.h>
int main() {
int arr[] = {64, 34, 25, 12, 22};
int n = 5, i, j, temp;
// Bubble Sort
for (i = 0; i < n - 1; i++) {
for (j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j+1]) {
// Swap
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
printf("Sorted array: ");
for (i = 0; i < n; i++)
printf("%d ", arr[i]);
return 0;
}
Output: Sorted array: 12 22 25 34 64
Q9. Explain and demonstrate important string handling functions in C.
#include <stdio.h>
#include <string.h>
int main() {
char s1[50] = "Hello";
char s2[50] = "World";
char s3[50];
printf("strlen: %lu
", strlen(s1)); // 5 — length of string
strcpy(s3, s1); // Copy s1 into s3
printf("strcpy: %s
", s3); // Hello
strcat(s1, s2); // Concatenate s2 to s1
printf("strcat: %s
", s1); // HelloWorld
printf("strcmp: %d
", strcmp("abc","abc")); // 0 (equal)
printf("strcmp: %d
", strcmp("abc","xyz")); // negative (abc < xyz)
strupr(s2); // Convert to uppercase (MSVC)
printf("strupr: %s
", s2); // WORLD
return 0;
}
| Function | Purpose | Return Value |
|---|---|---|
| strlen(s) | Length of string (excluding ' ') | Integer (length) |
| strcpy(dest, src) | Copy src into dest | Pointer to dest |
| strcat(dest, src) | Append src to end of dest | Pointer to dest |
| strcmp(s1, s2) | Lexicographic comparison | 0 if equal, <0 if s1 |
| strrev(s) | Reverse the string in-place | Pointer to reversed string |
| strupr(s) | Convert all characters to uppercase | Pointer to modified string |
| strlwr(s) | Convert all characters to lowercase | Pointer to modified string |
Unit 5: Pointers — Important Questions
Pointers are the most important and most feared topic in C. VNSGU dedicates at least one Section C question to pointers every year. Master this unit completely.
Q10. Explain pointer declaration, initialization, and pointer arithmetic with a program.
#include <stdio.h>
int main() {
int x = 42;
int *p; // Pointer declaration
p = &x; // Pointer initialization — p stores address of x
printf("Value of x: %d
", x); // 42
printf("Address of x: %p
", &x); // e.g., 0x61ff08
printf("Value of p (address): %p
", p); // Same address
printf("Value at *p: %d
", *p); // 42 — dereferencing
*p = 100; // Change x's value through the pointer
printf("x is now: %d
", x); // 100
// Pointer Arithmetic
int arr[] = {10, 20, 30, 40, 50};
int *ptr = arr; // Points to first element
for (int i = 0; i < 5; i++) {
printf("%d ", *(ptr + i)); // Access each element using pointer arithmetic
}
// Output: 10 20 30 40 50
return 0;
}
Key rules for pointer arithmetic:
ptr + 1moves the pointer forward bysizeof(datatype)bytes, not 1 byte. For anint*pointer, +1 moves 4 bytes forward.- Subtracting two pointers of the same array type gives the number of elements between them.
- Pointer comparison using <, >, == is valid only for pointers within the same array.
Unit 6: Structures and Unions — Important Questions
Q11. Write a C program using a structure to store and display student records.
#include <stdio.h>
// Structure definition
struct Student {
int rollNo;
char name[50];
float marks;
};
int main() {
// Structure variable
struct Student s1;
// Input
printf("Enter Roll No: ");
scanf("%d", &s1.rollNo);
printf("Enter Name: ");
scanf("%s", s1.name);
printf("Enter Marks: ");
scanf("%f", &s1.marks);
// Output
printf("
--- Student Record ---
");
printf("Roll No: %d
", s1.rollNo);
printf("Name: %s
", s1.name);
printf("Marks: %.2f
", s1.marks);
return 0;
}
// Structure with typedef (cleaner syntax)
typedef struct {
int id;
char dept[30];
} Employee;
// Now use: Employee e1; instead of: struct Employee e1;
Q12. What is the difference between a structure and a union? Write a program to demonstrate.
#include <stdio.h>
struct ExampleStruct {
int i; // 4 bytes
float f; // 4 bytes
char c; // 1 byte
};
// Total size = 4 + 4 + 1 = 9 bytes (may be 12 due to padding)
union ExampleUnion {
int i; // 4 bytes
float f; // 4 bytes
char c; // 1 byte
};
// Total size = 4 bytes (largest member — all share same memory)
int main() {
struct ExampleStruct s;
union ExampleUnion u;
printf("Size of struct: %lu bytes
", sizeof(s)); // 12 (with padding)
printf("Size of union: %lu bytes
", sizeof(u)); // 4
// In a union, only the last assigned member has valid data
u.i = 100;
printf("u.i = %d
", u.i); // 100
u.f = 3.14f;
printf("u.f = %.2f
", u.f); // 3.14
printf("u.i = %d
", u.i); // Garbage! u.f overwrote the shared memory
return 0;
}
Unit 7: File Handling — Important Questions
Q13. Write a C program to write student records to a file and read them back.
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *fp;
int rollNo;
char name[50];
float marks;
// Writing to a file
fp = fopen("students.txt", "w");
if (fp == NULL) {
printf("Error opening file!
");
exit(1);
}
fprintf(fp, "101 Rahul 78.5
");
fprintf(fp, "102 Priya 92.0
");
fprintf(fp, "103 Amit 65.3
");
fclose(fp);
printf("Data written to file successfully.
");
// Reading from the file
fp = fopen("students.txt", "r");
if (fp == NULL) {
printf("Error opening file!
");
exit(1);
}
printf("
--- Student Records ---
");
while (fscanf(fp, "%d %s %f", &rollNo, name, &marks) != EOF) {
printf("Roll: %d | Name: %s | Marks: %.1f
", rollNo, name, marks);
}
fclose(fp);
return 0;
}
| Function | Purpose | File Mode |
|---|---|---|
| fopen(filename, mode) | Opens a file; returns FILE* pointer | "r"=read, "w"=write (creates/overwrites), "a"=append |
| fclose(fp) | Closes the file and flushes the buffer | — |
| fprintf(fp, format, ...) | Writes formatted output to file | Write/append mode |
| fscanf(fp, format, ...) | Reads formatted data from file | Read mode |
| fgets(str, n, fp) | Reads a line of text from file | Read mode |
| feof(fp) | Returns true if end-of-file is reached | Read mode |
Unit 8: Dynamic Memory Allocation — Important Questions
Q14. Explain malloc(), calloc(), realloc(), and free() with examples.
#include <stdio.h>
#include <stdlib.h>
int main() {
int n = 5;
int *arr;
// malloc — allocates memory (uninitialized)
arr = (int*) malloc(n * sizeof(int));
if (arr == NULL) { printf("Memory allocation failed!
"); exit(1); }
for (int i = 0; i < n; i++) arr[i] = (i + 1) * 10;
printf("malloc array: ");
for (int i = 0; i < n; i++) printf("%d ", arr[i]);
printf("
");
// realloc — resize the previously allocated memory
arr = (int*) realloc(arr, 8 * sizeof(int));
for (int i = 5; i < 8; i++) arr[i] = (i + 1) * 10;
printf("After realloc (8 elements): ");
for (int i = 0; i < 8; i++) printf("%d ", arr[i]);
printf("
");
// free — release the memory back to the OS
free(arr);
arr = NULL; // Good practice: prevent dangling pointer
// calloc — allocates memory AND initializes to zero
int *arr2 = (int*) calloc(5, sizeof(int));
printf("calloc array (all zeros): ");
for (int i = 0; i < 5; i++) printf("%d ", arr2[i]); // 0 0 0 0 0
free(arr2);
return 0;
}
5-Year Topic Frequency Analysis (VNSGU BCA Sem 1 C Programming)
| Rank | Topic | Frequency | Typical Section |
|---|---|---|---|
| 1 | Pointers (declaration, arithmetic, call-by-reference) | 5/5 years | Section B + C |
| 2 | Arrays (1D/2D sorting, searching) | 5/5 years | Section B + C |
| 3 | Functions (recursion, factorial, Fibonacci) | 5/5 years | Section B + C |
| 4 | Strings (strlen, strcpy, strcat, palindrome check) | 4/5 years | Section B |
| 5 | Structures (student/employee record) | 4/5 years | Section C |
| 6 | File Handling (fopen, fprintf, fscanf) | 4/5 years | Section C |
| 7 | Control Structures (loops, switch-case) | 3/5 years | Section A + B |
| 8 | Dynamic Memory (malloc, calloc, free) | 3/5 years | Section B |
| 9 | Union vs Structure | 3/5 years | Section A + B |
| 10 | C Language Features and History | 2/5 years | Section A |
Common Mistakes VNSGU BCA Sem 1 Students Make in C Exams
- Missing #include directives: Writing
scanfwithout#include <stdio.h>orstrlenwithout#include <string.h>makes your program uncompilable. Always write includes first. - Forgetting & in scanf:
scanf("%d", x)instead ofscanf("%d", &x)is one of the most common errors. Only strings (char arrays) do not need & because the array name is itself an address. - Not initializing pointers: Using a pointer before assigning it an address causes undefined behavior. Always initialize:
int *p = &x;orint *p = malloc(...); - Mixing up == and = in if conditions:
if (x = 5)assigns 5 to x (always true).if (x == 5)compares. A veteran trick: write the constant first —if (5 == x)— so a typoif (5 = x)causes a compile error instead of a silent bug. - Not closing files:
fclose(fp)must be called after everyfopen(). Forgetting to close a file causes data loss and is deducted in marking. - Writing incomplete programs in Section C: Write the full program —
#include,main(), declarations, logic, andreturn 0. Half-finished programs get half marks at best.
Must-Practice Programs for the Practical Exam
- Print a multiplication table for any number (for loop)
- Check if a number is Armstrong (e.g., 153 = 1³+5³+3³)
- Reverse a string without using strrev()
- Sort an array using Bubble Sort and Selection Sort
- Find the second-largest element in an array
- Recursive GCD (Euclidean algorithm)
- Matrix multiplication of two 3×3 arrays
- Swap two numbers using pointers (call-by-reference)
- Count vowels and consonants in a string
- Check if a string is a palindrome
- Create, write, and read a student file using fprintf/fscanf
- Dynamic array using malloc and free
Internal Links: Related Study Resources
- 📄 VNSGU BCA Sem 1 Previous Year Question Papers PDF
- ✅ VNSGU BCA Sem 1 Solved Papers & Answers
- 📚 How to Pass BCA Sem 1 VNSGU on the First Attempt
- 📚 BCA Sem 2 DBMS Important Questions
- 📚 BCA Sem 3 Data Structures Important Questions
- 🤖 AI Study Buddy — Ask any C programming question
Frequently Asked Questions — VNSGU BCA Sem 1 C Programming
Q: Is the C programming practical exam hard?
The practical exam is straightforward if you practice. You receive a problem like "Write a program to find the factorial using recursion" or "Implement a student record using structures." You write it in the lab, compile it, run it, and then face a viva on how your code works. Students who have written 30+ programs by hand before the exam typically find it easy. Students who only read programs (without typing and running them) struggle under exam conditions.
Q: What compiler should I practice C with?
Use Code::Blocks with MinGW (free, Windows) or Dev-C++ for offline practice. Online, use OnlineGDB or Programiz C compiler. In your lab exam, your college will have Turbo C++ or Code::Blocks — know both. Practice using the gcc command line too: gcc program.c -o output then ./output.
Q: What is a dangling pointer?
A dangling pointer is a pointer that references memory that has been freed or is no longer valid. Example: calling free(ptr) and then accessing *ptr — the memory has been released but the pointer still holds the old address. This causes undefined behavior (program crash or data corruption). Always set a pointer to NULL after freeing: free(ptr); ptr = NULL;
Q: What is the difference between an array and a pointer in C?
An array name (e.g., arr) is a constant pointer to the first element — you cannot change what it points to. A pointer variable (e.g., int *p) is a variable that can point to any integer. You can do p = arr; but you cannot do arr = p;. The sizeof an array gives total size (e.g., 5 ints × 4 bytes = 20); sizeof a pointer always gives the pointer size (4 or 8 bytes depending on the system).
Q: What is the difference between local and global variables in C?
A local variable is declared inside a function or block. It is created when the function is called and destroyed when it returns. It is only accessible within that function. A global variable is declared outside all functions, usually at the top of the file. It is created when the program starts, persists for the entire program's lifetime, and is accessible from any function in the file. Overusing global variables is poor practice because it makes programs hard to debug — any function can accidentally modify a global value.
Q: What are preprocessor directives in C? Give examples.
Preprocessor directives are instructions processed by the C preprocessor before the compiler runs. They begin with # and do not end with a semicolon. Common examples: #include <stdio.h> — inserts the contents of the standard I/O header file. #define PI 3.14159 — creates a macro constant; wherever PI appears in code, the preprocessor replaces it with 3.14159 before compilation. #define MAX(a,b) ((a)>(b)?(a):(b)) — function-like macro. #ifdef / #ifndef / #endif — conditional compilation, used to include code only when certain conditions are met (e.g., debugging builds).
Q: What are storage classes in C? Explain auto, static, extern, and register.
Storage classes define a variable's lifetime, scope, and initial value: auto — the default for local variables. Created when the block starts, destroyed when it ends. Initial value is garbage. static — persists throughout the program's lifetime even after the function returns. A static local variable retains its value between function calls. A static global variable is restricted to its source file. Initial value is 0. extern — declares a variable defined in another file. Used to share global variables across multiple .c files. register — suggests the compiler store the variable in a CPU register for faster access (the compiler may ignore this hint). Used for variables accessed very frequently in loops.
📌 Practice papers: Use our VNSGU BCA Sem 1 Papers to test yourself under exam conditions. After each attempt, review your programs against our solved answer sheets. All resources are free — no sign-up required.
Keep reading more exam guides
All Blog Posts