Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:03:52+00:00 2026-06-09T07:03:52+00:00

i am trying to have a function determine the result a. If the numbers

  • 0

i am trying to have a function determine the result

a. If the numbers add up to 5, 7, or 12, then the player wins, and the function should return an indication of this (use some integer to represent a win).
b. If the numbers add up to 2, 4, or 11, then the player loses, and the function should return an indication of this (once again, use an integer).
c. If the numbers add up to anything else, then the game is a draw and the function should say this (by way of an integer).

question, do i need a different func for winner, loser, and draw?

and what how can i return a integer to main to let main know that if we have a winner a loser a draw.

just learning to program any help would be greatly appreciated

 //function
 int outcome(int, int)
    {
    int die1;
    int die2;
    int winner;
    int loser;
    int draw;

      if (die1&&die2==5||7||12)

      return 99;

      if (die1&&die2==2||4||11)

      return loser;

      else
      return draw;
      }



    // func to get a random number
    int rollDice()
    {
    int roll;

    roll = (rand()%6)+1;

    return roll;
    }

the main func

#include <iostream> 
#include <cstdlib> 
#include <fstream> 

using namespace std; 

int main() 
{ 
double die1=0; 
double die2=0;
int winner=0; //counter for winners   
int loser=0; //counter for losers
int draw=0; //counter for draw 

//func to determine the outcome 
int outcome(int, int); 

//func for random numbers 
int rollDice(); 

int outcome(int, int) 
if (return==99) 
    cout <<"winner";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:03:53+00:00Added an answer on June 9, 2026 at 7:03 am

    Your code has several syntax errors. If I want to, say, make a function to add two integer numbers, I’d do something like this:

    int add(int a, int b) //VARIABLES MUST CARRY A NAME!
    {
        return a+b;
    }
    

    If you want to work with conditions, do this:

    if(a==5 && b==6 || a==6 && b==7) //Just as an example
    

    Your fixed condition would be this:

    if (die1+die2==5 || die1+die2==7 || die1+die2==12)
    

    Also, study variable scope. Let’s say I have the following:

    int main()
    {
        int myVar = 1;
    }
    
    int anotherFunction()
    {
        println("%d", myVar); //This will cause an error, because myVar doesn't exist here, it only exists in main()
    }
    

    These are the most notable errors I can see in your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn JavaScript... I have function like, I take the format
I have a function that I'm trying to optimize at the moment but I'm
Hi I have a function in R that I'm trying to optimize for performance.
I have a function with a chain of filters in jQuery. I am trying
I have a function hitting a JSON file, and I am trying to get
I currently have a function where I'm trying to refer to the $id in
I have a function that creates a course. I am trying to get the
Trying to get a list of all substrings currently I have a function but
I'm trying to get rid of floats in my functions. I have one function
I have been trying to call the NewPixelRegionIterator function in ImageMagick's library from C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.