Im having trouble adding the looping in my program. I have here like an MRT ticketing machine but I don't know how to add the looping.
Can someone help me, Im thinking of adding an an option here:
___________________________________________________________________________
if(c2 == 2)
{printf("\nTo Avail a Ticket going to Quezon Avenue,\nPlease insert Php10.00\n");
printf("Enter Amount: ");
scanf("%d", & n2);
system("pause");
if(n2==10)
printf("Printing TICKET");
else
printf("Error");}
----------------------------------------------------------------------------
where if the user inputs a different integer and will result to printing "Error", another option will pop out asking the user if he wants to try again
example:
Enter Amount: 11
Press any key to continue...
Error
Would you like to try again?(y/n):
*if the user inputs y, he will go back from the start, and if he inputs n,the program will end. But if that doesn't work, any other suggestions is welcome and also how to do it. Thanks!
BTW THE WHOLE CODES WON'T FIT HERE SO I CUT IT.
Codes:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define SIZE 5
int choice1, c2;
int n2,n3,n4,n5,n6,n7,n8,n9,n10;
int q1,q3,q4,q5,q6,q7,q8,q9,q10;
int k1,k2,k4,k5,k6,k7,k8,k9,k10;
int c1,c2,c3,c5,c6,c7,c8,c9,c10;
int san1,san2,san3,san4,san6,san7,san8,san9,san10;
int o1,o2,o3,o4,o5,o7,o8,o9,o10;
int sha1,sha2,sha3,sha4,sha5,sha6,sha8,sha9,sha10;
int bo1,bo2,bo3,bo4,bo5,bo6,bo7,bo9,bo10;
int g1,g2,g3,g4,g5,g6,g7,g8,g10;
int bu1,bu2,bu3,bu4,bu5,bu6,bu7,bu8,bu9;
void info(){
printf("M R T T I C K E T V E N D I N G M A C H I N E\n");
printf("\n**How to Buy a Ticket:\n");
printf("[1] Choose From What Station. \n");
printf("[2] Choose Destination. \n");
printf("[3] Insert EXACT amount needed.\n");
printf("[4] Get your ticket.\n");
printf("\n\n\t\t\t!!!NOTE!!!\nThis Machine is a One(1) Transaction at a Time ONLY. ");}