Trying to make basic if command

Hello people.

I'm new learner of C language,and I'm trying to make simple and basic ATM software on C.However, When I try to make password activation on that I face with problem with something which is when I try to enter password like ' hello ' it's not send it directly to else command . What should I do about it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main () {
	
char pass;		
int password = 9314;
int calculation;
int payment;
int balance = 4250 ;

printf("WELCOME TO C-BANK AUTOMATIC TELLER MACHINE");
getchar();
printf("\n\nGiving you the best service is our first purpuse.");
getchar();
printf("\n\nPlease enter your password=");
scanf("%d",&password);

if ( password == 9314 ) {

printf("Welcome again Mr.Piskin\n\nHow can we help for our dear customer");
printf("\n\n1-)Money extract");
printf("\n2-)Money payment");
printf("\n3-)Money Transfer");
printf("\n4-)Check your balance");
printf("\n5-)Extract your card");
printf("\n\nPlease select any options=");
scanf("%d",&calculation);


switch (calculation) {

case 1 :
	 
	 
	 printf("Enter amount of money you want to extract from your balance=");
	 scanf("%d",&payment);
	 balance -= payment;
	 if ( balance < 0 ) {
	 	  printf("\nWe are sorry about that we haven't been complated your processing");
	 	   getchar();
	 	   printf("\nPlease check your balance and try again later");
	 	   getch();
		   return 0;
		  }
	 printf("Calculation is over.Thank you for using our service"); 
	 getchar();
	 printf("Your rest balance is = %d",balance);
     break;	
     
case 2 :
	 
	 printf("Enter amount of money you want to add to your balance=");
	 scanf("%d",&payment);
	 balance += payment;
	 printf("Calculation is over.Thank you for using our service"); 
	 getchar();
	 printf("Your new balance is = %d",balance); 
	 break;
	 
case 3 :

	 printf("Enter amount of money you want to transfer from your balance=");
	 scanf("%d",&payment);
	 balance -= payment;
	 	 if ( balance < 0 ) {
	 	  printf("\nWe are sorry about that we haven't been complated your processing");
	 	   getchar();
	 	   printf("\nPlease check your balance and try again later");
	 	   getch();
		   return 0;
		  }
	 printf("Calculation is over.Thank you for using our service"); 
	 getchar();
	 printf("Your new balance is = %d",balance); 
	 break;
	 
case 4 :

	 printf("This is your rest balance from your last account process=%d",balance);
	 break;
	 
case 5 :
	 
	 printf("Your card is extracted");
	 break;	 
	 	 
default :
		
		
		printf("Please try again");
	    break;
		
		}

}

else {
	 
	 printf("\n\nYour password is looking wrong.Please contact our security service");
   	 printf(" immidiately");
   	 printf("\nif you don't think that you weren't change the password");
   	 getch();
	 return 0;
}

getch();
return 0;

}
In main you initialize password to 9314. When you try to enter a string into this int it will be rejected and password will remain 9314.

BTW. Why do you want to learn c instead of the newer and better C++ ?
Topic archived. No new replies allowed.