Vraag(alweer xD)

Status
Niet open voor verdere reacties.

Hertebeest

Gebruiker
Lid geworden
10 mrt 2007
Berichten
37
Ik ben een beetje bezig met keuzes, en ik snap niet precies waarom dit niet werkt.

Code:
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    char Y;
    char N;
    int choice;
    cout << "Want to continue? [Y/N]";
    cin >> choice;
    
    if (choice == Y)
    {
               cout << "Oke" << endl;
               }
               if (choice == N)
               {
               cout << "No" << endl;
               }
               cout << "Bye" << endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

Iemand?

Ook heb ik dit geprobeerd

Code:
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    char Y;
    char N;
    int choice;
    cout << "Want to continue? [Y/N]";
    cin >> choice;
    
    for (; choice == Y; )
    {
               cout << "Oke" << endl;
               }
               for (;choice == N ;)
               {
               cout << "No" << endl;
               }
               cout << "Bye" << endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}
 
Laatst bewerkt:
Hmmz, ik zag ergens in een stukje code dat je n dan zo moest neerzetten: 'n'

Toen bedacht ik deze code.

Maar het lukt nog steeds niet. =S

Code:
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int choice;
    cout << "Input a Y or a N: ";
    cin >> choice;
    
    if (choice == 'Y')
    {
               cout << "Oke" << endl;
             
               }
               if (choice == 'N')
               {
                          cout << "2 bad" << endl;
                          }
   
         
    system("PAUSE");
    return EXIT_SUCCESS;
}
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan