simple c programs
Budget: $10 – $30 USD
Problem 1 - Dice
In this program, you will build upon your program for project 1 (Write a C program to simulate a simple dice game. In this game, there are two players. Each of
the players throws a cubical dice with distinct numbers from 1 to 6 written on its faces. Player,
whose value after throwing the dice is greater, wins the round. In case if player dice values are
equal, no one of them is a winner. )
to allow multiple
rounds of the game. In average, player, who won most of the rounds, is the winner of the
game. In case if two players won the same number of rounds, the result of the game is draw.
Example input/output:
Input:
Enter the number of rounds: 3
Output:
Round 1: Player 1’s number is 6, Player 2’s number is 5.
Round 2: Player 1’s number is 4, Player 2’s number is 6.
Round 3: Player 1’s number is 4, Player 2’s number is 4.
It’s a draw!
1. Name your program project2_dice.c
2. The user enters the number of rounds for the game.
3. Use a for loop for counting rounds of the game.
Problem 2 – Characters
In this program, you will calculate the result of an arithmetic operation of two single digit
positive integers. The program allows add, subtract, and multiply two single digit positive
integers by entering either +, -, * between the integers.
Example input/output #1:
Enter input: 7 – 3
Output: 4
Example input/output #2:
Enter input: 7 * 3
Output: 21
1) Name the program project2_arithmetic.c
2) Use getchar() function to read in the input. Do not use scanf.
3) There might be any number (1 or more) of white space(s) before the first integer,
between the integer and the operator in the input, or after the second integer.
4) The user input ends with the user pressing the enter key (a new line character).
5) The input format is exactly in the format of: integer1 operator interger2
6) Use switch statement to process the operator and the math.
7) If the operator entered is not one of the acceptable operators, display an error message
as the result.
In this program, you will build upon your program for project 1 (Write a C program to simulate a simple dice game. In this game, there are two players. Each of
the players throws a cubical dice with distinct numbers from 1 to 6 written on its faces. Player,
whose value after throwing the dice is greater, wins the round. In case if player dice values are
equal, no one of them is a winner. )
to allow multiple
rounds of the game. In average, player, who won most of the rounds, is the winner of the
game. In case if two players won the same number of rounds, the result of the game is draw.
Example input/output:
Input:
Enter the number of rounds: 3
Output:
Round 1: Player 1’s number is 6, Player 2’s number is 5.
Round 2: Player 1’s number is 4, Player 2’s number is 6.
Round 3: Player 1’s number is 4, Player 2’s number is 4.
It’s a draw!
1. Name your program project2_dice.c
2. The user enters the number of rounds for the game.
3. Use a for loop for counting rounds of the game.
Problem 2 – Characters
In this program, you will calculate the result of an arithmetic operation of two single digit
positive integers. The program allows add, subtract, and multiply two single digit positive
integers by entering either +, -, * between the integers.
Example input/output #1:
Enter input: 7 – 3
Output: 4
Example input/output #2:
Enter input: 7 * 3
Output: 21
1) Name the program project2_arithmetic.c
2) Use getchar() function to read in the input. Do not use scanf.
3) There might be any number (1 or more) of white space(s) before the first integer,
between the integer and the operator in the input, or after the second integer.
4) The user input ends with the user pressing the enter key (a new line character).
5) The input format is exactly in the format of: integer1 operator interger2
6) Use switch statement to process the operator and the math.
7) If the operator entered is not one of the acceptable operators, display an error message
as the result.