C++ :: Program That Asks User To Enter Even Number Only

Mar 23, 2014

Write a C++ program that asks the user to enter an even number only. If the user enters an odd number the program should use input validation to ask the user to enter another number.

- The user can enter as many numbers as he wants

- The program should also keep a count of how many numbers entered and display how many odd and even numbers entered.

View 1 Replies


ADVERTISEMENT

C++ :: Write Program That Asks User To Enter Student Grades?

Jan 21, 2014

Write a program that asks the user to enter a student’s grades on four exams. The program should display the four grades and the average of the four grades,rounded to the nearest tenth. To add the grades, use a variable called total_grade, which you should initialize to zero.As the program prompts for and obtains each grade, add the grade to total_grade using the += operator.

View 3 Replies View Related

C :: Make Program That Asks User For Number?

Oct 15, 2013

So I'm trying to make a program that asks the user for a number and then prints a statement the same number of times the user entered. 3 different statements, using the 3 loops (for, while, and do while). I made the program but for some reason the statement from the do while loop goes off infinitely.

MY CODE:

The error:

View 8 Replies View Related

C++ :: Program That Asks User To Prompt Integer Number

Nov 18, 2013

Write a program that asks the user to prompt an Integer number and then test whether it is Palindrome Numbers or not.

The following are Palindrome numbers:
1.22
2.333
3.67876
4.44444
5.123454321

View 8 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 :: Program That Allow User To Enter A Number N And Print Nth Prime Number

Nov 3, 2013

I need to write a program that will allow the user to enter a number "n" and the program tell you that the nth prime number is .....

EXAMPLE

user enters 55

printf("The 55th prime number is %i", variable");

View 1 Replies View Related

C++ :: Write Program That Prompts User To Enter Item Number

Jun 27, 2013

Write a program that prompts the user to enter an item#, the program should determine if the item is in the file and print the price of the corresponding item. If the item is not in the file an error message should be printed.

All I have so far is

string item_no=0;
cout<<"Enter a item#";
getline(cin,item_no);
if stream openData;

I need to finish the rest in pseudo code

View 2 Replies View Related

C/C++ :: Creating Program That Allows User To Enter Unknown Number Of Income / Expense Amounts

Feb 21, 2014

I'm trying to create a program that allows the user to enter an unknown number of income and expense amounts. The program has to us see a while loop and display the income total, expense total, and total profit or loss. I've got it really close, but I'm doing the loop wrong. It counts the sentinel value (-1) towards the total, instead of just ending like it is supposed to.

#include <iostream>
using namespace std;
int main() {
//declare variables
double incomeInput;
double expenseInput;
double incomeTotal=0;
double expenseTotal=0;

[code]....

View 5 Replies View Related

C++ :: Write A Program That Asks The User For A Name

Jul 2, 2014

So I am trying to write a program that asks the user for a name. If the user enter the right name the program ends but if the user were to enter the wrong name the program would enter a loop prompting the user to re-enter the name. However I am not able to get the program to work!

View 9 Replies View Related

C/C++ :: Write A Program Where It Asks The User For A File Name?

Apr 18, 2014

I'm trying to write a program where it asks the user for a file name.

If that file exists, the it will open the file and then read it and print the information in the file.

However, if the user enters a file name that does not exist, the user will have 2 more tries (for a total of 3 tries) to get the correct name of the file.

I am close to getting it. What I have now just won't go through the loop to validate if the input matches an existing file. It goes straight to the printing of what is in the file. If the file doesn't exist, it prints: "Found your file..Opening..processing...Total keys found = 0."

So, my question, what am I doing wrong that it won't go through the loop properly?

#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
using namespace std;
int main() {
bool fileFound = false;

[code]....

View 2 Replies View Related

C :: Asks To Input Number Nad If Outside Number Asks To Put In Number Within Bounds

Mar 23, 2013

I have to write a program that will ask you to put in a number between 0 and 9 and multiply it by pi. If the number put in is between 0 and 9 then pi is multiplied but if it isnt between 0 or 9, it will say the number is not between 0 and 9 and asks you to put it in again and will repeat until a number between 0 and 9 is put in.

I have got the program working to the extent that it the number is between 0 and 9 it will multiply it by pi but if its not between 0 and 9 it will say the number is not between 0 and 9 and ask to put in a new number.

I can't work out how to get the program to repeat itself if the number entered isnt between 0 and 9.

I have enclosed the code below .....

View 5 Replies View Related

C :: Program That Asks The User To Type 10 Integers Of Array?

Mar 2, 2014

Write a program that asks the user to type 10 integers of an array. The program will then display either "the array is growing", "the array is decreasing", "the array is constant", or "the array is growing and decreasing."

(Hint: compare consecutive numbers in array and check whether it is increasing or not or constant) I wrote the program very well, but do I have to use "bool" like in c++ ? I haven't known how to code in c++ yet.So, I don't want to use "bool" in C.

I also wrote code about it but it looks like backslash and one,two,three,four,five how can I do it like this ?

View 4 Replies View Related

C++ :: Program That Asks User For Numbers And Adds Odd Ones Doesn't Work

Nov 12, 2014

Title is self-explanatory.

Code:
#include <iostream>
using namespace std;
int main ( ) {
float number;
float sum;
float divi;
while(number != -1) {

[Code] .....

View 5 Replies View Related

C :: Create A Program That Asks User To Input Integer Lengths Of Three Sides Of A Triangle

Sep 6, 2013

C programming: I want to creat a program that asks the user to input the integer lengths of three sides of a triangle, and if so whether the triangle is a right-angled, acute or obtuse one. i am having some doubts about the if, else if statements. I never seem to know how and in what order to use them.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[]){
int SideA;
int SideB;
int SideC;
}

[code]....

View 14 Replies View Related

C++ :: Program Inputs The Number Of Rows And Columns And Asks For The Entries

Feb 7, 2015

I am writing a program that deals with 2d arrays. The program inputs the number of rows and columns and asks for the entries. When the program run and compiles it works perfectly until it outputs then it gives me a warning.

Here is my code:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int row1=0,col1=0,i,j;
//int a[row1][col1];
int** a= new int*[row1];

[Code]...

I am learning how to do this before I can move on so it can read a text file of numbers.

Also I am having problems with ////delete [] a[];///// I took it out because it made my code compile and run but when I add it in, it gives me an error:

matrixtesting.cpp|56|error: expected primary-expression before ']' token|

I know this expression is suppose to deallocate the array.

View 7 Replies View Related

C++ :: How To Restrict User To Enter Four Digit Number Only

Aug 22, 2014

I am trying to write up something to have a user to enter a four digit number. Only four digits, Ex: 0001, 0116, or 9999. There is no getting around the selection 0001 or 0002. I understand if not done correctly, the first three 0's will be ignored.

I've been just playing around with what I have below but I just don't remember how to do it nor can I find a good example online to figure it out. I know it is not correct just typing to try to remember. I am aware that it is gibberish right now, this is just me brainstorming.

int number;
cout<<("Please enter the four digit number(Ex: 0001):
");
cin>> setw(2) >> number;
cout<<)"Please enter four digit date. Two digits for month and two digits for year:
");
cin>> date;
if (number< || number > 30)
cout << "Invalid choice. Try again." << endl;
cin.clear();

View 2 Replies View Related

C++ :: Basic Calculator - User Will Have To Press Enter After Every Number

Mar 22, 2013

I'm stuck because I can make the calculator just find but the user will have to press enter after every number, what is s solution to this?

#include <iostream>
#include <string>
using namespace std;
int a = 1, b, c;
string symbol;
int multiplyFunction();

[Code] .....

View 6 Replies View Related

C/C++ :: How To Ask A User To Enter Date And ISBN Number In Specific Format

Dec 4, 2014

I don't know how to ask the user to enter the date in this format (DD/MM/YY) and ISBN number with hyphens.

After user enter date and ISBN number, it should look like this:

Date: 5/24/12
ISBN: 0-000-12345-0
#include <iostream>
#include <string>
using namespace std;
int main() {
string date;//MM/DD/YY Format

[Code] ....

View 7 Replies View Related

C :: Program That Will Allow A User To Enter Their Name

Jul 2, 2013

I am trying to make a program that will allow a user to enter their name, from this point, three options should be present for the user to choose, then from that point, two more options should be present. I have if else statements in a switch case and I get the "undeclared" error for the a in the first " if(specificage == a) ".

NOTE: I use Code::Blocks.

Here is the code:

Code:
#include <stdio.h>
#include <string.h>
int main(){
char name[50];
char ageclass[50];
char specificage[50];

[Code] ....

View 3 Replies View Related

C++ :: Program That Will Ask User To Enter Area Of Square?

Feb 11, 2013

B. Circle in a Square Write a C++ program that will ask the user to enter the area of a square. Then the program will display the biggest area of a circle that will fit in a given square. Using math.h library is not allowed.

View 1 Replies View Related

C++ :: Program Which Allows A User To Enter Input For A Time Interval

Apr 23, 2014

how can i make a program which allows a user to enter an input for a time interval for example i ask a question and sets the input to be entered within 10 seconds...

View 4 Replies View Related

C++ :: Program That Allows User To Enter Statement And Outputs Statistics?

Dec 12, 2013

a program that allows the user to enter a statement and outputs statistics; number of vowels, number of constants, percentage of vowels and constants, number of words, number of punctuation characters

View 2 Replies View Related

C++ :: Write A Program That Prompts The User To Enter Integer?

Nov 8, 2013

Write a program that prompts the user to enter an integer and then displays that integer as a product of its primes and if it is a prime then it should say so? Above is the question I have been given

#include <iostream>
#include <vector>
using namespace std;
int main () {
int num, result;
cout << "Enter A Number " << endl;
system ("pause");
return 0;
}

This is what I have so far, do I have to use a for loop, a while loop or a do loop,

View 7 Replies View Related

C++ :: C Type Strings - Program To Ask User To Enter A String And Perform Functions

Oct 18, 2014

My assignment is : Please use C type strings ( array representation of strings). Write a program that will ask the user to enter a string. It will then regard that string as a worked-on string and allow the user to perform the following editing functions on it:

s – search
i – insert
a – append
d – delete
a – append
d – delete
r – replace
e – exit
s – search

This option will allow the user to search for a specified string in the worked-on string. If the string is

found, it will display the starting index (position) of the searched string in the worked-on string.

here is what i have so far.

#include <iostream>
#include <cstring>
using namespace std;
int main() {
char a_string[80];

[Code] .....

View 4 Replies View Related

C++ :: Enter Decimal Number Into Program And Required Base

Oct 12, 2013

You enter decimal number into the program and what base you want. The integer part of the decimal is being handled fine, but the decimal is not.

For example, I enter 15.6847 and base 10, which means I'm going from base 10 to base 10. It spits out 68469999999999 for the decimal part. (Do not worry about the first block of numbers. The second block seperated from the first by a space is where the decimal will appear in order.)

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int baseConverter(int, int, int *, int *);

[Code] ....

View 2 Replies View Related

C :: Generate A Program That Will Allow User To Enter Data For A Stock And Calculate Amount Of Stocks

Oct 5, 2013

Okay, so my assignment for my C class is to generate a program that will allow the user to enter data for a stock and calculate the amount of stocks that ended up being positive, negative, and neutral.I tried to do this using one stock, here is my code;

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

Code:

void main()
{
float Neg;
float incst;
float shrs;
float bpps;
float crnt;
float crntcst;
float yrfes;
float pft;
float tpft;
}

[code]....

View 6 Replies View Related







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