C++ :: Reciprocal Of User Inputted Number

Jan 4, 2013

I've been working on this program and I have it all pretty much down, but I just need one thing that I can't, for the life of me, think of! I need to find the reciprocal of a number that the user inputted (ex: if user input was 2 output would be 0.5 or if input was .6, out put would be 1.6 repeating). If theres a simple way, I can't think of it.

View 2 Replies


ADVERTISEMENT

C++ :: Add Each Number From Zip Code Inputted By User

Oct 27, 2013

I came up with this code to try to add each number from a zip code inputted by the user but I think I'm adding up the ascii values not the real values the user is inputting. How I can go from ascii to the real digit. This is my code so far

#include <iostream>
#include <iomanip>
#include <string>
#include <conio.h>
using namespace std;
int main() {
int total = 0;
char ch[5];

cout << "Please input your 5 digit zip code: ";

[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

C++ :: Counting Number Of Lines Inputted By User (File Stream)

Feb 12, 2014

So I'm trying to count the number of lines in a text file that is inputted by the user. Also the code doesn't sum up the last number of the text file (exmp it calculates and print only 14 from 15 numbers). I'm a beginner in c++ programing.

View 3 Replies View Related

C++ :: Count Number Of Vowels Inputted By User - Isvowel Function

Mar 30, 2013

I am trying to create a code that simply counts the number of vowels inputted by the user. Here's where I am.

Code:
#include <iostream>
using namespace std;
bool isVowel(char ch);
int main() {
int count=0;
char character;
int vowelcount=0;

[Code] .....

View 14 Replies View Related

C :: Iterate Through A User Inputted Integer?

Oct 5, 2014

I need to allow the user to input an integer of any length and print out the word of each number in the integer. So the user would enter "324562" and then the output would be "three two four five six two". I'm struggling to understand the best way to do it in C. I know I need a loop that goes through the int but I don't know how to do it

View 7 Replies View Related

C :: User Inputted Validated Grade As Percentage

Jan 2, 2014

I am trying to get this program to accept two inputs Student number and grade and validate them both

However the program skips over the student number

Code attached AssignmentProgram.c

View 1 Replies View Related

C++ :: Add Score Between 0 And 1000 Inputted By User To Total And Increase Level

May 9, 2013

The program is supposed to have a method called Hitscore that adds a score between 0 and 1000 inputted by the user to the total score and increases level by one and print the score to the screen and which level they last completed after each entry . Have the user continue inputting scores to the program until the gamer has finished all 10 levels. After 10 levels, use a method you create called PassScore to have the program compare the score to avgscore (5000). If the score is less than avgscore, have the code respond "You are not angry at all. " if it is above avgscore, then have it respond "You seem quite angry, calm down. " and if it is exactly 5000, have it respond "Average, just average. "

//Angrybird.h
#ifndef ANGRYBIRD_H
#define ANGRYBIRD_H
using namespace std;
class Angrybird {
public:

float newscore;
float level;

[Code] .....

View 1 Replies View Related

C++ :: Creating A Game - Read Prices Of Object Inputted By User From A File

Feb 19, 2013

How do i read a specific part of a file? I am trying to create a game that reads the prices of an object inputted by the user from a file. This is the code i have so far

#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream infile;
infile.open ("Objects.txt", ifstream::in);

[Code] ....

The file contains this :

Example objects
( ) store items
(item) (purchase value)/(sell value)

Grocery Store Items
Fish 5 7
Vegetables 10 15
Drinks 20 30

Weapon Store Items
Pistol 300 375
Rifle 400 500
Ammunition 20 30

View 4 Replies View Related

C :: Print All Numbers Up To The Inputted Number Vertically

Feb 19, 2013

I've written a program which takes a character string and then prints each character vertically so that for instance the string 123 can be written as
1
2
3

no what i need is for all the numbers from zero to the inputted number to print the numbers digits vertically but each number to be printed horizontally so that for instance an input of 11 prints

1 2 3 4 5 6 7 8 9 1 1
0 1

i've made it so that i can print all numbers up to the inputted number vertically; however, i am stuck with a method for making each number print horizontally as described above.

View 3 Replies View Related

C/C++ :: Dynamic Allocation Of Array And Increase Its Size Every Time New Integer Inputted By User

Aug 29, 2014

I'm a little lost with this program. The idea is to dynamically allocate an array and increase its size every time a new integer is inputted by the user. I believe it is a memory leak but as we have just started learning this I'm not sure how to recognise it. Sometimes I can input as many integers as I want other times 2 or 3 before it crashes. When I can input enough values i exit the loop and send it to the sort function and mean calculator function, all works fine there except the last number inputted becomes this huge value not hexadecimal though... As such I'm at a loss as what to look at next, so here you go:

#include <iostream>
using namespace std;
void SelectSort(int [], int);
float MeanCalc(int [], int);
float MedianCalc(int* [], int);

[Code] .....

View 14 Replies View Related

Visual C++ :: Puzzle Game - Implement A Way To Save Board State Throughout User Inputted Path

Mar 16, 2013

I've been trying to figure out how to implement a way to save this board state throughout a user's inputted path. At the end, I need the output to print out the board states (user's path) of how he or she got the puzzle solved. This puzzle is the 15 Puzzle; but we have it to change by the user's input on what size they want to play (3x3 to 5x5). How to save the board state of each user input, then print those out in order from beginning to solved puzzle state. Subsequently, I would also need transferring the board state to change with using a vector to store the size based on user input. How to proceed, using a first search to solve the puzzle from the current board's state.

calculations.h

Code:
/*Calculations set as a header to keep compiling simple and faster*/

#ifndef calculations
#define calculations
int solved[5][5];
void initialize(int board[][5], int);
void slide(int board[][5],int move,int);
bool isBoardSolved(int board[][5],int);

[Code] .....

View 6 Replies View Related

C++ :: Program To Determine Number Of Inputted Riders And Closes When Input Is -1?

Jan 16, 2015

I seem to be having a logical error but can not find the sources.

#include <iostream>
using namespace std;
int main() {
int student = 0;
int adult = 0;

[Code] ....

View 1 Replies View Related

C++ :: Binary Search Function - Return True If Element Inputted By User Found In Array And False If Not

Nov 9, 2014

I was instructed to write a binary search function which would return true if an element, inputted by the user, was found in the array, and false if it was not. I'm not sure why, but my function always returns false. My code is as follows.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
//binary search function
bool search (int array[], int item)

[Code] ....

Why my code does not fulfill it's purpose???

View 7 Replies View Related

C/C++ :: Display Inputted Values Without Overwriting Other Inputted Values

Jun 16, 2014

How can I display my inputted values here without overwriting the other earlier inputted values. It should be displayed like this [URL].... but mine shows this [URL].... I've been stucked here for hours in thinking for an algorithm. Everything is working fine except the PDISPLAY part

#include<iostream>
#include<iostream>
#include<string>
#include<cctype>
#include<cstdlib>
#include <iomanip>
#include <windows.h>
#include<conio.h>

[Code]...

View 1 Replies View Related

C/C++ :: Compare Values Stored In First Array To User Inputted Values In Second Array

Oct 19, 2014

Goal: Write a program that compares the values stored in the first array to the user inputted values in the second array.

In order to fix this error: [URL]...

I had to change my array initialization to one with a star in front of it:

char a1[]={"a","d","b","b","c","b","a","b","c","d","a","c","d","b","d","c","c","a","d","b"};
to:
char *a1[]={"a","d","b","b","c","b","a","b","c","d","a","c","d","b","d","c","c","a","d","b"};

I also changed my 2nd array to one with a star in front of it: char *a2[20];

What does this mean exactly? Putting a star in front of an array?

Also, I am now getting an "unhandled exception" when I try to get input for my 2nd array:

cin>>a2[i];

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++ :: Receive Number From User And Output Largest Prime Number

Nov 20, 2014

I am attempting to write code that receives a number from the user and outputs the largest prime number underneath the user's number. There are no errors in my code, but no matter what number is imputed, the program says the largest prime number is 1. I cannot find where the issue is in the code. Here is the code I wrote:

#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int num);//function prototype

[Code] ....

View 2 Replies View Related

C/C++ :: Find Max Number Entered By User And Terminate When Negative Number Entered

Jul 15, 2014

I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.

#include <iostream>
using namespace std;
int Max(int x);
int main() {
int x;

[Code] ....

View 9 Replies View Related

C :: Know If Letter Is Inputted Twice

Sep 23, 2013

how can my program read if a letter is inputted again it prompts "letter inputted already"? heres my code:

Code:

#include <stdio.h>
#include <string.h>
#include <conio.h>

[Code].....

View 8 Replies View Related

C/C++ :: How To Mix Each Number Given By User Input

Jun 29, 2014

There's this program I'm trying to code where the user gives input of 2 values.

Sample :-

Value of X: 1234
Value of Y: 234567
Reversed value X: 4321
Reversed value of Y: 765432
New value as Z: 1223344567 (each number was taken in both X and Y)

Now the thing is I could do the reverse, and I've been trying to find out how.

Here's my code,

#include <iostream>
using namespace std;
int main(){
int x=0, y=0;
int reverse_x=0;
int reverse_y=0;
int z = 0;
int l;

[Code]....

What I thought about that area where I've put a comment on, I was wondering if I code a loop for the amount of times x gets divided by 10 until it becomes 0 and store it in the value, same thing for Y, and add the value together to get Z. But if that's how it is then how I could use that concept here.

View 5 Replies View Related

C/C++ :: How To Mix Each Number Given By The User Input

Jun 29, 2014

There's this program I'm trying to code where the user gives input of 2 values.

Sample :-
Value of X: 1234
Value of Y: 234567
Reversed value X: 4321
Reversed value of Y: 765432
New value as Z: 1223344567 (each number was taken in both X and Y)
Now the thing is I could do the reverse, and I've been trying to find out how.

Here's my code,

#include <iostream>
using namespace std;
int main(){
int x=0, y=0;
int reverse_x=0;
int reverse_y=0;
int z = 0;
int l;

[Code]...

What I thought about that area where I've put a comment on, I was wondering if I code a loop for the amount of times x gets divided by 10 until it becomes 0 and store it in the value, same thing for Y, and add the value together to get Z. But if that's how it is I can't seem to really get that idea how I could use that concept here. I'm not really good with programming, fairly new at this.

View 1 Replies View Related

C++ :: Parsing String To Contain Inputted Int

Sep 10, 2014

I have been here for almost 3 months looking for answers in my C++ problems.here's some type of code for this.

cout << "Enter value of x: " << endl; //Let's say 5.
cin >> x;
cout << "Enter equation: "; //Let's say x+1
cin >> equation;

Then the program analyzes that this character "x" has an initial value of 5.I already have the parser for the equation functions (+,-,*,/)This is the only thing lacking. Is there some type of function that i missed?

View 6 Replies View Related

C++ :: How To Display Inputted Values

May 10, 2013

Program works perfectly fine. I input in the length, width and height. But i want it to display those values for every individual prism when i output... along with the area and volume which i already have. Since i made a vector i won't let me cout it normally.

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

[Code].....

View 2 Replies View Related

C/C++ :: How To Encrypt The Password To Be Inputted

Sep 14, 2014

#include<stdio.h>
#include<conio.h>
#include<string.h>
char str1[20], str2[20]="kent";
main() {
printf("Enter your Username: ");
scanf("%s",str1);

[Code] ....

View 1 Replies View Related

C/C++ :: Testing To See If User Input Is A Number

Feb 10, 2013

I was wondering what function was the C++ equivalent for testing to see if a user input is numeric.

I have equivalents in Ruby, Java, Python, VB, VBA, php, but being a novice in C++, I have yet to find one - even with Google.

And I know C++ is such a wonderful language, that its extensive library must have one somewhere - considering it's already 2013!

View 2 Replies View Related







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