Check my error in this source code

Hello, my system have sign in function. Please check where my error in my source code. The error is, when I write correct ID and Password it become false, but at second time or more it OK. Thank you
ID = 2015
Password = 1234


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
#include<stdio.h>
#include<math.h>

void verify();
int diagonal ( int, int);
int factorial (int);

int main()
{
	int id, pz, a, b, result, num, c, n, f, fact = 1;
	printf("User ID >> ");
	scanf("%d", &id);
	printf("Password >> ");
	scanf("%d", &pz);
	verify();
	
	do
	{
	
		printf("\n\n1. Factorial\n2. Diagonal side\nEnter your choice>> ");
		scanf("%d", &num);
		
		if (num==1)
		{
			int x, result, c, n, fact;
			printf("\nInsert the number : ");
  			scanf("%d", &n);
 
  			fact = factorial (n);
 
 			 printf("Factorial result is %d\n", fact);
 			 printf("\n<<< Thank You >>>");
 			 
 			 return 0;
 			 
		} if (num==2)
			{
				result = diagonal (a, b) ;
			
				printf("The diagonal side is %d\n" , result);
				printf("\n<<< Thank You >>>");
			
			}
		}while (num != 1 && num != 2);
}
void verify()
{
	int id, pz;
	
	if( id != 2015 && pz != 1234)
	{
	do
		{
	
			printf("\a\nIncorrect user ID or Password !!!\n\n");
			printf("Please Re-enter User ID >> ");
			scanf("%d", &id);
			printf("Please Re-enter Password >> ");
			scanf("%d", &pz);
	
		}
		while (id != 2015 || pz != 1234);
			{
				if( id == 2015 && pz == 1234)
				printf("<<< Valid Password >>>\n");
			}
	}
	
	else 
	{
		printf("<<< Valid Password >>>\n");
	
	}

}
int factorial (int x)
{
		int i, F=1;
		for (i = 1; i <= x; i++)
		F*=i;

	return F;
}
int diagonal (int a, int b)
{
	int side;
	printf("\nInsert side a and side b >> ");
	scanf("%d %d", &a, &b);
	side = sqrt (pow (a,2) + pow(b,2) ) ;
	return side;
}


I want to display this when input true ID and Password
<<< Valid Password >>>


But it become this
Incorrect user ID or Password !!!
Last edited on
Please use code tags.
http://www.cplusplus.com/articles/jEywvCM9/

You need to pass ID and password as parameters to the verify function. I would also make it return a bool so you can check in main() if it was valid.
http://www.cplusplus.com/doc/tutorial/functions/
Last edited on
Please use code tags.
http://www.cplusplus.com/articles/jEywvCM9/

You need to pass ID and password as parameters to the verify function. I would also make it return a bool so you can check in main()
Edit & Run
if it was valid.
http://www.cplusplus.com/doc/tutorial/functions/


Thank you very much!! I have solve it.
Topic archived. No new replies allowed.