In: Computer Science
How would I make it so that when I run my code it does not ask for input (not having to enter after the statement and enter 0 for example) after ROXY (Forever ROXY Enterprises) appears? Like it would tell me the second statement right away along with the Roxy phrase. This is in C++.
My code:
#include /
#include
using std::endl;
int main()
{
void readAndConvert();
unsigned int stockSymbol;
unsigned int confNum;
std::cout << "ROXY (Forever ROXY
Enterprises)" << endl;
std::cin >> stockSymbol;
std::cout << "[htrewa] 5000" <<
endl;
std::cin >> confNum;
return 0;
}
To do so you have to remove the cin statement and if it is necessary to get those value you have to assign it during its declaration.The "cin>>" statement tells the compiler to read the value from the user so after entering the value the user need to press enter.
Like this,
#include<iostream>
using std::endl;
int main()
{
void readAndConvert();
std::string stockSymbol="[htrewa]";
unsigned int confNum=5000;
std::cout << "ROXY (Forever ROXY Enterprises) " <<
stockSymbol<<" "<<confNum<<endl;
return 0;
}
This is one way of doing that here I assigned the values to be printed next in the variable stockSymbol and confNum.
Other way is,
#include<iostream>
using std::endl;
int main()
{
void readAndConvert();
std::cout << "ROXY (Forever ROXY Enterprises) " <<"[htrewa] 5000"<<endl;
return 0;
}
Here,it is printed directly.
other way is,
#include<iostream>
using std::endl;
int main()
{
void readAndConvert();
std::string stockSymbol;
unsigned int confNum;
std::cin >> stockSymbol;
std::cin >> confNum;
std::cout << "ROXY (Forever ROXY Enterprises) "
<<"[htrewa] 5000"<<endl;
return 0;
}
Here the user inputs the value brfore printing and just prints the line as such.
other way,
#include<iostream>
using std::endl;
int main()
{
void readAndConvert();
std::string stockSymbol;
unsigned int confNum;
std::cin >> stockSymbol;
std::cin >> confNum;
std::cout << "ROXY (Forever ROXY Enterprises) "
<<stockSymbol<<" "<<confNum<<" [htrewa]
5000"<<endl;
return 0;
}
here the value user inputs is printed between the line