BSc CSIT (TU) Science C Programming (BSc CSIT, CSC115) Question Paper 2074 Nepal
This is the official BSc CSIT (TU) (Science stream) C Programming (BSc CSIT, CSC115) question paper for 2074, 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 2074 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
Discuss the structure of a C program with a suitable example. Explain the compilation and execution process of a C program.
Structure of a C Program
A C program is built from the following sections, in order:
- Documentation section — comments describing the program (
/* ... */or//). - Preprocessor/link section — header file inclusion, e.g.
#include <stdio.h>. - Definition section — symbolic constants/macros, e.g.
#define PI 3.14159. - Global declaration section — global variables and function prototypes.
main()function — the entry point; execution begins here.- User-defined functions — sub-programs called from
main()or other functions.
Example
#include <stdio.h> /* link section */
#define PI 3.14159 /* definition section */
float area(float r); /* global declaration (prototype) */
int main(void) { /* main function */
float r = 5.0;
printf("Area = %.2f\n", area(r));
return 0;
}
float area(float r) { /* user-defined function */
return PI * r * r;
}
Compilation and Execution Process
A C source file (.c) passes through four stages before it can run:
- Preprocessing — the preprocessor expands
#include,#defineand other directives, producing an expanded source (.i). - Compilation — the compiler translates the expanded source into assembly/object code (
.obj/.o) after checking syntax. - Linking — the linker combines the object code with library functions (e.g.
printffrom the standard library) and other object files to produce an executable (.exe/a.out). - Loading and Execution — the loader loads the executable into memory and the CPU executes it, starting from
main().
source.c → [Preprocessor] → source.i → [Compiler] → source.obj
→ [Linker + libraries] → a.out → [Loader] → Output
Using GCC: gcc program.c -o program performs preprocess, compile and link; ./program loads and runs it.
What is a loop? Explain different types of looping statements available in C with syntax, flowchart and examples.
Loop
A loop is a control structure that repeatedly executes a block of statements as long as a given condition remains true. Loops avoid code repetition and are used for iteration. C provides three looping statements.
1. for loop
Used when the number of iterations is known. The control flow checks the condition first (entry-controlled).
Syntax
for (initialization; condition; update) {
// body
}
Flowchart (described): initialization → test condition → if true, execute body → update → back to test; if false, exit.
Example
for (int i = 1; i <= 5; i++)
printf("%d ", i); // 1 2 3 4 5
2. while loop
Entry-controlled; the condition is tested before each iteration. Used when iteration count is not known in advance.
Syntax
while (condition) {
// body
}
Flowchart (described): test condition → if true, execute body → back to test; if false, exit.
Example
int i = 1;
while (i <= 5) { printf("%d ", i); i++; }
3. do-while loop
Exit-controlled; the body executes once before the condition is tested, so it always runs at least once.
Syntax
do {
// body
} while (condition);
Flowchart (described): execute body → test condition → if true, repeat; if false, exit.
Example
int i = 1;
do { printf("%d ", i); i++; } while (i <= 5);
Summary
| Loop | Condition checked | Min. executions |
|---|---|---|
for | before body | 0 |
while | before body | 0 |
do-while | after body | 1 |
Write a program to read N integers into an array and find the largest, smallest and average of the entered numbers.
Program: Largest, Smallest and Average of N Numbers
#include <stdio.h>
int main(void) {
int n, a[100];
int largest, smallest;
long sum = 0;
float average;
printf("Enter how many numbers (N): ");
scanf("%d", &n);
printf("Enter %d integers:\n", n);
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
largest = smallest = a[0]; /* assume first as both */
for (int i = 0; i < n; i++) {
if (a[i] > largest) largest = a[i];
if (a[i] < smallest) smallest = a[i];
sum += a[i];
}
average = (float) sum / n;
printf("Largest = %d\n", largest);
printf("Smallest = %d\n", smallest);
printf("Average = %.2f\n", average);
return 0;
}
How it works
- The numbers are read into the array
ausing aforloop. largestandsmallestare initialized to the first element, then updated while traversing the array.sumaccumulates the total;average = sum / n(cast tofloatfor a fractional result).
Sample Output
Enter how many numbers (N): 5
Enter 5 integers:
12 7 25 3 18
Largest = 25
Smallest = 3
Average = 13.00
Section B: Short Answer Questions
Attempt any EIGHT questions.
List the different types of operators in C and explain any four of them.
Operators in C
C provides the following categories of operators:
- Arithmetic operators —
+ - * / % - Relational operators —
< > <= >= == != - Logical operators —
&& || ! - Assignment operators —
= += -= *= /= %= - Increment/Decrement operators —
++ -- - Bitwise operators —
& | ^ ~ << >> - Conditional (ternary) operator —
?: - Special operators —
sizeof,&(address-of),*(dereference),,(comma)
Explanation of four operators
- Arithmetic operator: performs mathematical operations.
%gives the remainder. e.g.7 % 3→1,7 / 2→3(integer division). - Relational operator: compares two values and yields
1(true) or0(false). e.g.5 > 3→1. - Logical operator: combines conditions.
&&is true only if both operands are true. e.g.(a > 0 && a < 10). - Conditional (ternary) operator:
cond ? expr1 : expr2returnsexpr1ifcondis true elseexpr2. e.g.max = (a > b) ? a : b;.
Differentiate between break and continue statements with examples.
break vs continue
| Feature | break | continue |
|---|---|---|
| Purpose | Terminates the loop/switch entirely | Skips the rest of the current iteration only |
| Effect | Control jumps out of the loop | Control jumps to the next iteration |
| Used in | loops and switch | loops only |
break example
for (int i = 1; i <= 5; i++) {
if (i == 3) break; // loop stops when i == 3
printf("%d ", i); // Output: 1 2
}
continue example
for (int i = 1; i <= 5; i++) {
if (i == 3) continue; // skips printing 3
printf("%d ", i); // Output: 1 2 4 5
}
Summary: break exits the loop completely, whereas continue only skips the remaining statements of the current pass and continues with the next iteration.
Explain formatted input and output functions in C.
Formatted Input and Output in C
Formatted I/O uses format specifiers to control how data is read or displayed, allowing precise type and width control.
Formatted Output — printf()
Writes formatted data to the standard output.
printf("format string", arg1, arg2, ...);
Example:
int n = 42; float x = 3.14159;
printf("n = %d, x = %.2f\n", n, x); // n = 42, x = 3.14
Formatted Input — scanf()
Reads formatted data from the standard input into variables (which must be passed by address using &).
scanf("format string", &var1, &var2, ...);
Example:
int age; float salary;
scanf("%d %f", &age, &salary);
Common format specifiers
| Specifier | Data type |
|---|---|
%d | int |
%f | float |
%lf | double |
%c | char |
%s | string |
%x | hexadecimal |
Width/precision can be added, e.g. %6.2f prints a float in a field of 6 with 2 decimals.
What is a function? Explain the advantages of using functions in a program.
Function
A function is a self-contained, named block of code that performs a specific task. A program can call a function whenever that task is needed. C has library functions (e.g. printf) and user-defined functions, each having a prototype (declaration), definition and call.
int add(int a, int b) { // definition
return a + b;
}
// call: result = add(3, 4);
Advantages of using functions
- Modularity / divide-and-conquer: a large problem is split into smaller, manageable sub-tasks.
- Code reusability: a function written once can be called many times, avoiding repetition.
- Easier debugging and maintenance: errors are localized to individual functions.
- Reduced program size: repeated code is replaced by a single function and its calls.
- Readability: programs become well-organized and easier to understand.
- Reusability across programs: functions can be placed in libraries and shared.
Write a program to check whether a given number is prime or not.
Program: Check Whether a Number is Prime
A prime number is a natural number greater than 1 having exactly two divisors: 1 and itself.
#include <stdio.h>
int main(void) {
int n, isPrime = 1; /* assume prime */
printf("Enter a number: ");
scanf("%d", &n);
if (n <= 1) {
isPrime = 0; /* 0,1 and negatives are not prime */
} else {
for (int i = 2; i <= n / 2; i++) {
if (n % i == 0) { /* divisible -> not prime */
isPrime = 0;
break;
}
}
}
if (isPrime)
printf("%d is a prime number.\n", n);
else
printf("%d is not a prime number.\n", n);
return 0;
}
Logic
- Numbers
<= 1are not prime. - Otherwise, test divisibility from
2up ton/2(orsqrt(n)for efficiency). If any divisor dividesnexactly, it is not prime.
Sample Output
Enter a number: 17
17 is a prime number.
Differentiate between while and do-while loops with examples.
while vs do-while
| Feature | while loop | do-while loop |
|---|---|---|
| Type | Entry-controlled | Exit-controlled |
| Condition tested | Before executing the body | After executing the body |
| Minimum executions | 0 (may not run at all) | 1 (always runs once) |
| Syntax ending | no semicolon after block | ends with ; after while(...) |
while example
int i = 5;
while (i < 5) { // condition false -> body never runs
printf("%d ", i);
i++;
} // Output: (nothing)
do-while example
int i = 5;
do { // body runs once before test
printf("%d ", i);
i++;
} while (i < 5); // Output: 5
Summary: A while loop checks the condition first and may execute zero times, whereas a do-while loop executes its body at least once because the condition is checked at the end.
Explain the concept of an array with example. How is a one-dimensional array declared and initialized?
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; each element is accessed using an index (subscript) starting from 0. Arrays let us handle many related values with a single name.
One-Dimensional Array
Declaration
data_type array_name[size];
int marks[5]; /* an array of 5 integers */
Initialization
int marks[5] = {90, 85, 70, 60, 95}; /* full initialization */
int a[5] = {1, 2}; /* rest set to 0 */
int b[] = {10, 20, 30}; /* size inferred = 3 */
Accessing elements (indices 0 to size-1):
printf("%d", marks[0]); // first element = 90
marks[2] = 75; // modify third element
Example
int a[3] = {5, 10, 15};
int sum = 0;
for (int i = 0; i < 3; i++)
sum += a[i]; // sum = 30
Here marks[0] is the first element and marks[4] the last; valid indices range from 0 to 4.
What is a pointer? Explain how a pointer variable is declared and initialized.
Pointer
A pointer is a variable that stores the memory address of another variable. Through a pointer we can indirectly access and modify the value stored at that address. Pointers enable dynamic memory allocation, efficient array/string handling, call-by-reference and building data structures.
Declaration
data_type *pointer_name;
int *p; /* p can hold the address of an int */
The * indicates that the variable is a pointer; its base type must match the variable it points to.
Initialization
A pointer is initialized with the address of a variable using the address-of operator &:
int x = 10;
int *p;
p = &x; /* p now holds the address of x */
Can also be combined: int *p = &x;.
Accessing the value
The dereference (indirection) operator * accesses the value at the stored address:
printf("%d", *p); // prints 10 (value of x)
*p = 20; // changes x to 20
A pointer that points to nothing should be set to NULL: int *p = NULL;.
Write short notes on storage classes in C.
Storage Classes in C
A storage class specifies the scope (visibility), lifetime (duration), default initial value and storage location of a variable. C provides four storage classes:
1. auto
- Default for local variables inside a function/block.
- Scope: local to the block. Lifetime: until the block ends. Stored in: memory (stack). Default value: garbage.
auto int x; // same as: int x;
2. register
- Requests the variable be stored in a CPU register for fast access (compiler may ignore).
- Scope: local. Lifetime: block. Default value: garbage. The
&operator cannot be applied.
register int counter;
3. static
- Retains its value between function calls; initialized only once.
- Scope: local (or file scope for globals). Lifetime: entire program. Stored in: memory. Default value: 0.
static int count = 0; // keeps its value across calls
4. extern
- Declares a global variable defined elsewhere (in another file or later in the same file); used to share variables across files.
- Scope: global. Lifetime: entire program. Default value: 0.
extern int total; // defined in another file
Summary
| Class | Scope | Lifetime | Default | Storage |
|---|---|---|---|---|
| auto | block | block | garbage | stack |
| register | block | block | garbage | register |
| static | block/file | program | 0 | memory |
| extern | global | program | 0 | memory |
Frequently asked questions
- Where can I find the BSc CSIT (TU) C Programming (BSc CSIT, CSC115) question paper 2074?
- The full BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2074 (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) 2074 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) 2074 paper?
- The BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2074 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.