function call

what wrong in this code cause appearance of numbers in funstion call instead hello world words
& how to make good function call
& how to use goto operator in function or many case in switch

the code is


#include <iostream>
using namespace std;

void mystring();

int main ()
{
cout << mystring << endl;
return 0;
}

void mystring()
{
cout << "hello world" << endl;
}


that for fuction call



& what wrong in this code & how to use the goto loop




#include <iostream>
using namespace std;



int main ()
{
int x , y , z ,n ;
cin >> x;
cin >> y;
cin >> n;
switch(n)
{
case 1: ( n = 1 );
z = x +y ;
cout << z ;

case 2: ( n = 2 );
z = x -y;
switch(z)
case 1:( z < 0 );
{goto case 1:(n = 1);}
case 2: for (z = 0, z > 0);
{cout << z}
}
return 0;
}


Use code tags for code, as I am doing.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;

void mystring();

int main ()
{
cout << mystring << endl;
return 0;
}

void mystring()
{
cout << "hello world" << endl;
}


In order to properly call the function mystring, you must follow the word with parenthesis, like this: mystring()
If you are simply trying to call the mystring function so that it will print the words "hello world" for you, then your call to that function should simply look like this:
1
2
3
4
5
int main ()
{
mystring();
return 0;
}

You don't need to use cout in your main function, because you are using it in the mystring function.
Last edited on
What is this nonsense supposed to be ???

#include <iostream>
using namespace std;


int main ()
{
int x , y , z ,n ;
cin >> x;
cin >> y;
cin >> n;
switch(n)
{
case 1: ( n = 1 );
z = x +y ;
cout << z ;

case 2: ( n = 2 );
z = x -y;
switch(z)
case 1:( z < 0 );
{goto case 1:(n = 1);}
case 2: for (z = 0, z > 0);
{cout << z}
}
return 0;
}
Topic archived. No new replies allowed.