BSc CSIT (TU) Science C Programming (BSc CSIT, CSC115) Question Paper 2075 Nepal
This is the official BSc CSIT (TU) (Science stream) C Programming (BSc CSIT, CSC115) question paper for 2075, as set in the regular annual examination. It carries 60 full marks and a time allowance of 180 minutes, across 12 questions. On Kekkei you can attempt this C Programming (BSc CSIT, CSC115) past paper online with a timer, get instant AI feedback and step-by-step solutions, and track the topics where you lose marks — completely free. Whether you are revising for your BSc CSIT (TU) C Programming (BSc CSIT, CSC115) exam or solving previous years' question papers, this 2075 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
Explain different types of decision-making (branching) statements in C with syntax and examples. Differentiate if-else with switch statement.
Decision-Making (Branching) Statements in C
Decision-making statements let a program choose among different paths of execution based on the result of a condition (an expression that evaluates to true/non-zero or false/zero).
1. Simple if statement
Executes a block only when the condition is true.
if (condition) {
// statements executed when condition is true
}
Example:
if (marks >= 40)
printf("Passed\n");
2. if-else statement
Provides an alternative block when the condition is false.
if (condition) {
// true block
} else {
// false block
}
Example:
if (n % 2 == 0)
printf("Even\n");
else
printf("Odd\n");
3. else-if ladder (nested if-else)
Used to test a series of mutually exclusive conditions.
if (marks >= 80) grade = 'A';
else if (marks >= 60) grade = 'B';
else if (marks >= 40) grade = 'C';
else grade = 'F';
4. switch statement
Selects one of many code blocks by matching an integer/character expression against constant case labels.
switch (expression) {
case const1: statements; break;
case const2: statements; break;
default: statements;
}
Example:
switch (day) {
case 1: printf("Sunday\n"); break;
case 2: printf("Monday\n"); break;
default: printf("Other\n");
}
Difference between if-else and switch
| Basis | if-else | switch |
|---|---|---|
| Condition type | Any relational/logical expression (ranges allowed) | Only equality against integer/char constants |
| Evaluation | Each condition evaluated in sequence | Single expression evaluated once, jumps to matching case |
| Data types | int, float, char, etc. | int and char only |
break | Not required | Required to avoid fall-through |
| Default action | else | default |
| Speed | Slower for many conditions | Faster (jump table) for many fixed values |
Conclusion: Use if-else for range or complex logical conditions; use switch when one variable is compared with many constant values.
What is a function? Explain function declaration, definition and call. Differentiate call by value and call by reference with examples.
Function in C
A function is a self-contained, named block of code that performs a specific task. It can be called (invoked) any number of times, supports modular programming, reduces code duplication, and improves readability and reusability.
A function works through three parts:
1. Function Declaration (Prototype)
Tells the compiler the function's name, return type and parameter types before it is used. It ends with a semicolon.
int add(int a, int b); // declaration / prototype
2. Function Definition
Contains the actual body (logic) of the function.
int add(int a, int b) { // definition
return a + b;
}
3. Function Call
Invokes the function and (optionally) passes arguments and receives a return value.
int sum = add(5, 3); // call -> sum = 8
Call by Value vs Call by Reference
Call by Value: A copy of the actual argument is passed to the function. Changes made to the parameters inside the function do not affect the original variables.
void swap(int x, int y) { // call by value
int t = x; x = y; y = t;
}
int a = 2, b = 5;
swap(a, b); // a and b remain 2 and 5
Call by Reference: The address of the actual argument is passed (using pointers). The function works on the original memory, so changes are reflected in the caller.
void swap(int *x, int *y) { // call by reference
int t = *x; *x = *y; *y = t;
}
int a = 2, b = 5;
swap(&a, &b); // a and b become 5 and 2
| Basis | Call by Value | Call by Reference |
|---|---|---|
| What is passed | Copy of value | Address of variable |
| Effect on original | No change | Original is modified |
| Memory | Extra copy created | No copy, uses pointer |
| Safety | Safer | Original can be altered |
Write a program to read a matrix of order m x n and find the transpose of the matrix.
Program: Transpose of an m x n Matrix
The transpose of a matrix is obtained by interchanging its rows and columns: element of the original becomes element of the transpose. If is of order , its transpose is of order .
#include <stdio.h>
int main() {
int a[10][10], t[10][10];
int m, n, i, j;
printf("Enter rows (m) and columns (n): ");
scanf("%d %d", &m, &n);
printf("Enter %d x %d matrix elements:\n", m, n);
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
scanf("%d", &a[i][j]);
// Compute transpose: t[j][i] = a[i][j]
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
t[j][i] = a[i][j];
printf("Transpose (%d x %d):\n", n, m);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++)
printf("%d\t", t[i][j]);
printf("\n");
}
return 0;
}
Sample Run
Enter rows (m) and columns (n): 2 3
Enter 2 x 3 matrix elements:
1 2 3
4 5 6
Transpose (3 x 2):
1 4
2 5
3 6
Logic: Read the matrix with nested loops, then store each a[i][j] into t[j][i], swapping the row and column indices to form the transpose.
Section B: Short Answer Questions
Attempt any EIGHT questions.
What are tokens in C? Explain different types of tokens.
Tokens in C
A token is the smallest individual (indivisible) unit of a C program that is meaningful to the compiler. The C compiler breaks the source program into tokens during the lexical-analysis phase. C has six types of tokens:
- Keywords — reserved words with predefined meaning that cannot be used as identifiers, e.g.
int,if,while,return,for,void(32 keywords in standard C). - Identifiers — user-defined names for variables, functions, arrays, etc. (e.g.
sum,count,main). They must begin with a letter or underscore and cannot be a keyword. - Constants (Literals) — fixed values that do not change, e.g. integer
10, float3.14, character'A', string"Hello". - Strings — a sequence of characters enclosed in double quotes, e.g.
"CSIT". (Often grouped with constants.) - Operators — symbols that perform operations, e.g. arithmetic
+ - * /, relational> <, logical&& ||, assignment=. - Special symbols / Punctuators — symbols such as
{ } [ ] ( ) ; , #used for grouping, separation and preprocessing.
Example: In int sum = a + b;, the tokens are int (keyword), sum, a, b (identifiers), =, + (operators), and ; (special symbol).
Explain the use of getchar() and putchar() functions with example.
getchar() and putchar()
Both are character I/O functions declared in <stdio.h>.
getchar()
Reads a single character from the standard input (keyboard) and returns it as an int.
Syntax: ch = getchar();
putchar()
Writes a single character to the standard output (screen).
Syntax: putchar(ch);
Example
#include <stdio.h>
int main() {
char ch;
printf("Enter a character: ");
ch = getchar(); // read one character
printf("You entered: ");
putchar(ch); // print that character
putchar('\n');
return 0;
}
Sample Output
Enter a character: A
You entered: A
getchar() accepts one character from the user and putchar() displays it. They are simple, fast functions for character-by-character input/output.
Write a program to find the factorial of a number using recursion.
Factorial Using Recursion
The factorial of a non-negative integer is defined recursively as:
A recursive function calls itself with a smaller value until it reaches the base case ( or ).
#include <stdio.h>
long factorial(int n) {
if (n <= 1) // base case
return 1;
return n * factorial(n - 1); // recursive case
}
int main() {
int n;
printf("Enter a number: ");
scanf("%d", &n);
printf("Factorial of %d = %ld\n", n, factorial(n));
return 0;
}
Sample Run
Enter a number: 5
Factorial of 5 = 120
Working: factorial(5) = 5 * factorial(4) = 54factorial(3) ... = 54321 = 120. The base case stops the recursion.
What is a string? Explain any four built-in string handling functions.
String in C
A string is a one-dimensional array of characters terminated by a null character '\0'. It is used to store text.
Example: char name[] = "CSIT"; stores C S I T \0 (5 bytes).
C provides built-in string-handling functions in the header <string.h>. Four important ones are:
strlen(s)— Returns the length of strings(number of characters, excluding'\0').strlen("hello")→5.strcpy(dest, src)— Copies stringsrcintodest(including'\0').strcpy(t, "abc");makest="abc".strcat(dest, src)— Appends (concatenates)srcto the end ofdest. Ifs1 = "Good",strcat(s1, "Day")→"GoodDay".strcmp(s1, s2)— Compares two strings lexicographically; returns0if equal, a negative value ifs1 < s2, and positive ifs1 > s2.
Example
#include <stdio.h>
#include <string.h>
int main() {
char a[20] = "Hello", b[20] = "World";
printf("Length of a = %lu\n", strlen(a));
strcat(a, b); // a = "HelloWorld"
printf("After concat: %s\n", a);
printf("Compare: %d\n", strcmp("abc", "abc")); // 0
return 0;
}
Differentiate between structure and union with example.
Structure vs Union
A structure (struct) is a user-defined data type that groups related variables of different types under one name; each member gets its own separate memory.
A union groups members of different types under one name, but all members share the same memory location (size = size of the largest member); only one member holds a valid value at a time.
struct S { int i; char c; float f; }; // separate memory for each
union U { int i; char c; float f; }; // all share one memory block
| Basis | Structure | Union |
|---|---|---|
| Keyword | struct | union |
| Memory | Sum of all members' sizes | Size of the largest member |
| Member access | All members usable at once | Only one member at a time |
| Value storage | Each member keeps its own value | Members overwrite each other |
| Use | When all fields are needed together | When only one field is used at a time (saves memory) |
Example
#include <stdio.h>
struct S { int a; char b; };
union U { int a; char b; };
int main() {
printf("struct size = %lu\n", sizeof(struct S)); // e.g. 8 (with padding)
printf("union size = %lu\n", sizeof(union U)); // 4 (largest member)
return 0;
}
In a structure, assigning s.a does not affect s.b; in a union, assigning u.a overwrites u.b because they occupy the same memory.
Explain the relationship between arrays and pointers.
Relationship Between Arrays and Pointers
In C, arrays and pointers are closely related:
-
Array name as pointer: The name of an array acts as a constant pointer to its first element. For
int a[5];, the expressionais equivalent to&a[0]. So*agivesa[0]. -
Pointer arithmetic = indexing: Adding to a pointer moves it by element size. Therefore:
where p = a;. The compiler internally translates a[i] into *(a + i).
-
Passing arrays to functions: When an array is passed to a function, only the address of its first element is passed (it "decays" to a pointer); the function receives a pointer, not a copy of the array.
-
Difference: An array name is a constant address (cannot be reassigned, e.g.
a++is illegal), whereas a pointer is a variable that can be reassigned (p++is valid).
Example
#include <stdio.h>
int main() {
int a[3] = {10, 20, 30};
int *p = a; // p points to a[0]
printf("%d %d\n", a[1], *(p + 1)); // both print 20
printf("%d\n", *(a + 2)); // prints 30 (a[2])
return 0;
}
Thus arrays can be processed using pointer notation and vice versa, but the array name itself is a fixed (non-modifiable) pointer.
Write a program to display the Fibonacci series up to n terms.
Fibonacci Series up to n Terms
In the Fibonacci series each term is the sum of the two preceding terms, starting with 0 and 1:
#include <stdio.h>
int main() {
int n, i;
int t1 = 0, t2 = 1, next;
printf("Enter number of terms: ");
scanf("%d", &n);
printf("Fibonacci series: ");
for (i = 1; i <= n; i++) {
printf("%d ", t1);
next = t1 + t2; // next term
t1 = t2;
t2 = next;
}
printf("\n");
return 0;
}
Sample Run
Enter number of terms: 7
Fibonacci series: 0 1 1 2 3 5 8
Logic: Start with t1 = 0, t2 = 1; in each iteration print t1, compute next = t1 + t2, then shift the window forward (t1 = t2, t2 = next).
Explain the use of #define and #include preprocessor directives.
#define and #include Preprocessor Directives
Preprocessor directives begin with # and are processed by the preprocessor before actual compilation.
#include
Used to insert (copy) the contents of a header file into the program.
#include <stdio.h>— searches the standard system directories (for library headers).#include "myfile.h"— searches the current/user directory first (for user-defined headers). It gives access to library function declarations such asprintf,scanf, etc.
#define
Used to define symbolic constants (macros) and macro functions. The preprocessor replaces every occurrence of the macro name with its value/expansion before compilation.
#define PI 3.14159 // object-like macro (symbolic constant)
#define SQUARE(x) ((x)*(x)) // function-like macro
Usage:
#include <stdio.h>
#define PI 3.14159
#define SQUARE(x) ((x)*(x))
int main() {
printf("Area = %f\n", PI * SQUARE(5)); // PI*25
return 0;
}
Summary: #include brings external file contents into the program, while #define creates constants/macros that are textually substituted, improving readability and easy maintenance.
What is dynamic memory allocation? Explain malloc() and calloc().
Dynamic Memory Allocation (DMA)
Dynamic memory allocation is the process of allocating memory at run time (rather than compile time) from the heap. It allows programs to request exactly as much memory as needed and to resize/free it later, which is useful when the data size is unknown in advance. The functions are declared in <stdlib.h>, and freed using free().
malloc() — Memory Allocation
Allocates a single block of the requested size in bytes and returns a void* pointer to it. The allocated memory is uninitialized (contains garbage). Returns NULL on failure.
int *p = (int *) malloc(5 * sizeof(int)); // block for 5 ints
Syntax: ptr = (type*) malloc(size_in_bytes);
calloc() — Contiguous Allocation
Allocates memory for an array of n elements each of given size and initializes all bytes to zero. Returns NULL on failure.
int *p = (int *) calloc(5, sizeof(int)); // 5 ints, all set to 0
Syntax: ptr = (type*) calloc(n, size_of_each);
Difference
| Basis | malloc() | calloc() |
|---|---|---|
| Arguments | One (total bytes) | Two (count, size) |
| Initialization | Garbage (uninitialized) | All zeros |
| Speed | Slightly faster | Slightly slower (zeroing) |
Memory obtained from either must be released with free(p); to avoid memory leaks.
Frequently asked questions
- Where can I find the BSc CSIT (TU) C Programming (BSc CSIT, CSC115) question paper 2075?
- The full BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2075 (regular) question paper is available free on Kekkei. You can read every question online and attempt the paper under timed exam conditions.
- Does the C Programming (BSc CSIT, CSC115) 2075 paper come with solutions?
- Yes. Every question on this C Programming (BSc CSIT, CSC115) past paper includes a step-by-step solution, plus instant AI feedback when you attempt it on Kekkei.
- How many marks is the BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2075 paper?
- The BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2075 paper carries 60 full marks and is meant to be completed in 180 minutes, across 12 questions.
- Is practising this C Programming (BSc CSIT, CSC115) past paper free?
- Yes — reading and attempting this C Programming (BSc CSIT, CSC115) past paper on Kekkei is completely free.