Good Day .. I'm new to the forum ..
New to C++ either .. I'm having a problem regarding the while loop ..

I've been trying to make an ATM system .. But I can't continue further for the other cases because whenever I try the loop for going back to the menu isn't working .. Here's my code ..

#include<stdio.h>
#include<conio.h>

void main()
{
	int pin, menu, vBal;
	float cBal=5000, sBal=10000;
	char ans='Y';
clrscr();

		gotoxy(20,5);printf("******** Welcome to IIC Bank Express ********");
		gotoxy(20,15);printf("Enter Pincode: ");
		scanf("%d", &pin);
	if (pin==1234)
	{
		while(ans=='Y')
		{
		clrscr();
				gotoxy(20,5);printf("****** MENU ******");
				gotoxy(20,7);printf("[1]Balance Inquiry");
				gotoxy(20,9);printf("[2]Cash Withdrawal");
				gotoxy(20,11);printf("[3]Deposit");
				gotoxy(20,13);printf("[4]Fast Cash");
				gotoxy(20,15);printf("[5]Payments");
				gotoxy(20,17);printf("[6]Others");
				gotoxy(20,20);printf("Input choice: ");
				scanf("%d", &menu);
		clrscr();
				switch (menu)
				{
					case 1:
						gotoxy(20,5);printf("** Balance Inquiry **");
						gotoxy(20,7);printf("[1]Savings Account");
						gotoxy(20,9);printf("[2]Current Account");
						gotoxy(20,12);printf("Input Choice: ");
						scanf("%d", &vBal);	
		clrscr();
							if (vBal==1)
							{
							gotoxy(20,5);printf("** Savings Account **");
							gotoxy(20,8);printf("Current Balance is : %.2f", sBal);
							}
							else
							{
							gotoxy(20,5);printf("** Current Account **");
							gotoxy(20,8);printf("Current Balance is : %.2f", cBal);
							}
					break;
					default:
							printf("ERROR");
				}
						gotoxy(20,11);printf("Would like to make another transaction (Y/N): ");
						scanf("%c%s", &ans);	
						getch();
		}				
	}
}

Any quick response is much appreciated ..

thanks

This is a C program, not C++, so Narue's thread will not work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.