3 Replies - 242 Views - Last Post: 20 April 2013 - 10:25 AM Rate Topic: -----

#1 saimjarwar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-April 13

I have an error- error C2447: '{' : missing function header (o

Posted 19 April 2013 - 01:10 PM

#include<iostream>
using namespace std;
void fn(int n);
void main()
{
int n;
cout<<"Enter a number"<<endl;
cin>>n;
cout<<"Nature of number"<<endl;
cout<<"....................."<<endl;
fn(n);
}
void fn(int n);
{
int c=0;
for(int i=2;i<n;i++)
{
	if(n%i==0)
		c=1;
}
if(n%2==0 && c==0)
	cout<<n<<"is a prime even number"<<endl;
else if(n%2!==0 && c==0)
	cout<<n<<"is a odd prime number"<<endl;
else if(n%2==0 && c!==0)
	cout<<n<<"is only even number not prime"<<endl;
else if(n%2!==0)
	cout<<n<<"is a  only odd number,not prime "<<endl;
else 
	cout<<"is not a prime number"<<endl;
}


Mod edit - Please :code:

Is This A Good Question/Topic? 0
  • +

Replies To: I have an error- error C2447: '{' : missing function header (o

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1201
  • View blog
  • Posts: 7,309
  • Joined: 07-September 06

Re: I have an error- error C2447: '{' : missing function header (o

Posted 19 April 2013 - 01:42 PM

The simple answer:
You have a semicolon at the end of line 13 that isn't supposed to be there.

Also of note is that void main is bad practice, and instead it should be int main.

In the future it is nice if you post your code in the :code: tags, makes things significantly easier to read. Also, some indication as to what the problem is (such as the error messages you are getting) will make debugging a lot easier.

Hope that helps.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3835
  • View blog
  • Posts: 13,583
  • Joined: 12-December 12

Re: I have an error- error C2447: '{' : missing function header (o

Posted 19 April 2013 - 01:45 PM

void fn(int n); << remove this semi-colon, it terminates the statement
{
    int c = 0;

Was This Post Helpful? 0
  • +
  • -

#4 saimjarwar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-April 13

Re: I have an error- error C2447: '{' : missing function header (o

Posted 20 April 2013 - 10:25 AM

I got it,,,,,,,,..................



Thankssssssssssssss.,.....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1