My assignement is to display in a console a while loop to calculate and display the sum of the numbers from 1 to 100,
This is my code:
// while loop.cpp : main project file.
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"TEST THE WHILE, FOR AND DO...WHILE LOOPS");
return 0;
//A while loop to calculate and display the sum of the numbers from 1 to 100
int i=1;
int sum=0;
while (i < 101)
{
sum += i;
i++;
}
This is the error message I got back and can't seem to figure out what my mistake is.
1>------ Build started: Project: while loop, Configuration: Debug Win32 ------
1>Compiling...
1>while loop.cpp
1>.\while loop.cpp(20) : fatal error C1075: end of file found before the left brace '{' at '.\while loop.cpp(8)' was matched
1>Build log was saved at "file://c:\Users\Marion\Documents\Visual Studio 2008\Projects\while loop\Debug\BuildLog.htm"
1>while loop - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"TEST THE WHILE, FOR AND DO...WHILE LOOPS");
return 0;
int i=1;
int sum=0;
while (i < 101)
{
sum += i;
i++;
}
//No ending brace!