Skip to content

Search

Find a program, subject or material type

CACS255 · Database Management System · Lab Work

Lab 4: Functions and arrays

Program with output · 5 pages · Updated May 23, 2026

Download

Objective

To understand and practise functions and arrays as part of Database Management System.

Theory

Functions and arrays is a common task in Database Management System. The program below shows the idea step by step with simple input and clear output.

Program

#include <stdio.h>

int main() {
    int n, i, sum = 0;
    printf("Enter a number: ");
    scanf("%d", &n);

    for (i = 1; i <= n; i++) {
        sum += i;
    }

    printf("Sum of 1 to %d = %d\n", n, sum);
    return 0;
}

Output

Enter a number: 5
Sum of 1 to 5 = 15

Conclusion

In this lab we learned functions and arrays and tested it with sample input.