Write a program in C that calculates the sum   S = 1 + 2 + 3 + ... + 10. Using the For-loop.

******** In Algorithm ********
Algorithm Variables i,S: integers
Begin
S ← 0
for i from 1 to 10
S ← S + i
next
write("the sum 1+2+...+10 =" ,S)
End
Result : ==> the sum 1+2+...+10 = 55

******** In C ********
#include <stdio.h>
int main(){
int i, S=0;
S = 0 ;
for (i=1; i<=10 ; i++){
S = S + i ;
}
printf ("the sum 1+2+...+10 = %d" , S); return 0; }
return 0;
}

******** In C++ ********

#include <iostream> using namespace std; int main(){ int i, S=0; S = 0 ; for (i=1; i<=10 ; i++){ S = S + i ; } cout<<"the sum 1+2+...+10 = "<<S; return 0; }

******** in Python ********

S = 0 for i in range(1,11): S = S + i print("1 +2+...+ 10 =:",S)


******** in JAVA ********

import java.util.Scanner;
class Main {
public static void main(String[] args) {
int i,S=0;
   for (i=1;i<=10;i++) {
        S = S+i;
   }
System.out.print("1+2+..+10 =: "+S);
}
}

********* in C# *******

using System;
public class Ex17 {
public static void Main(string[] args)
{ int i, S=0;
  S = 0  ;
   for (i=1; i<=10 ; i++){
      S = S + i ;
   }
Console.Write(" 1+2+...+10 = "+S);
  }
}