Im trying my best but I keep gettting this Error. Somebody please Help me. Its error C2447: '{' : missing function header (old-style formal list?)

Im New to C++ I really need Help, Let me know if Im on the right track with my HomeWork Please!!!Write an interactive C++ program that prompts the user for ten (10) real numbers and calculate the sum, average, and prints the result. Hint: you may use an array to store the data.

Program requirements:
- The program must contain a class in which all the required private and public identifiers and the following functions must be defined.
- The program must contain three or more functions using parameters. These functions should read the data, calculate the sum, find the average, and print the results.

CPP / C++ / C Code:
#include "stdafx.h"
#include <iostream>



int _tmain(int argc, _TCHAR* argv[]);


{
{
class real


double n[10],s;
int i;
double avg;
}
public:
real()
{
s=0;
}


void read()
{


for (i=0;i<10;i++)
{
cout<<"Enter a number :";
cin>>n;
}
}


void print()
{
cout<<"The numbers entered are        :"<<endl;
for (i=0;i<10;i++)
{
cout<<n<<endl;
}
}


void sum()
{


for (i=0;i<10;i++)
s=s+n;
}


void average()
{
avg=s/10;
}


void printres()
{
cout<<"Sum        ="<<s<<endl;
cout<<"Average    ="<<avg<<endl;
}

Edited 3 Years Ago by happygeek: fixed formatting

1. Define your class outside main.

2. (From MSDN)
Compiler Error C2447
missing function header (old-style formal list?)

An open curly brace ({) was found at global scope without a corresponding function header.

This error can be caused by using the old-style C-language formal list.

Check that the function being defined has an appropriate function declaration.

The following is an example of this error:

int c;
{}       // error

check this:

int _tmain(int argc, _TCHAR* argv[]);

{
{
class real

try without these lines..... y r u using int _tmain(int argc, _TCHAR* argv[]);
for?

and check brackets on the top part!

n which compiler u r using?

The Complier Ask Me Do I Wan A Percomplier Header? I Using Visual C++ Express Edition

#include "stdafx.h"
#include <iostream>
using namespace std;

Also, add above line. When you attempt to compile, select menu item Build --> Rebuild Solution, this will cause the compiler to generate the precompiled headers that you mentioned. read this if you don't know what precompiled headers are.

This article has been dead for over six months. Start a new discussion instead.