Browse papers
A

Section A: Long Answer Questions

Attempt any TWO questions.

3 questions·10 marks each
1long10 marks

What is an operator? Explain arithmetic, relational, logical and bitwise operators with examples.

Operator

An operator is a symbol that tells the compiler to perform a specific mathematical, logical or other operation on one or more operands. C is rich in operators; they form the building blocks of expressions.

1. Arithmetic Operators

Used to perform basic mathematical calculations.

OperatorMeaningExample (a=10, b=3)
+Additiona+b → 13
-Subtractiona-b → 7
*Multiplicationa*b → 30
/Division (integer)a/b → 3
%Modulus (remainder)a%b → 1
int a = 10, b = 3;
printf("%d %d", a / b, a % b);  // 3 1

2. Relational Operators

Compare two operands and return 1 (true) or 0 (false).

OperatorMeaningExample
<Less thana < b → 0
>Greater thana > b → 1
<=Less or equala <= b → 0
>=Greater or equala >= b → 1
==Equal toa == b → 0
!=Not equala != b → 1

3. Logical Operators

Combine relational expressions; result is 1 or 0.

OperatorMeaningExample (x=5)
&&Logical AND(x>0 && x<10) → 1
||Logical OR(x<0 || x>3) → 1
!Logical NOT!(x>0) → 0
if (age >= 18 && citizen == 1)
    printf("Eligible to vote");

4. Bitwise Operators

Operate on individual bits of integer operands.

OperatorMeaningExample (a=12=1100, b=10=1010)
&Bitwise ANDa & b = 1000 = 8
|Bitwise ORa | b = 1110 = 14
^Bitwise XORa ^ b = 0110 = 6
~One's complement~a = -13
<<Left shifta << 1 = 24
>>Right shifta >> 1 = 6
int a = 12, b = 10;
printf("%d %d %d", a & b, a | b, a ^ b);  // 8 14 6

These four categories let C express both numeric computation and low-level hardware manipulation in a compact way.

operators
2long10 marks

Explain the different types of looping statements with syntax and example. Write a program to check whether a number is an Armstrong number.

Looping Statements in C

A loop repeatedly executes a block of statements as long as a condition remains true. C provides three loop constructs.

1. while loop (entry-controlled)

The condition is tested before the body executes; body may run zero times.

while (condition) {
    // body
}
int i = 1;
while (i <= 5) { printf("%d ", i); i++; }   // 1 2 3 4 5

2. do...while loop (exit-controlled)

The body executes once first, then the condition is tested; body runs at least once.

do {
    // body
} while (condition);
int i = 1;
do { printf("%d ", i); i++; } while (i <= 5);  // 1 2 3 4 5

3. for loop (entry-controlled, compact)

Initialization, condition and update are written in one line.

for (init; condition; update) {
    // body
}
for (int i = 1; i <= 5; i++) printf("%d ", i);  // 1 2 3 4 5

Key difference: while and for test the condition first (may run 0 times); do...while runs at least once.

Program: Check Armstrong Number

An Armstrong number equals the sum of its own digits each raised to the power of the number of digits (e.g. 153=13+53+33153 = 1^3 + 5^3 + 3^3).

#include <stdio.h>
#include <math.h>

int main() {
    int num, temp, rem, sum = 0, digits = 0;
    printf("Enter a number: ");
    scanf("%d", &num);

    temp = num;
    while (temp != 0) { digits++; temp /= 10; }   // count digits

    temp = num;
    while (temp != 0) {
        rem = temp % 10;
        sum += (int)pow(rem, digits);
        temp /= 10;
    }

    if (sum == num)
        printf("%d is an Armstrong number\n", num);
    else
        printf("%d is not an Armstrong number\n", num);
    return 0;
}

Sample run: input 153 → output 153 is an Armstrong number.

loops
3long10 marks

What is a pointer? Explain pointer to pointer, pointer to array and pointer to function with examples.

Pointer

A pointer is a variable that stores the memory address of another variable. It is declared with * and dereferenced with * to access the pointed value.

int a = 10;
int *p = &a;          // p holds address of a
printf("%d", *p);     // 10

1. Pointer to Pointer

A pointer that stores the address of another pointer (double indirection, declared with **).

int a = 5;
int *p = &a;
int **pp = &p;
printf("%d %d %d", a, *p, **pp);   // 5 5 5

Here pp → p → a; **pp reaches the value 5.

2. Pointer to Array

A pointer can point to the elements of an array. The array name itself is the address of the first element, so pointer arithmetic walks through it.

int arr[5] = {10, 20, 30, 40, 50};
int *p = arr;            // same as &arr[0]
for (int i = 0; i < 5; i++)
    printf("%d ", *(p + i));   // 10 20 30 40 50

*(p+i) is equivalent to arr[i].

3. Pointer to Function

A pointer that stores the address of a function, allowing the function to be called indirectly (useful for callbacks).

#include <stdio.h>
int add(int a, int b) { return a + b; }

int main() {
    int (*fp)(int, int) = add;   // function pointer
    printf("%d", fp(3, 4));      // calls add → 7
    return 0;
}

The declaration int (*fp)(int,int) means fp is a pointer to a function taking two ints and returning int.

Summary: pointers give C direct, efficient access to memory, enabling dynamic data structures, pass-by-reference, and flexible array/function handling.

pointers
B

Section B: Short Answer Questions

Attempt any EIGHT questions.

9 questions·5 marks each
4short5 marks

Explain the steps involved in creating and running a C program.

Steps to Create and Run a C Program

Four main phases transform source code into a running program:

  1. Editing (Writing source code): Type the program in a text editor / IDE and save it with a .c extension (e.g. hello.c). This human-readable file is the source code.

  2. Preprocessing: The preprocessor handles directives starting with # (e.g. #include, #define) — it expands header files and macros, producing an expanded source file.

  3. Compilation: The compiler translates the expanded source into object code (machine-level .obj/.o file) and reports syntax/semantic errors. If errors exist, return to step 1.

  4. Linking: The linker joins the object code with required library functions (e.g. printf from the C standard library) and other object files to create an executable file (.exe / a.out).

  5. Execution / Running: The loader loads the executable into memory and the CPU runs it; the program produces output. Runtime/logical errors found here send you back to editing.

hello.c → [Preprocessor] → [Compiler] → object → [Linker] → executable → [Run] → output

Example with GCC: gcc hello.c -o hello then ./hello.

program-structure
5short5 marks

Differentiate between local and global variables.

Local vs Global Variables

FeatureLocal VariableGlobal Variable
DeclarationDeclared inside a function/blockDeclared outside all functions
ScopeAccessible only within that function/blockAccessible by all functions in the file
LifetimeCreated on function entry, destroyed on exitExists for the entire program run
StorageStored on the stack (auto by default)Stored in the global/data segment
Default valueGarbage (uninitialized)Zero if not initialized
AccessCannot be used outside its functionShared, so can be modified anywhere
#include <stdio.h>
int g = 100;            // global

void show() {
    int x = 5;          // local to show()
    printf("%d %d\n", x, g);
}
int main() {
    show();             // 5 100
    // printf("%d", x); // ERROR: x not visible here
    return 0;
}

Key point: Local variables promote modularity and avoid name clashes; global variables allow data sharing but should be used sparingly to reduce unwanted side-effects.

scope
6short5 marks

Write a program to reverse a given number.

Program: Reverse a Given Number

The number is reversed by repeatedly extracting the last digit with % 10, appending it to the result (rev = rev*10 + digit), and removing it with / 10.

#include <stdio.h>

int main() {
    int num, rem, rev = 0;
    printf("Enter a number: ");
    scanf("%d", &num);

    while (num != 0) {
        rem = num % 10;       // extract last digit
        rev = rev * 10 + rem; // build reversed number
        num = num / 10;       // remove last digit
    }

    printf("Reversed number = %d\n", rev);
    return 0;
}

Sample run:

Enter a number: 1234
Reversed number = 4321

Trace (for 1234): rem/rev pairs → 4/4 → 3/43 → 2/432 → 1/4321.

loops
7short5 marks

What is a string? Explain strlen(), strcpy(), strcat() and strcmp().

String

A string in C is a one-dimensional array of characters terminated by the null character '\0'. The null marks the end of the string.

char name[] = "Ram";   // stored as: R a m \0

C has no separate string type; string library functions are declared in <string.h>.

String Library Functions

1. strlen(str) — returns the length (number of characters before '\0', excluding it).

strlen("Hello");   // 5

2. strcpy(dest, src)copies the source string (including '\0') into the destination.

char d[20];
strcpy(d, "World");   // d = "World"

3. strcat(dest, src)concatenates (appends) src to the end of dest.

char s[20] = "Hello ";
strcat(s, "World");   // s = "Hello World"

4. strcmp(s1, s2)compares two strings lexicographically. Returns 0 if equal, a negative value if s1 < s2, and a positive value if s1 > s2.

strcmp("abc", "abc");  // 0
strcmp("abc", "abd");  // negative
#include <stdio.h>
#include <string.h>
int main() {
    char a[20] = "Hello ", b[] = "CSIT";
    printf("%d\n", (int)strlen(b));  // 4
    strcat(a, b);
    printf("%s\n", a);               // Hello CSIT
    printf("%d\n", strcmp("a","a")); // 0
    return 0;
}
strings
8short5 marks

Explain the difference between structure and array.

Structure vs Array

FeatureArrayStructure
DefinitionCollection of elements of the same data typeCollection of elements of different (or same) data types
KeywordNo special keyword (int a[10];)Defined using struct
Data typeHomogeneousHeterogeneous
Element accessBy index: a[i]By member name using . : s.name
MemoryElements stored in contiguous locationsMembers stored together but may include padding
UseStore a list of similar items (marks, names)Group related but different attributes of one entity
// Array – same type
int marks[3] = {80, 90, 75};
printf("%d", marks[1]);      // 90

// Structure – different types
struct Student {
    char name[20];
    int roll;
    float gpa;
};
struct Student s = {"Ram", 5, 3.6};
printf("%s %.1f", s.name, s.gpa);   // Ram 3.6

Key point: an array groups many values of one type, whereas a structure groups several related values of possibly different types into a single record.

structures
9short5 marks

Write a program to find the largest element of an array.

Program: Find the Largest Element of an Array

Assume the first element is the largest, then scan the rest and update whenever a bigger element is found.

#include <stdio.h>

int main() {
    int arr[100], n, i, max;
    printf("Enter number of elements: ");
    scanf("%d", &n);

    printf("Enter %d elements: ", n);
    for (i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    max = arr[0];                 // assume first is largest
    for (i = 1; i < n; i++) {
        if (arr[i] > max)
            max = arr[i];         // update if bigger found
    }

    printf("Largest element = %d\n", max);
    return 0;
}

Sample run:

Enter number of elements: 5
Enter 5 elements: 12 45 7 89 23
Largest element = 89
arrays
10short5 marks

Explain the static and register storage classes.

Static and Register Storage Classes

A storage class defines the scope, lifetime, default value and storage location of a variable.

1. static Storage Class

  • Keyword: static
  • Storage: memory (data segment), not the stack.
  • Lifetime: the entire program — the variable retains its value between function calls.
  • Scope: local to the block/function (or, for a global static, limited to that file).
  • Default value: zero.
void counter() {
    static int c = 0;   // initialized only once
    c++;
    printf("%d ", c);
}
// calling counter() three times prints: 1 2 3

The value of c persists across calls instead of being re-created.

2. register Storage Class

  • Keyword: register
  • Storage: suggests the variable be kept in a CPU register instead of RAM for faster access (the compiler may ignore the hint).
  • Lifetime: within the block/function (like auto).
  • Scope: local to the block.
  • Default value: garbage (uninitialized).
  • Restriction: the address (&) of a register variable cannot be taken, since it may not have a memory address.
void loop() {
    register int i;          // fast loop counter
    for (i = 0; i < 1000; i++) { /* ... */ }
}

Summary: static extends a variable's lifetime and preserves its value; register is a speed optimization request for frequently used variables.

storage-class
11short5 marks

What is a command line argument? Explain with example.

Command Line Arguments

Command line arguments are values passed to a program from the command line / terminal at the time of execution, received through the parameters of main().

int main(int argc, char *argv[])
  • argc (argument count): number of arguments passed, including the program name.
  • argv (argument vector): array of strings holding the arguments; argv[0] is the program name, argv[1], argv[2], … are the user-supplied arguments.

Example

#include <stdio.h>
int main(int argc, char *argv[]) {
    printf("Number of arguments = %d\n", argc);
    for (int i = 0; i < argc; i++)
        printf("argv[%d] = %s\n", i, argv[i]);
    return 0;
}

Running:

$ ./myprog Hello CSIT
Number of arguments = 3
argv[0] = ./myprog
argv[1] = Hello
argv[2] = CSIT

Use: lets users supply input (filenames, options, values) without modifying or recompiling the source code. Note that all arguments are received as strings; convert them with atoi()/atof() if numbers are needed.

functions
12short5 marks

Write short notes on typedef.

Short Note on typedef

typedef is a keyword used to create a new name (alias) for an existing data type. It does not create a new type — it improves readability and portability of code.

Syntax:

typedef existing_type new_name;

Examples

1. Simple alias

typedef unsigned int uint;
uint a = 10;        // same as unsigned int a = 10;

2. With structures (avoids repeating the struct keyword)

typedef struct {
    char name[20];
    int roll;
} Student;

Student s1;         // instead of: struct Student s1;

3. With pointers / arrays

typedef char* String;
String msg = "Hello";   // char *msg = "Hello";

Advantages

  • Makes complex declarations shorter and clearer.
  • Improves portability — change one typedef to alter the type everywhere (e.g. typedef float REAL;).
  • Enhances readability of code using structures and pointers.
data-types

Frequently asked questions

Where can I find the BSc CSIT (TU) C Programming (BSc CSIT, CSC115) question paper 2079?
The full BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2079 (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) 2079 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) 2079 paper?
The BSc CSIT (TU) C Programming (BSc CSIT, CSC115) 2079 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.