Thread: C++ Simple Puzzle Word Game

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    1

    Thumbs up C++ Simple Puzzle Word Game

    Here is my code
    I want to calculate the point score by the user. For example for each puzzle word would get 1 point if the puzzle word is correct. And Display the total score

    like this (lppea= apple) 1 point.
    sorry for my bad English.
    Code:
    #include<iostream>
    #include<string>
    using namespace std;
    int main()
    {
    	const int a=3;
    	string word[a]={"apple","ball","cat"};
    	string nword[a]={"lppea","lalb","cta"};
    	string j;
    	int point;
    	int p=0;
    	int ctr=0;
    
    	
    	cout<<"BASIC"<<endl;
    	for(int i=0; i<a; i++)
    	{
    		cout<<nword[i]<<endl;
    		cin>>j;
    		
    		 
    	
    		ctr++;
    		if(j==word[i])
    		{
    			cout<<"==========Congratulation========="<<endl;
    			cout<<"==========You Have Score:"<<endl;
    			cout<<"       "<<i+1<<" "<<"Point"<<endl;
    			 
    		}
    		else
    		{
    			cout<<"Wrong"<<endl;
    		}
    		
    	}
    	//cout<<"Your Score Is:"<<point<<endl;
    	return 0;
    }
    Last edited by ijAcK; 09-23-2008 at 09:56 AM.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    What is crt supposed to count? Why can't you similarly increment the counter for correct answers if the answer matches?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    1) Yeah, why not increment the counter point whenever a point is scored?
    2) You need to add a cin.ignore() after the cin>>j;, since it will leave the \n character and that would be read by the cin>>j of the next iteration.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help using arrays ( simple hangman game)
    By skymoha in forum C Programming
    Replies: 2
    Last Post: 03-04-2009, 04:52 AM
  2. Replies: 7
    Last Post: 06-16-2006, 09:23 PM
  3. Simple driving game
    By VirtualAce in forum Game Programming
    Replies: 6
    Last Post: 07-06-2004, 09:34 AM
  4. Im a Newbie with a graphics design problem for my simple game
    By Robert_Ingleby in forum C++ Programming
    Replies: 1
    Last Post: 11-23-2001, 06:41 PM
  5. Whats a very simple but good game i can try to make?
    By bluehead in forum C++ Programming
    Replies: 2
    Last Post: 11-06-2001, 09:24 PM