Help! It's Killing Me

Jul 14, 2011 at 4:33pm
closed account (9wX36Up4)
İ don't Know english well so i will try to tell with my best.
I wrote these codes but it's sure it's not working well. And it's killing me that can't find what the problem is!!
#include<iostream>

using std::cout;
using std::endl;
using std::cin;

main()
{
      int a,d1,d2;
      char dice,startgame;
      
      cout<<"To Start Please Push A Button!"<<endl<<"Waiting..."<<endl;
      cin>>startgame;
      if(startgame=='a'||startgame=='A){
               cout<<"To Dice Please Push Button Z!"<<endl<<"Waiting..."<<endl;
               while(a=1;a<=1000;a++){
                   cin>>dice;
                   if(dice=='Z'||dice=='z'){
                           d1=1+(rand()%6);
                           d2=1+(rand()%6);
                           cout<<"     First Dice :"<<d1<<endl<<"    Second Dice :"<<d2<<endl;}
                   else
                           cout<<"Error :Only Z Button can dice"<<endl;
      else{
              cout<<"Wrong Button!!!"<<endl;
              return main();}
}

What i want to do is here. http://imageshack.us/photo/my-images/96/skillingme.jpg
I just want to make a program that doing randoming two dice depend on a time 0<time<37
Jul 14, 2011 at 4:48pm
Well, it would help if you said what the problem is.
However, this is not a valid: main()
You forgot the return type, it must int main()

Nor is this valid: return main();
main() is not a regular function and you're not allowed to call it yourself.
Jul 14, 2011 at 4:52pm
closed account (9wX36Up4)
i did what u said but it still giving errors Athar i need a detailed help.
Jul 14, 2011 at 4:53pm
Try to line up your code so it is easier to read, maybe space it out.
Then you can maybe see what is wrong, but the error codes should tell you what you need to do.
You are missing quotation marks and closing braces.
Jul 14, 2011 at 4:55pm
i did what u said but it still giving errors Athar i need a detailed help.

Sorry, but can't you read?

Well, it would help if you said what the problem is.


And read this first of all:
http://www.cplusplus.com/forum/beginner/1/
Last edited on Jul 14, 2011 at 4:56pm
Jul 14, 2011 at 5:00pm
closed account (9wX36Up4)
#include<iostream>

using std::cout;
using std::endl;
using std::cin;

int main()
{
      int a,d1,d2;
      char dice,startgame;
      
      cout<<"To Start Please Push A Button!"<<endl<<"Waiting..."<<endl;
      cin>>startgame;
      if(startgame=='a'||startgame=='A')
      {
               cout<<"To Dice Please Push Button Z!"<<endl<<"Waiting..."<<endl;
               while(a=1;a<=1000;a++)
                   {
                   cin>>dice;
                   if(dice=='Z'||dice=='z')
                   {
                           d1=1+(rand()%6);
                           d2=1+(rand()%6);
                           cout<<"     First Dice :"<<d1<<endl<<"    Second Dice :"<<d2<<endl;
                   }
                   else
                           cout<<"Error :Only Z Button can dice"<<endl;
                   }
      }
      else
      {
              cout<<"Wrong Button!!!"<<endl;
              return main();
      }
}


I have turn it to this And it still gives error and the error is 'expected before token )' in line 17. I m saying i couldn't find the problem. i don't know enough becouse i m a beginner.
Last edited on Jul 14, 2011 at 5:03pm
Jul 14, 2011 at 5:07pm
First of all don't use quote for code. Use code.

At line 17 you have a mutant while(a=1;a<=1000;a++). It should be a for.
Jul 14, 2011 at 5:09pm
closed account (z05DSL3A)
You are missing a closing brace for the while loop and the while loop is some kind of love child of a for loop and a while loop.
Jul 14, 2011 at 5:23pm
closed account (9wX36Up4)
First of all don't use quote for code. Use code.

At line 17 you have a mutant
while(a=1;a<=1000;a++)
. It should be a
for
.

thank u Catfish it work finally
Last edited on Jul 14, 2011 at 5:24pm
Topic archived. No new replies allowed.