Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 02:13

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C++]Help in Yes or No loop

Discussion on [C++]Help in Yes or No loop within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
FinalKnightx's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 372
Received Thanks: 104
[C++]Help in Yes or No loop

Can someone please teach me how can I add a Yes or No loop in this program? This is a simple library system which will store 20 book titles with a maximum of 50 characters each. Every time after the user inputs a title, it will prompt for a yes or no. If the user inputs yes, it will ask for another title. if no, it will display the title of the books stored in the array.
Code:
#include <iostream>
using namespace std;

int main()
{
	char book[20][50],choice;
	int index;
	cout<< "ADDING BOOK - MMSU LIBRARY";
	for ( int i = 0; i < 20; i++ )
	{
		cout << "\n\nTitle: :";
		cin.getline(book[i], 50);
}
	system("cls");
				cout << "DISPLAY BOOK - MMSU Library System";
				cout << "\n\nBook Index" " \tTitle";
	for ( int i = 0; i < 20 ; i++ )
	{
		index=i+1;
		cout<<endl<<"    "<<index<<"\t\t"<<book[i]<<endl;
	}
	system("pause");
	return 0;
}
FinalKnightx is offline  
Old 01/18/2016, 07:18   #2



 
IceTrailer's Avatar
 
elite*gold: 150
Join Date: Sep 2010
Posts: 2,070
Received Thanks: 821
Quote:
Originally Posted by FinalKnightx View Post
Can someone please teach me how can I add a Yes or No loop in this program? This is a simple library system which will store 20 book titles with a maximum of 50 characters each. Every time after the user inputs a title, it will prompt for a yes or no. If the user inputs yes, it will ask for another title. if no, it will display the title of the books stored in the array.
Code:
#include <iostream>
using namespace std;

int main()
{
char book[20][50],choice;
int index;
cout<< "ADDING BOOK - MMSU LIBRARY";
for ( int i = 0; i < 20; i++ )
{
cout << "\n\nTitle: :";
cin.getline(book[i], 50);
}
system("cls");
cout << "DISPLAY BOOK - MMSU Library System";
cout << "\n\nBook Index" " \tTitle";
for ( int i = 0; i < 20 ; i++ )
{
index=i+1;
cout<<endl<<"    "<<index<<"\t\t"<<book[i]<<endl;
}
system("pause");
return 0;
}

bool done = false;

In the beginning of your for loop:
if (done) break;
Also i don't advise you to use a 2 dimensional array. Just use std:vector or sth
IceTrailer is offline  
Reply


Similar Threads Similar Threads
Loop Bug
07/02/2013 - SRO Private Server - 2 Replies
Hi, Everytime when I have to go to the temple of jupiter trainplace starting from Hotan to Constantinople the bot stops and log show it: http://img594.imageshack.us/img594/6830/1s.png http://i.imgur.com/laayGnK.png
Loop
08/11/2011 - SRO Private Server - 0 Replies
hmm i m just wondering is loop safe to use and if loop works with db.bot 1.3a on ZSZC
LOOP
09/14/2010 - Grand Chase Philippines - 1 Replies
MY MAIN.EXE IS LOOPING PLZ HELP ME OUT GCPH!
[Bot]Loop ?
06/25/2010 - SRO Private Server - 1 Replies
I been trying to set up the bot to loop where i grind, and it doesnt works! someone has any idea how to make the bot loop? thanks!
Agbot loop dosnt loop
10/18/2008 - Silkroad Online - 1 Replies
my agbot after i tele will go through the 20 sec wait then says in bot concle feature not available yet feature not available yet idk whats wrong



All times are GMT +1. The time now is 02:14.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.