Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 4, Problem 10E
What would happen if you typed a negative number into
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can you help me with this program?In C++ The room contains n*n cubes (in rows and columns). Each cube is white or black. You can get out of a white cube by going in one of the four directions horizontally or vertically (but you can't go beyond the scope of the room). You can get out in a black cube, but you can't get out of it. There is a mouse and a piece of cheese in the room. The mouse is in a cube (0,0) - white, and the cheese in a cube (n-1, n-1) - black. The mouse can move from cube to cube according to the rules described above. Write a program that finds all the paths that can be moved to the cheese with the mouse and if it appears, display it with ‘*’.
An example diagram of the task is shown in the figure:
Operating instructions: Compose a recursive function path (int i, int j), receiving as parameters the coordinates of the current position of the mouse (initially 0.0, and then run with parameters (i-1, j), (i + 1, j), ( i, j-1) or (i, j + 1)).
Use Python & Don't use any python
Library. You can use
Random.randint() only.
3. Suppose you have been hired to
develop a musical chair game. In this game
there will be 7 participants and all of them
will be moving clockwise around a set of 7
chairs organized in a circular manner while
music will be played in the background.
You will control the music using random
numbers between 0-3.lf the generated
random number is 1, you will stop the
music and if the number of participants who
are still in the game is n, the participants at
position (n/2) will be eliminated. Each time
a participant is eliminated, a chair will be
removed and you have to print the player
names who are still in the game.
The game will end when there will be only
one participant left. At the end of the game,
display the name of the winner.
[Hint: You will need to invoke a built-in
method to generate a random number
between 0
(inclusive) to 3 (inclusive)]
Modify the program you wrote in exercise 3.32 so that it prints a hollow square. For example, if your program reads a size of 5, its should print
Chapter 4 Solutions
Programming in C
Ch. 4 - Type in and run the nine programs presented in...Ch. 4 - Prob. 2ECh. 4 - A triangular number can also be generated by the...Ch. 4 - The factorial of an integer n. written n!, is the...Ch. 4 - The following perfectly valid C program was...Ch. 4 - A minus sign placed in front of a field width...Ch. 4 - A decimal point before the field width...Ch. 4 - Program 4.5 allows the user to type in only five...Ch. 4 - Rewrite Programs 4.2 through 4.5, replacing all...Ch. 4 - What would happen if you typed a negative number...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
A woman bails out of an airplane at an altitude of 10.000 ft. falls freely for 20 s, then opens her parachute. ...
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Write a program that reads a four-digit integer, such as 1998, and then displays it, one digit per line, like s...
Java: An Introduction to Problem Solving and Programming (7th Edition)
What is the most important difference between a while statement and a do-while statement?
Problem Solving with C++ (10th Edition)
In an if/else statement, the if part executes its statement or block if the expression is __________, and the e...
Starting Out with C++ from Control Structures to Objects (8th Edition)
T F Protected members of a private base class become public members of the derived class.
Starting Out with C++ from Control Structures to Objects (9th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Welcome to the era of Aladdin and the great magic lamp. This is 1st of January and Aladdin will be in jail for one year. He was recently caught for helping forty thieves. Now he has nothing to do. But he knows that Jasmine is waiting for him. At some point he got an idea to give Jasmine a magical program that can find intervals of months from a year. This allows her to easily determine how long it will take for Aladdin to get out. Then Aladdin rubs the magic lamp and The Genie appears. Then he asked The Genie to make such a magical program. Unfortunately the Genie doesn't know programming and he wants your help to create that magical program. Genie will give you N as the day of the year and you have to print in which month that day is. Input Format Input will contain one line with a single integer N, day of the year. Constraints 1 <= N <= 365 Output Format Print a single line containing the name of month. Be careful about the newline ('\n') at the end. Sample Input 0 1 Sample…arrow_forwardHow many cousins does the program have? Please say a few words about each.arrow_forwardWrite basic code for solving a sudoku game?arrow_forward
- java / eclipsearrow_forwardUsing c++ Let's play a game of FizzBuzz! It works just like the popular childhood game "PopCorn", but with rules of math applied since math is fun, right? Just print out "Fizz" when the given number is divisible by 3, "Buzz" when it's divisible by 5, and "FizzBuzz" when it's divisible by both 3 and 5!arrow_forward(This is for devc++ but I use mindmap from Cengage. I know it a little different. If you can't use Cengage, I suggest devc++ version 5.11) One way to determine how healthy a person is, is by measuring the body fat of the person. The formulas to determine the body fat for female and male are as follows: Body fat formula for women: A1 = (body weight X 0.732) + 8.987 A2 = wrist measurement (at fullest point) / 3.140 A3 = waist measurement (at navel) X 0.157 A4 = hip measurement (at fullest point) X 0.249 A5 = forearm measurement (at fullest point) X 0.434 B = A1 + A2 - A3 - A4 + A5 Body fat = body weight - B Body fat percentage = body fat X 100 / body weight Body fat formula for men: A1 = (body weight X 1.082) + 94.42 A2 = waist measurement X 4.15 B = A1 - A2 Body fat = body weight - B Body fat percentage = body fat X 100 / body weight Instructions Write a program to calculate the body fat of a person. Prompt the user to input: Their gender ('m' or 'M' for male, 'f' or 'F' for…arrow_forward
- language c++arrow_forwardGuess number game. Write a program in Java to: a. Generate a random integer between 1 and 100 (inclusive) and prompt user to guess the number. b. If the guess is not right, give the user the hint like “higher”, “lower”. Allow the user to retry and input the new guess. c. Likely you want to use a while loop to support the user’s multiple attempts. Stop the loop when the user guessed the number. d. Print out the number of attempts for the user for this round of game.arrow_forward[in java] You are working in the information technology department of a financial institute. You are required to develop a Java Program to assist the customer service department to provide good quality of services to the customer. Fix deposit is one of the most commonly asked services. Therefore, you are asked to develop a calculator for fix deposit to be included in the ATM display. The available options for ATM display is Fix Deposit and Cancel. When different option is chosen, different inputs from a user are required. Figure 6 shows the expected outputs on the ATM display. When the option Cancel is chosen, the user will exit from the system. Fix Deposit: Annual interest (%) : 3.0 Principal of saving (RM):Z Number of years of saving (n): Total savings (RM): figure 6 Based on Figure 6, the annual interest given by the bank is 3% and will be displayed on ATM screen. Let represents the amount of money in your saving account at the end of n years in the bank…arrow_forward
- You will implement a variant of the number guessing game we played in lecture. In this variant, you will ask the user to guess the price of a $42,500 car. Let's assume that the player knows the price of the car is rounded to the nearest $500. If a player's guess is not exactly correct, your program will tell them they are either too high or too low. The player will get as many guesses as they need to guess the price of the $42,500 car. They need to guess correctly to finish the game, but they will only win the game if they used 5 or fewer guesses. Here are two examples of how the program should work for both cases: Guess the price and win the prize! Enter your guess:50000 Too high! Enter your guess:40000 Too low! Enter your guess:45000 Too high! Enter your guess: 42500 You won the car! Guess the price and win the prize! Enter your guess:46000 Too high! Enter your guess:45000 Too high! Enter your guess: 44000 Too high! Enter your guess: 43000 Too high! Enter your guess:4 Too low! :…arrow_forwardTHIS IS MEANT TO BE IN JAVA So far we've learned variables, branches, loops, and some array. The assignment is: Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue); The output ends with a newline. This doesn't make sense to me.... Please show the end result and explain why you added what you added. This is what I have so far: import java.util.Scanner; public class LabProgram {public static void main(String[] args) {}}arrow_forwardint i=0; while(i<10) { printf(“I am inside the loop”); } What is wrong with this block of C code? Mark the errors and fix them.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY