Please Check my function code(it is not run)

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

main()
{
void sum (int, int);
clrscr();
sum(10,15);
cout<<"ok";

}

void sum (int x, int y)

{
int s;
s=x+y;
cout<<"sum=" <<s<<endl;

}
#include <iostream> without .h.

The return type of main should must be int.

Write std:: in front of the standard identifiers: std::cout and std::endl.
For C++ I find this way nicer:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <conio.h>

//function prototypes here
void sum (int, int);  

int main()
{
     clrscr();
     sum(10, 15);
     std::cout << "ok";
     return 0;  // don't have to implicitly call this, but I started back in 1997 when void main was allowed still
}

void sum(int x, int y)
{
     int s;
     s = x + y; 
     std::cout << "sum = " << s << std::endl;
}

Now if you don't know the standard identifiers, as I don't know them all, you can cheat and add using namespace std; right under #include <conio.h> .
Topic archived. No new replies allowed.