/ src / Focused 2 / f2.cpp
f2.cpp
 1  /*
 2  * FILE : f2.cpp
 3  * PROJECT : SENG1000 - FOCUSED ASSIGNMENT 2
 4  * PROGRAMMER : Tian Yang
 5  * FIRST VERSION : 2024-01-17
 6  * DESCRIPTION :
 7  * Show the result of sum from 1 to 500.
 8  */
 9  
10  #include <stdio.h>
11  
12  int main(int argc, char* argv[])
13  {
14      int sum = 0;
15      int from = 1;
16      int to = 500;
17      while (from <= to)
18      {
19          sum += from;
20          ++from;
21      }
22      printf("%d\n", sum);
23      
24      return 0;
25  }