C++ :: Program To Allow A User To Input A Number From Keyboard That Involves Loop Not Working Right?

Mar 30, 2014

I'm trying to write a C++ program that will allow a user to input a number from the keyboard. Then using a loop, that will perform 10 times, multiply the entered number by the loop counter. Print out the loop counter, the entered number and the product of the loop counter and the entered number. A one-time heading should be displayed before information is printed.

This kinda of what I have so far:

#include <iosteam>
using namespace std;
int main () {
Start
Declare: numScores, sum, score, avg, SENTINEL = 200
numScores = 0

[Code] ....

All the programs I have tried to make are not working?

View 4 Replies


ADVERTISEMENT

C++ :: Loop Not Working User Input?

Jan 20, 2013

Some of my loop is not working. How messed up is this code.. Commented non working code

// ADIT.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "windows.h"

[Code]....

View 3 Replies View Related

C :: Initialize For Loop Using Input From Keyboard?

Feb 22, 2015

I'm not finished with this code, but I am stuck on this one glitch. This is what I have so far, and it's not working.

Code:
int main() {
/*Please input an n value greater than zero. Otherwise, exit the program by entering a carriage return*/
printf("Please input an n value greater than zero. Otherwise, exit the program by entering a carriage return
");
int summation = 0, x, y;
scanf("%d", y);
for (y == x; summation <= M_E && x <= 34; x++)

[Code] ....

View 1 Replies View Related

Visual C++ :: Program That Take Input From A User And Calculate It In A Do While Loop

May 15, 2013

I'm trying to create a program that will take input from a user and calculate it in a do-while loop. The program does the calculation but the answer is wrong. The loop also doesn't work. The purpose of the program is to see how much an item will cost after a discount is taken off and tax is added.

#include <iostream>
#include <cmath>
using namespace std;
double original_cost;
double discount;
double tax;
double total;
char answer;

[Code]...

View 2 Replies View Related

C++ :: Program To Make A Table For Any Input Number - Do While Loop

Nov 27, 2014

Write a program to make a table for any input number and then continuesly ask to press y to print more table and if you press any key other than y then program must be terminate using while loop and do while loop. How to start or end with it.

View 2 Replies View Related

C++ :: Writing Program That Asks User To Input Number?

Sep 11, 2013

im writing a program that asks the user to input a number 1-10 and will transform it into the roman numeral of that number but it seems that its not after the user inouts the number nothing will output

#include <iostream>
#include<iomanip>
using namespace std;

[Code]....

View 3 Replies View Related

C/C++ :: Program To Allow User Input And Output Perfect Number

Mar 11, 2014

The problem that I am having is that , the program outputs numbers that are perfect numbers and im not sure where i can add a statement to make it so that if it isn't a perfect number it doesn't output...

#include<iostream>// allows user input/output
#include<conio.h>
#include<fstream>//data file / result file
#include<iomanip>
#include<cmath> // math function
#define in_file "data.txt"
#define out_file "result.txt"

[Code] ....

View 3 Replies View Related

C++ :: Create Program That Has User Input 5 Digit Number?

Mar 9, 2013

Im trying to create a program that has the user input a 5 digit number. If it's between 10000 & 99999, it will do one thing..(just saying 'yes' for now. Outside those numbers will prompt the user to input again. However, if the user inputs the exact digits 76087, it should display 'term'.

This current code is displaying 'term' whenever the user inputs the 5 digits.

Code:

#include <iostream>
using namespace std;
int main() {
int pin;
cout << "Welcome to Movie Food
Enter your 5-digit pin code: " ;

[code]....

View 14 Replies View Related

C++ :: Write Program Which Tells User If Number They Input Is Prime Or Not?

May 2, 2014

So I need to write a program which tells the user if the number they input is prime or not. I have done so and included the code below. My problem is that I need to allow the user to input if they want to enter another number after the first one using y or n and I am having trouble figure it out.

#include <cstdlib>
#include <iostream>
using namespace std;

[Code].....

View 5 Replies View Related

C/C++ :: Create A Program That Prints A Certain Number Of Asterisks Based On User Input

Apr 12, 2015

I need to create a program that prints a certain number of asterisks based on user input. The user inputs 5 and I want my program to output "*****". How would I do this in C? I've tried printf("%#**", myvariable) but this does not work it only prints "*".

View 1 Replies View Related

C/C++ :: Do While Loop Not Working - Exits After Input

Feb 6, 2014

My code:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int factorial(int n);
int main() {
int n,num;
do {

[Code] ....

My while loop is not working... it exits after 1 input...

View 3 Replies View Related

C++ :: Read User Input To Determine Different Discounts By Number Of Units Sold - Errors In Program

Jun 23, 2014

it will not run and im not sure why. I have a couple of errors, but I'm not sure why.

Here is my code.

//Reads input from user to determine different discounts by number of units sold

#include <iostream>
#include <string>
using namespace std;

int main() {
//Declaration and Initialization of variables
int quantity;
double discount,price = 99.00,totalCost;

[Code] ....

View 1 Replies View Related

C/C++ :: Program That Read A Number From Keyboard And Print Separated Digits To Screen

Feb 18, 2015

Basically this is what i need to do. Write a program that reads a number from the keyboard, separates it into its individual digits and prints the digits to screen, each on its own line followed by the same number of stars as itself.

For example, if the number is 2339 the program should print

9 *********
3 ***
3 ***
2 **

So far i have managed to separate the number and have them on different lines, but how to implement the stars onto each line with the number!

My code so far:

int main() {
int n;
printf("number? ");
scanf("%d", &n);
while (n > 0) {
printf("
%d

[Code]...

View 4 Replies View Related

C# :: Change Position Of TabTip Keyboard Is Not Working

Mar 26, 2014

I wrote a C# program to open and set the position of the TabTip keyboard I can open the keyboard and find the window handle by calling "FindWindow("IPTip_Main_Window",null);" using spy++ I verified that I get the correct handle when I call SetWindowsPos it returns true but the keyboard is not moving.

[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,
int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string ClassName, string WindowName);
IntPtr hWnd=FindWindow("IPTip_Main_Window",null);
if(hWnd!= (IntPtr)0) {
SetWindowPos(hWnd, (IntPtr)0, ToX, ToY, 0, 0, 0x0045);
}

View 1 Replies View Related

C++ :: Keyboard Shortcuts Not Working In Visual Studio 2013

Feb 6, 2015

I downloaded Visual Studio 2013 on a new laptop. On my old one I could press things like ctrl + F7 to compile and ctrl + F5 to start without debugging however now it isn't responding when I type those commands. Nothing happens at all. How to change this? I googled "keyboard shortcuts not working in Visual Studio 2013" but per the usual Google comes up with garbage search results that do not pertain at all.

View 1 Replies View Related

C++ :: User Input - Infinite While Loop

Sep 5, 2014

I have a small loop that gets the user input, as well as acts as input validation to make sure he or she doesn't enter a value that is not within the specified range.

The user is supposed to enter a month number. E.g. if he or she chooses February, then enter 2, or December, 12.

It works correctly if they type a number that is not in the range, but goes into an infinite loop if, say, they type a string such as "month".

Code:
int main() {
// Variable Declaration(s)/Initialization(s)
int month=0;

// Get input
cout<<"Enter a month";
cin>>month;

[Code] ....

How could I go about revising this?

View 4 Replies View Related

C++ :: Loop Depending On User Input

Jul 31, 2013

I'm trying to get this program to loop the number of times I get it to input. The program compiles alright, and it does loop when I tell it too, but how do I output the grades of the multiple students?

#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
int weighted1 = 0;
int weighted2 = 0;

[Code] .....

View 12 Replies View Related

C++ :: While Loop Keeps Looping Without Getting Input From User

Dec 5, 2013

struct stu_dat //outside main function
{
int rollno;
char name[45],
float average;

[Code] ....

No compilation problem.when executing prompt waits for inputting rollno, but, as soon as i enter a char string it keeps looping displaying the "want to enter more data?".i cant understand what is going on,as there is no compilation problem and runs good till i input the name.

View 3 Replies View Related

C++ :: Indefinite User Input Loop?

Dec 13, 2014

In short, I'm trying to make a CLI for a project that can take multiple user inputs add I don't exactly know what I'm doing. I'm able to get cin to take one user input, but that's all I'm sure about.

View 8 Replies View Related

C/C++ :: While / For Loop User Input Sentence

Sep 15, 2014

I'm not sure what the program's purpose is?

1) Ask the user to enter a sentence. Until you reach the end of the sentence, test each character to count the number of spaces and letters.

2) For every space counted, print "SPACE", then print one "!" for every letter counted on an indented line underneath the "SPACE".

Your test sentence to use is: "The potash feldspars are important rock-forming minerals in plutonic, volcanic, and metamorphic rocks."

HINT: You do not need any strings. You need one while loop and two for loops. <cctype>

View 4 Replies View Related

C++ :: Queues Program Suddenly Stops Working When Input Value

Feb 22, 2013

I'm having troubles with this program I made. Put it simply, it's a basic program using Queues. Whenever I try to input a value, my compiler(Dev C) suddenly stops working. The .exe file crashes and I've no way on how I can execute my program.

Code :
#include<iostream>
using namespace std;
int *queue;
int rear, front, queueSize;
void enqueue();
void dequeue();
void display();

[Code] ....

View 1 Replies View Related

C :: Unscramble User Input - Error In Loop

Sep 24, 2014

The purpose of this program is to unscramble the user's input. for example if the user entered 'ftooabll' the program would print 'football'. find the error that I am making....

Now, this only works for strings that are contained in the file wordlist. That being said, I would like this to repeat this search multiple times. Currently, the process is being repeated 7 times, but it only works on the first iteration. The code and sample input/output is below.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUMLOOP 6
void sort_string(char*);

[Code] ....

Sample input/output: (note: all data has been verified to be in the wordlist)

Enter string:
4132dcba
abcd1234
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba

View 3 Replies View Related

C :: Fixing User Input Errors In A For Loop

Mar 6, 2015

So I have to write a step in my program that reads in up to 8 variables. Simple, but if the User submits an invalid value, I have to give an error message and ask him to re-enter the value until he enters a valid number. Here's my while loop that works perfectly:

Code:

while (true) {
printf("
Enter the mark given by Judge 1: ");
scanf("%f", &m1);
if ((m1 >= 0.0) && (m1 <= 10.0)) {
break;
}

[code]...

I'm not sure what to write in the else statement to make the programme understand that it has to repeat the exact same step but without adding 1 to index. Is this possible or do I have to suck it up and just use while loops instead? I'm very new to programming.

View 2 Replies View Related

Visual C++ :: Using Loop To Take User Input And Keep Running Sum Until 0 Entered

Feb 28, 2013

I am stuck on an exercise where i am supposed to use a loop to take user input and keep a running sum until the user enters a 0. the code i have so far is:

#include <iostream>
int main() {
using namespace std;
int num;
int total = 0;
int x;

[Code] ....

The full text of the error message is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream' . and one more thing i was wondering, is there a difference between c++ and visual c++?

View 4 Replies View Related

C++ :: For Loop - Display Smallest And Largest Numbers From User Input

Jul 29, 2013

I'm suppose to write a program using (for loop) that asks the user to enter any amount of numbers, so that it can display the smallest and largest. My program successfully finds the largest, but it is always displaying 0 for the smallest, I think Im doing something wrong with the internalization but I dont know what to change it to.

This is what I have ....

#include <iostream>
using namespace std;
int main() {
int amount;
int count;
int number = 0;
int smallest = 0;
int largest = 0;
cout << "Enter total numbers to process: ";

[Code] ....

View 4 Replies View Related

C :: How To Repeat A Loop Based On Number Inputted By User

Oct 21, 2014

How can i repeat a loop based on the number inputted by the user?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved