C++ :: Numbers Game - Store Current Low Number

Dec 14, 2013

I have a program that stores current a low numbers. The Object is to Store the low number every time time one is presented. so say I start the function the first number is the low number. but the trouble im having it once the function is called again it starts over(low number). Is there a way I can keep the function value once the function is called again? Any better way of doing this while keeping function in a class?

double a;
class rff{
public:
void FGH() {
doubleb=0;
cout<< "pick a number"<<endl;

[Code] ....

View 1 Replies


ADVERTISEMENT

C :: Display Current Time And Date In Program And Use Variable To Store Each Of Values

Feb 16, 2013

i need to display the current time and date in my program and use variable to store each of the time values like

a = 10
b = 29
c = 31

printf(``%d : %d : %d``, a,b,c);

which then give the output as - 10:29:31

How to save the time in variables in C....

i am using C in windows 7 and my complier is Bloodshed Dev C++

View 7 Replies View Related

C++ :: Summation Of Numbers In Current And Previous Iterator

Jul 9, 2012

Below is the sample of the code :

int summation = 0;
for (it= s.begin(); it!= s.end(); ++it) {
summation += std::atoi( ((*it).substr( 8 )).c_str() );
}

Nos after the first 8 characters are the ones I need to perform addition on.

do the summation of these nos.

View 14 Replies View Related

C++ :: Find Prime Numbers Between Given Pair Of Numbers And Store Them Into Array?

Apr 18, 2014

Find all the prime numbers between a given pair of numbers. Numbers should be read in from an input file called "numbers.txt" and find all the prime numbers between them. Store the prime numbers in an array, then sort the array from greatest to least. Display the array before and after the sort.

I'm stuck on how to put the prime numbers into an array.

The input file has the numbers 1 & 100.

Here's what I have so far.

#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin;
fin.open("numbers.txt");

[Code] .....

View 1 Replies View Related

C/C++ :: Madd Libs Game - How To Store Inputted Strings Or Values To Arrays

Nov 11, 2014

My assignment is writing Madd Libs game. I still do not understand how to store inputted strings or values to arrays. I need explanation of collecting inputted data to arrays.

#include "stdafx.h"
#include<stdio.h>
//#include<string.h>
int main(void) {
char string[37] = {''};
char adjective1[15];

[Code] ....

View 14 Replies View Related

C++ :: Guessing Game With Numbers Between 1 And 100

Apr 22, 2014

I neeed to Create a guessing game with numbers between 1 and 100. The loop will never exit until the condition is met. The user will continually guess and display:

Sorry Too Low
Sorry Too High
You Guessed Right

** YOU MUST USE THE BOOLEAN VARIABLE… when the boolean is true, the loop will exit **

This is what i got so far;

#include <iostream>
using namespace std;
int main() {
//Declaring Variables
int guess=50,x;

[Code] .....

View 2 Replies View Related

C :: Store Random Numbers In Array

Jan 11, 2015

i cannot print the values stored in the array ?

Code:
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<stdlib.h>
double randf();

[Code] ....

View 7 Replies View Related

C++ :: How To Store Names And Numbers In Array

Jul 25, 2014

Can names and numbers be stored in one array ? Like a telephone directory?

View 1 Replies View Related

C/C++ :: Program Which Ask For X Numbers And Store Them In Array

Nov 22, 2014

This is in c. Write a program which asks for X numbers, and stores them in an array.

The program then asks the user to enter a number to look for, and tells the user how many times that number appears in the array of numbers (if any), and the array index which contain the number

Make an array of the indexes where the number was found, and then format your output to match my output.

Sample Run:

How many numbers would you like to enter: 5

Please enter a number:1
Please enter a number:2
Please enter a number:3
Please enter a number:4
Please enter a number:2

The numbers you enter were: 1, 2, 3, 4, 2
Please enter a number to find: 2
The number appears 2 times, at array ellements with indexes 1, 4

Press any key to continue . . .

View 10 Replies View Related

C++ :: Retrieve Double Number - Store 8 Bits Of Number In One Field And 16 Bits In Another

May 14, 2013

I am working on a project where I need to retrive a double number and store 8 bits of the number in one field and the other 16 bits in another field. the code below gives me an error.

lata= lat>>8;
latb = (lat & 0xff);

The error states that & and >> are illegal for double. With this in mind, can I use these on a double. If not what can I do to achieve what I am trying to do?

View 1 Replies View Related

C :: How To Store All Random Generated Numbers In Array

Feb 27, 2013

So we're having an assignment for school where you code a Roulette game which simulates you playing and you can choose how many times you "play" to check how many times you'd win (if that makes any sense, im german :P)

Anyways, the problem is how do i store all the random generated numbers in an array while NOT doing this (it's just a snip):

Code:

void randomzahl(void){
int i;
int zahl5[5];
int zahl10[10];
int zahl100[100];
int zahl1000[1000];
int zahl10000[10000];
if(runden == 5)

[Code]...

View 3 Replies View Related

C :: Code That Will Store PID Numbers Of Child After A Fork?

Aug 8, 2013

I am currently trying to write a code that will store PID numbers of a child after a fork, I have to be able to enter an amount that will be created, so far I have managed to be able to get them to print (which puts me on the right path as far as I am concerned) but I am having issues. Using the following code:

Code:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

[Code].....

View 3 Replies View Related

C++ :: Program To Store 10 Decimal Numbers In Array

Sep 24, 2014

Write a program which stores 10 decimal numbers in an array. For these numbers accept input from the users. Once the array is populated do the following:

Display each elements of the array
Display the sum of all the elements of array

View 1 Replies View Related

C++ :: Store Random Numbers And Sort Function

Oct 7, 2014

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <algorithm>
using namespace std;

const int s = 12, p = 6;
int x[s][p];

[Code] ....

Names: P1 P2 P3 P4 P5 P6 AVER.

EVIKE 41 85 72 38 80 69 64.17
KKASV 65 68 96 22 49 67 71.86
YCXFX 51 61 63 87 66 24 70.64
FADPO 80 83 71 60 64 52 80.11
OEJUV 90 60 49 31 23 99 72.02
POEYL 94 11 25 24 51 15 48.67
VRVIP 13 39 67 97 19 76 59.94
QNQRQ 12 33 99 18 92 35 58.16
OOVAO 74 0 95 71 39 33 61.69
NCBXC 39 32 37 45 57 71 57.12
ATXDK 95 5 71 24 86 8 57.69
IXJSW 51 54 74 24 75 70 67.61
AVER. 58.75 49.15 72.35 51.11 62.68 56.81

1: Sort Alphabetically
2: Sort Grades Increasing Order (Student)
3: Sort Grades Increasing Order (Project)
4: End Program Enter choice: 2

Names: P1 P2 P3 P4 P5 P6 AVER.

XXZRZ 41 72 38 80 69 65 60.83
OKETL 68 85 22 49 67 51 67.14
GZQRC 61 63 87 66 24 80 74.69
OJWAY 83 71 60 64 52 90 82.45
PSAJL 60 49 31 23 96 94 72.57
AOVLZ 11 25 24 51 15 13 35.26
CPWSR 39 67 97 19 76 12 57.54
IZCOB 33 99 18 92 35 74 68.09
IJTVD 0 95 71 39 33 39 57.52
LDVGY 32 37 45 57 71 95 65.75
MBORX 5 71 24 86 8 51 51.79
XOHGM 54 74 24 75 70 0 58.13
AVER. 40.58 70.72 50.98 62.66 56.56 60.05

1: Sort Alphabetically
2: Sort Grades Increasing Order (Student)
3: Sort Grades Increasing Order (Project)
4: End Program Enter choice:

Why my sort is not working. Also, I want to keep the same random numbers for the continuation of the program, I don't want new randomized values when I display the table.

View 4 Replies View Related

C/C++ :: Using Linked List To Store Guessed Numbers

Apr 26, 2015

Rewriting a program to convert an array based list to a linked list. The program has a user guess a number [1-100] until the correct answer is guessed. I only want to give hints if a duplicate isn't guessed.

while (aGuess-> != p->guess) doesn't work and I haven't been able to troubleshoot myself.

while (aGuess->guess != p->guess) {
if ( aGuess->guess > a ) {
cout << "That's too high -- try again: ";
} // if guess > a

[Code] ....

View 1 Replies View Related

C/C++ :: How To Store 50 Digit Number

Sep 14, 2013

what is the data type of a variable to store 50 digit number in c? and what is the data type specifier for that?

View 5 Replies View Related

C++ :: Program To Play Numbers Guessing Game

Dec 14, 2014

"Write a program to play a numbers guessing game. The user thinks of a number between 1 and 100 and your program asks questions to figure out what the number is (e.g., "Is the number you are thinking of less than 50?"). Your program should be able to identify the number after asking no more than seven questions. Hint: Use < and <= opeartors and the if-else construct."

What I've managed so far, but what I have seems to be lacking

Code:
#include "../../std_lib_facilities.h"

int half(int guess);
int going_up(int i);

int main()

[Code] ....

View 4 Replies View Related

C :: How To Store The Highest Prime Number

Feb 17, 2013

Basically, I am suppose to compute 10 numbers and find their highest prime number for each of them. I've already have the inputs working, and set up 2 arrays to store inputs and their highest prime number. But I am uncertain on how to find and store their highest prime number. How to start it off?

View 7 Replies View Related

C :: Input Number - How To Store 500 Digits

Oct 30, 2013

"Every number has at most 500 digits" under input. 500? How am I supposed to store that? And what if someone multiplies 999 ...(500 times) * 999 ... (500 times) ? I seriously doubt that my computer can store that! Is that just some huge value used to scare people off or is there some sneaky trick that I am unaware of?

I am done with the program, but won't post it, Lets not ruin the fum for ohers...Does that 500 limit also applies to result of operation?So max length of an input number is ~22 digits ? But still, how do I store 500 digits? Array would be a lot of wastage of memory (though I do have 256MB available).

View 2 Replies View Related

C++ :: How To Generate And Then Store Random Number

Nov 6, 2014

So I have to generate a random number between 1 and 6 and then store that same random number into an int variable. Eg, if the random number is 4, that must be stored into int i.

View 7 Replies View Related

C :: Guess Random Number Game

Aug 9, 2013

I have an error on my Guess the random number game.When you got the right answer it shows the "You got the right answer" and shows the "What is the number?" Here is the code.

Code:

#include<stdio.h>
main()
{
srand(time(0));
int x=rand() % 101,guess=0,tries=3;
printf("The computer will generate a random number, try and guess the random number.
}

[code]....

View 3 Replies View Related

C :: Random Number Guessing Game

Feb 13, 2013

Code:

#include <conio.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#define MAX 100
}

[code].....

I am completely stuck when assigning values to and passing variables around. It seems that the problem occurs with fscanf function. I have also guessed that it might be passing and reading it as a character, even though I said it will be an integer, and tried atoi() with no luck. I troubleshooted the error as I tried to print the given values after I assign it. I am doing this for a friend I have recently been programming django, so I am completely out of the loop when it comes to C. where I am assigning converting passing in a wrong way?

View 2 Replies View Related

C++ ::  Programming A Random Number Game

Nov 21, 2013

This is the code i have so far

#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

/* function main begins program execution */
int main() {

[Code] .....

I have gotten the conditions to execute properly but will end the program after doing a case instead of asking to play again and loop. Also how would i output the number of wins and losses?

View 2 Replies View Related

C# :: Random Number Guessing Game?

Oct 13, 2014

The question for homework is Create an application that generates a random number in the range of 1 through 100 and asks the user to guess what the number is. If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the program should display “Too low, try again.” If the user guesses the number, the application should congratulate the user and then generate a new random number so the game can start over"

I have no errors in my code, but when it compiles it and I type the number in, and hit calculate nothing happens at all. Im baffled. Here is my code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

[Code].....

View 4 Replies View Related

C/C++ :: Complex Number Guessing Game (SOS)

Mar 12, 2014

the only problem I have is where to add

want to play again? y
OK, I am thinking of a number. Try to guess it.
Your guess?
...

want to play again? no
Goodbye

Code :

#include <stdio.h>
#define TARGET 23
#define LOW 1
#define HIGH 100
#define TRUE 1
#define FALSE 0
#define GUESS 6
int process( int guess, int target );

[Code] ....

View 1 Replies View Related

C++ :: Program Read In 15 Integers From User Then Store And Print Out Numbers

Apr 29, 2014

I want to write a program to read in 15 integers from the user, and then store them in a 5x3 array, and print out the numbers as a 3x5 array.

View 7 Replies View Related







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