Skip to content

Search

Find a program, subject or material type

CACS401 · Cyber Law and Professional Ethics · Lab Work

Lab 3: Forms and validation

Program with output · 8 pages · Updated Sep 27, 2026

Download

Objective

To understand and practise forms and validation as part of Cyber Law and Professional Ethics.

Theory

Forms and validation is a common task in Cyber Law and Professional Ethics. 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 forms and validation and tested it with sample input.