// Program to output the sum of first 'n' numbers // Header file #include // Function Prototype int SumOfNnumbers (int num); // Main function int main (void) { int num; // Variable Declaration // Read the number 'n' from the user cout << "Input a number: "; cin >> num; // Compute and print the sum of first n numbers cout << "Sum of first " << num << " numbers: " << SumOfNnumbers(num) << endl; // return success return 0; } // Function Definition of SumOfNnumbers int SumOfNnumbers (int num) { // local variable declaration int n; int sum = 0; // statements for (n = 1; n <= num; n++) sum = sum + n; // return result return sum; }