BSc CSIT (TU) Science C Programming (BSc CSIT, CSC115) Question Paper 2077 Nepal
This is the official BSc CSIT (TU) (Science stream) C Programming (BSc CSIT, CSC115) question paper for 2077, 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 2077 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
List different types of operators available in C and explain any four of them with examples.
Operators in C
An operator is a symbol that tells the compiler to perform a specific mathematical, logical or relational operation on operands. C provides a rich set of operators classified as follows:
- Arithmetic operators —
+,-,*,/,% - Relational operators —
<,>,<=,>=,==,!= - Logical operators —
&&,||,! - Assignment operators —
=,+=,-=,*=,/=,%= - Increment/Decrement operators —
++,-- - Bitwise operators —
&,|,^,~,<<,>> - Conditional (ternary) operator —
?: - Special operators —
sizeof,&(address-of),*(dereference),,(comma),.and->(member access)
Explanation of four operators with examples
1. Arithmetic operators
Used for basic mathematical calculations. The % (modulus) operator gives the remainder and works only on integers.
int a = 10, b = 3;
printf("%d %d %d", a + b, a / b, a % b); // 13 3 1
2. Relational operators
Compare two operands and return 1 (true) or 0 (false).
int a = 5, b = 8;
printf("%d", a < b); // 1 (true)
printf("%d", a == b); // 0 (false)
3. Logical operators
Combine relational expressions. && is true only if both operands are true; || is true if at least one is true; ! negates.
int age = 20;
if (age >= 18 && age <= 60)
printf("Eligible"); // both conditions true
4. Increment/Decrement operators
++ increases a value by 1, -- decreases by 1. In pre form the value changes before use; in post form after use.
int x = 5;
printf("%d ", x++); // prints 5, then x becomes 6
printf("%d", ++x); // x becomes 7, then prints 7
Thus operators form the core of expressions and control how data is manipulated in a C program.
What is recursion? Explain with a suitable example. Write a program to compute the GCD of two numbers using recursion.
Recursion
Recursion is a programming technique in which a function calls itself directly or indirectly to solve a problem by breaking it into smaller sub-problems of the same type. A recursive function must have:
- a base case that stops the recursion, and
- a recursive case that calls the function with a smaller/simpler argument moving toward the base case.
Example — Factorial
int factorial(int n) {
if (n == 0) // base case
return 1;
return n * factorial(n - 1); // recursive case
}
For factorial(3): 3*factorial(2) = 3*2*factorial(1) = 3*2*1*factorial(0) = 3*2*1*1 = 6.
GCD of two numbers using recursion
Uses the Euclidean algorithm: , with .
#include <stdio.h>
int gcd(int a, int b) {
if (b == 0) // base case
return a;
return gcd(b, a % b); // recursive case
}
int main() {
int x, y;
printf("Enter two numbers: ");
scanf("%d %d", &x, &y);
printf("GCD of %d and %d = %d\n", x, y, gcd(x, y));
return 0;
}
Sample run: input 36 24 → GCD of 36 and 24 = 12.
Define a structure. Create a structure STUDENT with members SID, name, address and CGPA, and write a program to read and display the records of 100 students.
Structure
A structure is a user-defined data type in C that groups together logically related variables (members) of different data types under a single name. It is declared using the struct keyword and lets us treat a collection of heterogeneous data as one unit.
struct STUDENT {
int SID;
char name[50];
char address[50];
float CGPA;
};
Program to read and display 100 student records
#include <stdio.h>
struct STUDENT {
int SID;
char name[50];
char address[50];
float CGPA;
};
int main() {
struct STUDENT s[100];
int i;
// Reading records
for (i = 0; i < 100; i++) {
printf("\nEnter details of student %d\n", i + 1);
printf("SID: "); scanf("%d", &s[i].SID);
printf("Name: "); scanf("%s", s[i].name);
printf("Address: "); scanf("%s", s[i].address);
printf("CGPA: "); scanf("%f", &s[i].CGPA);
}
// Displaying records
printf("\n%-6s %-15s %-15s %-6s\n", "SID", "Name", "Address", "CGPA");
for (i = 0; i < 100; i++) {
printf("%-6d %-15s %-15s %-6.2f\n",
s[i].SID, s[i].name, s[i].address, s[i].CGPA);
}
return 0;
}
Here an array of structures s[100] stores 100 records, each member accessed using the dot (.) operator.
Section B: Short Answer Questions
Attempt any EIGHT questions.
Explain the basic structure of a C program.
Basic Structure of a C Program
A C program is generally organized into the following sections:
- Documentation section — comments describing the program (
/* ... */or//). - Preprocessor / Link section —
#includeheader files and#definemacros, e.g.#include <stdio.h>. - Global declaration section — global variables and function prototypes declared outside
main(). main()function — execution always begins here; contains declarations and statements enclosed in{ }.- Sub-program / user-defined functions — definitions of other functions called from
main().
#include <stdio.h> // Preprocessor section
#define PI 3.1416 // Macro definition
int square(int n); // Global declaration (prototype)
int main() { // main function
int x = 5;
printf("%d", square(x));
return 0;
}
int square(int n) { // User-defined function
return n * n;
}
Every executable statement ends with a semicolon, and main() returns an integer status to the operating system.
Describe different formatted input and output functions in C.
Formatted Input and Output Functions in C
Formatted I/O functions transfer data in a specified format using format specifiers (e.g. %d, %f, %c, %s). They are declared in <stdio.h>.
Formatted Output — printf()
Sends formatted data to the standard output (screen).
printf("control string", arg1, arg2, ...);
printf("Sum = %d, Avg = %.2f", 30, 12.5); // Sum = 30, Avg = 12.50
Formatted Input — scanf()
Reads formatted data from the keyboard and stores it at the addresses (&var) of the variables.
scanf("control string", &arg1, &arg2, ...);
scanf("%d %f", &n, &x);
Common format specifiers
| Specifier | Used for |
|---|---|
%d / %i | integer |
%f | float |
%lf | double |
%c | single character |
%s | string |
%x / %o | hexadecimal / octal |
Related functions sprintf() and sscanf() perform the same formatted operations on a string buffer instead of the console. Field width and precision (e.g. %5d, %6.2f) can be used to control alignment and decimal places.
Write a program to display the first 50 prime numbers.
Program to Display the First 50 Prime Numbers
A prime number is a natural number greater than 1 having exactly two divisors: 1 and itself. We test each number for divisibility and keep counting until 50 primes are found.
#include <stdio.h>
int main() {
int count = 0, num = 2, i, isPrime;
printf("First 50 prime numbers:\n");
while (count < 50) {
isPrime = 1;
for (i = 2; i <= num / 2; i++) {
if (num % i == 0) { // divisible -> not prime
isPrime = 0;
break;
}
}
if (isPrime) {
printf("%d ", num);
count++;
}
num++;
}
printf("\n");
return 0;
}
Output (first few): 2 3 5 7 11 13 17 19 23 29 ... up to the 50th prime, which is 229.
Demonstrate the use of a recursive function with a suitable example.
Use of a Recursive Function
A recursive function is one that calls itself to solve a problem in terms of smaller instances of the same problem. It needs a base case (to terminate) and a recursive case (to progress toward the base case).
Example — Sum of first n natural numbers
#include <stdio.h>
int sum(int n) {
if (n == 0) // base case
return 0;
return n + sum(n - 1); // recursive case
}
int main() {
int n = 5;
printf("Sum of first %d numbers = %d", n, sum(n));
return 0;
}
Working of sum(5): 5+sum(4) → 5+4+sum(3) → ... → 5+4+3+2+1+0 = 15.
The call stack grows with each call and unwinds when the base case is reached, producing the result 15.
What are the characteristics of an array?
Characteristics of an Array
An array is a collection of elements of the same data type stored in contiguous memory locations and referred to by a common name. Its key characteristics are:
- Homogeneous elements — all elements are of the same data type (e.g. all
intor allfloat). - Contiguous memory — elements are stored in adjacent memory locations, allowing fast indexed access.
- Fixed size — the size is fixed at declaration time and cannot grow or shrink during execution (for static arrays).
- Zero-based indexing — elements are accessed using an index starting from
0ton-1, e.g.a[0],a[1]. - Random access — any element can be accessed directly in time using its index.
- Common name — a single identifier refers to the whole collection; the array name represents the base address.
int marks[5] = {80, 75, 90, 65, 88}; // marks[0] .. marks[4]
Differentiate between actual and formal arguments.
Actual vs Formal Arguments
Actual arguments are the values or variables passed to a function in the function call, whereas formal arguments are the variables declared in the function definition/header that receive those values.
| Actual Arguments | Formal Arguments |
|---|---|
| Appear in the function call. | Appear in the function definition (header). |
| Also called actual parameters. | Also called formal parameters or dummy parameters. |
| Hold the actual data passed. | Receive a copy of (or reference to) that data. |
| Need not have data types written. | Must be declared with their data types. |
| Their scope is the calling function. | Their scope is limited to the called function. |
int add(int x, int y) { // x, y -> formal arguments
return x + y;
}
int main() {
int a = 5, b = 3;
int s = add(a, b); // a, b -> actual arguments
printf("%d", s); // 8
return 0;
}
In call-by-value, the formal arguments get separate copies, so changing them does not affect the actual arguments.
Explain file handling in C. List the modes of opening a file.
File Handling in C
File handling allows a program to store data permanently on secondary storage (disk) and to read it back later, so that data is not lost when the program ends. C uses a pointer of type FILE (defined in <stdio.h>) to work with files.
Steps in file handling
- Declare a file pointer:
FILE *fp; - Open the file:
fp = fopen("data.txt", "r"); - Process (read/write) using
fscanf,fprintf,fgetc,fputc,fread,fwrite, etc. - Close the file:
fclose(fp);
FILE *fp = fopen("data.txt", "w");
if (fp == NULL) { printf("Cannot open file"); return 1; }
fprintf(fp, "Hello File\n");
fclose(fp);
Modes of opening a file
| Mode | Meaning |
|---|---|
"r" | Open for reading (file must exist). |
"w" | Open for writing (creates new / overwrites existing). |
"a" | Open for appending at end of file. |
"r+" | Open for both reading and writing (file must exist). |
"w+" | Read and write (creates new / truncates existing). |
"a+" | Read and append. |
Appending b (e.g. "rb", "wb") opens the file in binary mode.
Write a program to swap two values using call by reference.
Swapping Two Values Using Call by Reference
In call by reference, the addresses of the variables are passed to the function. Using pointers, the function operates directly on the original variables, so changes made inside it are reflected in the caller.
#include <stdio.h>
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int main() {
int x = 10, y = 20;
printf("Before swap: x = %d, y = %d\n", x, y);
swap(&x, &y); // pass addresses
printf("After swap: x = %d, y = %d\n", x, y);
return 0;
}
Output:
Before swap: x = 10, y = 20
After swap: x = 20, y = 10
Because swap() receives the addresses &x and &y and dereferences them (*a, *b), the original variables are exchanged.
Write short notes on the ternary (conditional) operator.
Ternary (Conditional) Operator
The ternary operator ?: is the only operator in C that takes three operands. It provides a compact way to write a simple if-else decision in a single expression.
Syntax:
expression1 ? expression2 : expression3;
expression1is evaluated first (the condition).- If it is true (non-zero), the whole expression takes the value of
expression2. - If it is false (0), it takes the value of
expression3.
Example — finding the larger of two numbers:
int a = 10, b = 20;
int max = (a > b) ? a : b;
printf("Largest = %d", max); // Largest = 20
Equivalent if-else:
if (a > b) max = a; else max = b;
It makes code concise and can be nested, e.g. checking even/odd: printf("%s", (n % 2 == 0) ? "Even" : "Odd");. Excessive nesting, however, reduces readability.
Frequently asked questions
- Where can I find the BSc CSIT (TU) C Programming (BSc CSIT, CSC115) question paper 2077?
- The full BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2077 (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) 2077 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) 2077 paper?
- The BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2077 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.