Mar 26, 2007

C++ program for Password input and check

C++ program to input and check a given password. if user input a correct password then program to add two number will be executed and a user input a wrong password. A message "Wrong password" would appeared on the screen and terminates the proram.

#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
for (int i=1;i<=5;i=i+1) // start, condition, increment
{
int a,b,c,x;
cout << "enter your password here";
cin >> x ;
if (x==1)
{\
cout <<"enter first number";
cin >> a;
cout <<"enter second number";
cin >> b;
c=a+b;
cout << c <<endl;
}
else
{
cout << "wrong password";
break;
}
}
getch();
}

No comments:

Post a Comment