4 errors, please indicate errors.

#include <iostream.h>
#include <conio.h>
//#include <stdlib.h>

main()
{
void diplay (void);
clrscr();

display();

cout<<"ok";

//getch();

}
void display (void)
{
cout<<"It is my first Function program"<<endl;
}
Seems like a homework problem... Why don't you first try for yourself?
You declared function as

void diplay (void);

But called functiobn
display();

That is their names do not coinside.

I hope that your old compiler allows to omit return types of functions.

Otherwise you shall declare main as

int main()
Last edited on
You misspelled display in line 7.
Watch this youtube video about functions and please learn some more C++

http://www.youtube.com/watch?v=endPDlcvoYM&list=UUdbHDXYdsHkqpyAt9Z4_iCw&index=4

Fixed code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <windows.h>

using namespace std;

void display();       // Function prototyping


int main(){

display();   // You spelled diplay. You don't need to type void. You make a new function if you do that.
                 // What you did is called function overloading. Giving two or more functions the same name. 
                 // So if you want to call a function in main only use the function it's name!

// if you want you can use system("CLS"); here. You must include windows.h for that

cout << "Ok" << endl;

system("PAUSE");
return 0;
}

void display(){
cout << "This is my first function program!" << endl;

}


Last edited on
Bundle of Thanks Great work
You're welcome (:
Topic archived. No new replies allowed.