Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

C++ I want to make it so that I get a var named totalx but I want the x to change with the for loop

+5 votes
asked Apr 10, 2018 by SavageMango (310 points)
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>

using namespace std;
    

int bowl()
{
 srand(time(NULL));
 for(int x=0;x<9;x++)
 {
   cout<<"Frame"<<x+1<<endl;
   int arr[49]={0,0,0,0,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,9,9,9,10,10,10};
   int RandIndex = rand() % 49 ;
    if (9 >= arr[RandIndex] >= 1 and arr[RandIndex] != 0)
    {
     cout<<"You knocked down "<< arr[RandIndex]<< " pins!"<<endl;
     int RandNumber = rand() % 49 ;
        if (arr[RandNumber]+arr[RandIndex] >= 10)
        {
            cout<<"Spare!"<<endl;
        }
        else
            if (9>=arr[RandNumber]>=1 and arr[RandNumber] != 0)
            {
                cout<<"You knocked down "<< arr[RandNumber]<< " pins!"<<endl;
                arr[RandNumber]+arr[RandIndex]=;
            }
            
            else
            {
                cout<<"You threw a gutterball:("<<endl;
                arr[RandNumber]+arr[RandIndex]=;
            }
             
    }
   
    if (arr[RandIndex]== 10)
    {
      cout<<"Strike!"<<endl;
      cout<<"X"<<endl;
    }
    
    if (arr[RandIndex]== 0)
    {
     cout<<"You threw a gutterball :("<<endl;
     int RandNumber = rand() % 49 ;
        if (arr[RandNumber]+ arr[RandIndex] >= 10)
        {
            cout<<"Spare!"<<endl;
        }
        else
            if (9>=arr[RandNumber]>=1 and arr[RandNumber] != 0)
            {
                cout<<"You knocked down "<< arr[RandNumber]<< " pins!"<<endl;
                arr[RandNumber]+arr[RandIndex]= ;
            }
            
            else
            {
                cout<<"You threw a gutterball:("<<endl;
                arr[RandNumber]+arr[RandIndex]= ;
            }
       
    }
    cout<<Total<< endl;
 }  
   

    
  
    
    
}

int main()
    {
      bowl();
    }

2 Answers

0 votes
answered Jan 5, 2023 by Max Jian (730 points)
I think that isn’t possible ;-;
0 votes
answered Jan 5, 2023 by Max Jian (730 points)
oh ok this was 2 years ago ;-; ;-;-;-;-;-;
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...