It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming C and C++ Forum Script-archive

Simple C++ Code

Share your completed scripts.

Simple C++ Code

Postby Kotik on Wed Mar 16, 2005 12:06 am

//Written by Arman Iqbal

#include <iostream.h>

main()
{
int med;
int pass;

int correct1 = 12345; //password for user nr 12
int correct2 = 54321; //password for user nr 24

cout << "Type in your membership number : \n";
cin >> med;

switch (med) {

case 12:

cout << "Type in your password : \n";
cin >> pass;

if (pass == correct1) {
cout << "You have successfully logged into your account \n";
break;
}

else {
cout << "Your password is incorrect. Run the program again. \n";
break;
}


case 24:

cout << "Type in your password \n";
cin >> pass;

if (pass == correct2) {
cout << "You have successfully logged into your account \n";
break;
}

else {
cout << "Your password is incorrect. Run the program again. \n";
}

default:
cout << "The membership number is invalid. Access denied.\n\n";

}

return 0;
}
DEVPPL : News Publisher
User avatar
Kotik
1000+ Club
 
Posts: 1086
Joined: Mon Aug 23, 2004 12:25 am
Location: Sweden

Postby Vankelmod on Mon Nov 13, 2006 5:34 pm

I feel kind of stupid for asking this question. HadI written this program I would have begun with:

#include<iostream>
using namespace std;

Is there a rigth or wrong way? I thought for sure your code would generate an error message, though my compiler accutally doesn't protest more than a little.
Vankelmod
 
Posts: 10
Joined: Sun Nov 05, 2006 2:59 pm


Who is online

Users browsing this forum: No registered users and 0 guests