Dice Roll 3 Solution

 You're programming a backgammon game, and are working on the dice roll method. Given two ints, return their sum. However, if the two numbers are the same, return double their sum.

image

Input Format

Two space separated integers

Constraints

No constraints

Output Format

the output displays an integer

Sample Input 0

10 20

Sample Output 0

30





Program :

#include <stdio.h>

#include <string.h>

#include <math.h>

#include <stdlib.h>


int main() 

{

    int a=0,b=0,sum=0;

    scanf("%d%d",&a,&b);

    if (a==b)

    {

        sum=(a+b)*2;

        printf("%d",sum);

    }

    else

    {

        sum=(a+b);

       printf("%d",sum);

    }

    return 0;

}


Post a Comment

0 Comments