answersLogoWhite

0


Best Answer

You can find C++ source code all over the internet and in C++ reference books. The vast majority of programs accept input of some form or another, but not all programs use while loops (some don't use loops of any kind). The following example demonstrates input and while loops:

#include <iostream>

#include <string>

#include <sstream>

#include <time.h>

using namespace std;

void PrintOptions( string options )

{

cout << "Please enter one of ";

unsigned int i=0;

while( i < options.length() )

{

if( i )

{

if( i < options.length() - 1 )

cout << ", ";

else

cout << " or ";

}

cout << "'" << options.at( i++ ) << "'";

}

cout << "." << endl;

}

int PromptChar( string prompt, string options )

{

int result = -1;

while( result num )

{

cout << "Well done! You got it right in " << guess << " guesses.\n" << endl;

guess = 0;

}

else

{

++guess;

cout << "Too " << (i<num?"low":"high") << ". Try again." << endl;

}

}

}

return( 0 );

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Where can you find a C plus plus program that accepts input and will uses while statement?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


Write a program that will graph using for loop?

A = 5do{statement;A = A + 1;} while (A < 10)


Conversion of decimal to binary in fortran?

This is not a perfect program, but it will get you started in the right direction. Works for any INTEGER up to "some" power of 2 (decimals kill the program). PROGRAM binary IMPLICIT NONE INTEGER remainder, quotient, n, int_input, answer REAL input, dec_input WRITE(*,*) 'Input a number to convert to binary' READ(*,*) input int_input = input dec_input = input - int_input dec_input = abs(dec_input) quotient = abs(input) DO WHILE (dec_input==0) n = 0 answer = 0 DO WHILE (quotient&gt;1) remainder = mod(quotient,2) quotient = quotient/2 answer = answer+remainder*10.**n n = n+1 END DO IF (input&lt;0) answer = -answer answer = answer + quotient*10.**n WRITE(*,"(a,i31)") 'Your answer in binary is:',answer END DO END PROGRAM binary


Java script program to Print the Fibonacci series using array?

&lt;script type = "text/javascript"&gt; var input; var rev = 0; input=window.prompt ("Please enter a 5-digit number to be reversed."); input = input * 1; while (input &gt; 0) { rev *= 10; rev += input % 10; input /= 10; } document.write ("Reversed number: " + rev); &lt;/script&gt;


Difference between break and continue statements in wml?

Break statements:-its terminates the current while or for loop and continue the program execution from the statement following the terminated.NOTE:-note that it is wmlscript syntax error to use the break statement outside of while or a for statements.example;Breakstatement:Break;Continue statement:-this statement terminate execution of a block of statementin while or for loop and continues execution of loop with the next iteration.note that the continue statement does not terminate the execution of loop and also is wmlscript syntax error to use the break statement outside of while or a for statements.-> in while loop, it jumps back to the condition.-> in for loop,it jumpsto the update expression.syntax:continuestatement:continue;

Related questions

What is the use of INPUT statement?

Input command is used to enter the values while the program is being executed. this command waits for the user to enter the information and then assigns the values accordingly.


How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


How are kidneys filters?

Filter is a program that accepts a certain type of data as input, transforms it in some manner, and then outputs the transformed data. while Kidneys, organs with several functions, serve essential regulatory roles in most animals, including vertebrates and some invertebrates.


What is the difference between Do While statements and Do For statements?

A "do while....." statement is a looping instruction to a program to repeat a stage in the program while some condition is true - e.g while a variable is negative, or, while one variable is less than another. A "do for ....." statement is a looping instruction to a program to repeat a stage in the program a set number of times - e.g for steps = 1 to 10, or, for steps = 1 to (some variable).


How do you write a java program that prompts the user for a list of 5 prices?

// create an BufferedReader from the standard input stream BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String currentLine = ""; int total = 0; // read prices System.out.print("Please enter a price: "); while (total &lt; 5) { double input = 0; try { input = Double.valueOf(currentLine); ++total; } catch (final NumberFormatException ex) { System.out.println("That price was not formatted correctly."); } System.out.print("Please enter a price: "); } Note that this program does nothing with the input, just accepts it form the user.


Write a program that will graph using for loop?

A = 5do{statement;A = A + 1;} while (A < 10)


In language Borland C How do you make a computer program accept input without stopping it with a specific input statement For example: Asteroids game-program runs but accepts arrow keys while running?

I remember doing this in borland c++ many years ago. The strategy is to write an interrupt handler function that will go out the the character buffer and check to see if a key was pressed. you will need to look up in your borland documentation on what this register would be called. i am too poor to afford a compiler right now. then in your game processing loop you code would look something like: stmts if keypressed then check input buffer for char (process char for the action you want it to do) end if stmts your function "keypressed" would be the one to check the interrupt for this this is also similar to how to handle mouse input. sorry i can't give you more help.


Conversion of decimal to binary in fortran?

This is not a perfect program, but it will get you started in the right direction. Works for any INTEGER up to "some" power of 2 (decimals kill the program). PROGRAM binary IMPLICIT NONE INTEGER remainder, quotient, n, int_input, answer REAL input, dec_input WRITE(*,*) 'Input a number to convert to binary' READ(*,*) input int_input = input dec_input = input - int_input dec_input = abs(dec_input) quotient = abs(input) DO WHILE (dec_input==0) n = 0 answer = 0 DO WHILE (quotient&gt;1) remainder = mod(quotient,2) quotient = quotient/2 answer = answer+remainder*10.**n n = n+1 END DO IF (input&lt;0) answer = -answer answer = answer + quotient*10.**n WRITE(*,"(a,i31)") 'Your answer in binary is:',answer END DO END PROGRAM binary


Java script program to Print the Fibonacci series using array?

&lt;script type = "text/javascript"&gt; var input; var rev = 0; input=window.prompt ("Please enter a 5-digit number to be reversed."); input = input * 1; while (input &gt; 0) { rev *= 10; rev += input % 10; input /= 10; } document.write ("Reversed number: " + rev); &lt;/script&gt;


What is the purpose of wend statement in while loop in gw-basic?

While--wend statement is used to execute a loop until a given condition is true.if the condition is false the loop ends and the program continous to the line following eend.


How will you print 10 studens name by using while loop statement in QBasic?

cls input "enter a name"; a$ b=1 while b &lt;=1 print a$ b = b+1 wend end


Difference between break and continue statements in wml?

Break statements:-its terminates the current while or for loop and continue the program execution from the statement following the terminated.NOTE:-note that it is wmlscript syntax error to use the break statement outside of while or a for statements.example;Breakstatement:Break;Continue statement:-this statement terminate execution of a block of statementin while or for loop and continues execution of loop with the next iteration.note that the continue statement does not terminate the execution of loop and also is wmlscript syntax error to use the break statement outside of while or a for statements.-> in while loop, it jumps back to the condition.-> in for loop,it jumpsto the update expression.syntax:continuestatement:continue;