crazy_person's Profile User Rating: -----

Reputation: -1 Dishonored
Group:
Members
Active Posts:
18 (0.03 per day)
Joined:
27-May 12
Profile Views:
350
Last Active:
User is offline Aug 22 2012 03:05 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
XBox
Your Car:
Who Cares
Dream Kudos:
0
Icon   crazy_person has not set their status

Posts I've Made

  1. In Topic: Number guessing game

    Posted 11 Jun 2012

    I didn't add the globals to the program, they were there. But anyway my bad.
  2. In Topic: Number guessing game

    Posted 11 Jun 2012

    You didn't assign generateNumber any value, plus you didn't pass any arguments to the functions leaving review guess unused.

    here is what i got, don't know if it is what you need:
    // Week2 GuessingGame.cpp : Defines the entry point for the console application.
    //
    
    #include <iostream>
    #include <time.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    using namespace std;
    //int _tmain(int argc, _TCHAR* argv[])
    
    	//declare variables
    	int generateNumber; //generated number
    	int guess; //user input guess
    	int c;
    	int check;
    	
    	bool reviewGuess(int guess_param, int generateNumber_param){
    		return (guess_param == generateNumber_param);
    
    	}
    	int game(int random_number){
    		
    	//loop to check the user input until the guess is correct
    	do {
    		
    		printf ("Please guess a number between 1 and 10: ");
    		scanf("%d", & guess); //user input
    		
    		if (reviewGuess(guess, random_number)==false)
    		{
    			printf("Incorrect number\n");
    		}
    	}
    
    	while (reviewGuess(guess, random_number)==false);
    	puts ("You have guessed correctly! Good Job!"); //guess is correct
    
    	system("PAUSE"); //pause before exiting
    	return 0;
    }
    
    	void generateRandom() {
    		
    		srand(time(0));
    		int generateNumber=(rand()%10)+1; //= rand() %10 + 1; //generate number between 1 and 10
    		game(generateNumber);
    	}
    
    	
    	int main(){
    		 //random seed
    		generateRandom();
    		return 0;
    	}
    
    
    
    
  3. In Topic: Bool how does it work?

    Posted 10 Jun 2012

    View Postbaavgai, on 10 June 2012 - 03:55 AM, said:

    It also commits a major tweak, for me. So, since we're abusing it.

    Never, ever, do if (condition) { return condition; } else { return !condition; }. Just: return condition;

    So: bool type_top(char x) { return (x=='y'); }

    Ok, I feel better, sorry for the detour.

    P.S. I feel the same way about if (condition==true) instead of if (condition)...


    Sorry for the wrong post, but just trying to figure this out. So this function will only return true if x=='y'? I haven't seen a book formatted like that before, but then again I'm pretty new lol
  4. In Topic: Bool how does it work?

    Posted 9 Jun 2012

    View Postrrclarke, on 09 June 2012 - 03:27 PM, said:

    Hello, i want to use an true or false statement, im making a car rental system and what im trying to ask if they want a softtop or not so when they come to book it a message will ask them if they want it or not if yes then it will store that if not goes onto the next question how would i do that?

    You could use a bool function:

    bool type_top(char x)
    {
        if (x=="y")
         {
            return true;
         }
        else
            return false;
    }
    
    int main()
    {
    char choice;
    std::cout<< "Do you want a softtop? (y,n)" << std::endl;
    std::cin >> choice;
         if (type_top(choice))
          { 
    
              //they chose a softtop
          }
         else if (!type_top(choice))
          {
              //they didn't say yes to a softtop
          }
    
          return 0;
    }
    
  5. In Topic: Problem 3--project euler

    Posted 9 Jun 2012

    Haha kk ty i got it now :)

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Full Name:
Wil Prim
Years Programming:
2
Programming Languages:
C/C++, Python, php

Contact Information

E-mail:
Private

Friends

crazy_person hasn't added any friends yet.

Comments

crazy_person has no profile comments yet. Why not say hello?