Semi Finished Simple Program

Posts 1–12 of 12 · Page 1 of 1
Semi Finished Simple Program
Basically, i just want it to respond differently based on what the users says, right now it only replies if the user says "no" -see picture/code-




Code:
#include <iostream>

void main() {
	char caName [20];
	std::cout << "What Is Your Name?" << std::endl;
	std::cin >> caName;
	std::cout << "Your Name Is " << caName << "?" << std::endl;
	std::cout << "Nice To Meet You " << caName;
	char cContinue;
	std::cout << ", Has Your Day Been Good Today? (y/n) " << std::endl;
	do {
		std::cin >> cContinue;
	} while (cContinue == 'y');
	std::cout << "Aww, Thats Too Bad." << std::endl;
}
I think I said this in your other program post, but here it is D:
Use If, If Else and Else statements and possibly bool.

EDIT: yeah try using If Else statements with "do while."

I think that if you are gonna use "do while" here you would have to make "do" at the beginning right after the "char" statement line.
@Minato_Nagato
Quote Originally Posted by Pie View Post
I think I said this in your other program post, but here it is D:
Use If, If Else and Else statements and possibly bool.

EDIT: yeah try using If Else statements with "do while."

I think that if you are gonna use "do while" here you would have to make "do" at the beginning right after the "char" statement line.
@Minato_Nagato

tried those, could not get it to work, want to fill in the code me for and show it? i dont understand out if else works
Quote Originally Posted by youngbuck1970 View Post
If and Then are you friends
Don't you mean If and Else
Code:
if(cContinue == 'y')
{
std::cout << "Statements here";
}
else if(cContinue == 'n')
{
std::cout << "Statements for N here";
}
else
{
std:cout << "You didn't choose noob";
}
^Idk if that will compile, i'm half asleep

also, if you put:

using namespace std;

at the top right above int Main() you won't have to put std:: at the beginning of all your statements
Code:
#include <iostream>

void main() {
	char caName [20];
	std::cout << "What Is Your Name?" << std::endl;
	std::cin >> caName;
	std::cout << "Your Name Is " << caName << "?" << std::endl;
	std::cout << "Nice To Meet You " << caName;
	char cContinue;
	std::cout << ", Has Your Day Been Good Today? (y/n) " << std::endl;
	do {
		std::cin >> cContinue;
	} while (cContinue != 'y' && cContinue != 'n');
        if(cContinue == 'n')
	    std::cout << "Aww, Thats Too Bad." << std::endl;
        else
            std::cout << "Woot, that's great." << std::endl;
}
Code:
#include <iostream>
#include <string>
using namespace std;

int main(){

    string ronon;
    cout << "Are you gay?\n";
    cin >> ronon;
       if (ronon == "no")
{
   cout << "fine than!\n";
}
else
{
   cout << "yeah you are.... get out of the fkin closet. \n";
}


}
dunno if it will work in visual c++ but it does in codeblocks.
Quote Originally Posted by Ronon666 View Post
Code:
#include <iostream>
#include <string>
using namespace std;

int main(){

    string ronon;
    cout << "Are you gay?\n";
    cin >> ronon;
       if (ronon == "no")
{
   cout << "fine than!\n";
}
else
{
   cout << "yeah you are.... get out of the fkin closet. \n";
}


}
dunno if it will work in visual c++ but it does in codeblocks.
c++ is c++. IDEs should not matter in such simple apps
Quote Originally Posted by 'Bruno View Post
c++ is c++. IDEs should not matter in such simple apps
yes they do. just tried the code in visual v++ and it gave me an error
Quote Originally Posted by Ronon666 View Post
yes they do. just tried the code in visual v++ and it gave me an error
Maybe you should try Visual C++
Quote Originally Posted by Ronon666 View Post
yes they do. just tried the code in visual v++ and it gave me an error
dude... for how long do you do code?

an IDE is an IDE. C++ is C++.
What changes is normally error levels and warning levels, which visual studio is more.. "careful" about... (and also some libraries related stuff). Stuff like initialized variables, etc... But the language remains the same. (windows related, it will of course change from OS to OS because of libs)
Posts 1–12 of 12 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us