Hello to all of you and I would like you to check and post here what`s the problem in my code. So, I am writing a program where you input a number, the computer checks it and if it`s true a password is printed out. But when I compile and run it(in Dev-C++) whatever number I input it displays the password. So here`s the code:
#include<stdio.h>
int main()
{
int IDN;
int pass=123;
printf("Please enter your IDN: ");
scanf("%d", &IDN);
if(IDN==1);
{
printf("The password is: %d", pass);
}
getch();
return 0;
}
Please help me because I really want to learn both C and C++! Thank you!
According to your description above , I write a C program based on your code
Hopefully, it can help you
I compile my code in Visual C++ 6.0
My Email is TZOU1@e.ntu.edu.sg, I am from Nanyang Technological University, Singapore
#include<stdio.h>
#include<conio.h>
int main()
{
int IDN;
int pass=123;
printf("Please enter your IDN: ");
scanf("%d", &IDN);
if(IDN==pass)
{
printf("The password is: %d\n", pass);
// Here you can also write the follow sentence
// printf("The password is: %d\n", IDN);
}
else
{
printf("The passwd you inputted is wrong!\n");
}
Thank `s to both of you!You are like the best!Hour after I started this topic I have two answers that helped a lot!www.cplusplus.com is the greatest C/C++ website!The semi-colon was a BIG mistake and Robin you reminded me for the ELSE function.
/* Password Manager 1.1
by Shooter
This program tell`s your password that you have entered for
(facebook, skype, yahoo mail etc.) only if you input the
correct number/password(choosen by you) and if you enter
wrong number/password it displays "Access denied!!! :)"
*/
#include<stdio.h>
int main()
{
long Pass;
long ePass=847152095;
long fPass=734920948;
printf("Please enter the password: ");
scanf("%ld", &Pass);
if(Pass==990405)
{
printf("My email password is: %ld. My facebook password is: %ld", ePass, fPass);
}
else
{
printf("Access denied!!! :)");
}
getch();
return 0;
}
Note: If any of you know how can I ask the user if he wants to try and input it again? Thoese aren`t my real password.