Lab 1: Sorting and searching CACS155 · Microprocessor and Computer Architecture · BCA Semester 2 ============================ OBJECTIVE To understand and practise sorting and searching as part of Microprocessor and Computer Architecture. THEORY Sorting and searching is a common task in Microprocessor and Computer Architecture. The program below shows the idea step by step with simple input and clear output. PROGRAM #include 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 sorting and searching and tested it with sample input. Downloaded from BCA Sansar — free study materials for Nepali students.