Originally answered in Quora!. My most viewed answer. (Almost 57k+ views!!) Click to view post.

Algorithm

  1. Start

  2. Declare a variable of type int i = 0 and sum = 0

  3. Iteration, iterate variable i in a loop from 1 to 50. On each iteration increment i by 1 and add i

    for i = 1 and i <= 50
    {
        sum = sum + i
        increment i = i + 1
    }
    
  4. Print Sum

  5. Stop

C++ Syntax

#include<iostream.h>
using namespace std

int main()
{
    int i,sum=0;
    for(i=1;i<=50;++i) // for loop to iterate upto 50
    {
        sum += i; //sum = sum + i (C++ Shorthands)
    }
    cout<<"Sum of first 50 numbers : "<<sum;
    return 0;
}

Cheers!

Pic Credits: Photo by Aperture Vintage