Programming Logic & Design Comprehensive
9th Edition
ISBN: 9781337669405
Author: FARRELL
Publisher: Cengage
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Conditional Statements - Practice Questions
• Write a python program to accept a number and
o if the number is equal to 1, calculate Z = x % y
o if the number is equal to 2, calculate Z = x // y
o if the number is equal to 3,
or negative
o
equal to 4,
if the number is
odd
o
if the number is equal to 5,
not same
o
if the number is equal to 6,
two numbers
o if the number is equal to 7,
two numbers
o Otherwise print STOP
check if the number is positive
check if the number is even or
check if two numbers are same or
check the greatest number among
check the smallest number among
answer only 100% knowledge else skip posting multiple times
Context for question:
The user inputs the secret number, then the computer guesses your secret number by randomly generating numbers. The program should automatically output if the user's secret number is higher or lower than the computer's guess. The computer can then use this information for its next random guess. Although the computer's guesses are random, think of ways to make the computer's guesses intelligent, without the computer using the secret number the user entered (that would be cheating on the part of the computer).
#include
#include
#include
int main()
{
int secretNumber, guess;
printf("Enter Secret Number: ");
scanf("%d", &secretNumber);
do {
guess = (rand() % 100 + 1);
printf("The guess is %d", guess);
if (secretNumber == guess){
printf("\nYour guess is correct. Congratulations!\n");
}else if(secretNumber > guess){
printf("\nYour secret number is higher than the guess…
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
- (General math) The value of p can be approximated by this series: 4(113+1517+....) Using this formula, write a program that calculates and displays the value of , using 2, 3, and 4 terms of the series.arrow_forward(Statistics) This is the formula for the standard normal deviate, z, used in statistical applications: z=(X)/ X is a single value. refers to an average value. refers to a standard deviation. Using this formula, you need to write a program that calculates and displays the value of the standard normal deviate when X=85.3,=80,and=4. a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. d. Test the formula written for Exercise 7c, using the data given in the problem.arrow_forwardThe island nation of Babbage charges its citizens an income tax each year. The tax rate is based on the following table: Income $0 - 5000 $5001 - 10000 $10001 - 20000 $20001 40000 Over $40000 Tax Rate 0% 3% 5.5% 10.8% 23.7% Write a program that, when given a person's income, prints the tax owed rounded to the nearest dollar. Enter your income: 35000 Your tax is: $3780arrow_forward
- Excercise 30 defines the number e and exerecise 31 shows how to approximate the value of e using a different expression. Interestingly the value of e can also be approximated using the foloowing expression: 2+1/1+1/2+2/3+3/4+4/5+5.../(n-1)+(n-1)/n+n Write a program that uses this formula to approximate the value of e. Test your program for n = 3, 5, 10, 50, and 100.arrow_forwardCan you use Python programming language to to this question? Thanksarrow_forwardim not sure how to start this assignment in python programming languagearrow_forward
- Name of student: Kristel Answer immediately thanksarrow_forwardConditional Statements - Practice Questions • Write a python program to accept a number and if the number is even calculate Z=x modulus y, If number is positive calculate Z=x to the power y If number is in between 1 and 10 calculate Z- (x+y)/2 If the number is equal to 0 calculate division of two numbers by removing decimal. Otherwise display Wrong input ㅇ • write a python program to accept 2 numbers, if two numbers are same calculate Z=a²+b², oif modules of two number is equal to zero Z=(2a5+3b5) /3b, if both the numbers are even calculate Z-(a+b)?/(a*b), otherwise display Wrong Choice. calculatearrow_forwardProblem Statement Create a program that will determine whether a triple can generate a triangle and if it can generate a triangle, determine if the triangle is scalane, isosceles or equilateral. Input Input starts with a number N and is followed by N triples (a,b,c), where a, b and care natural numbers Output The output will be: equilateral, if the triangle formed is an equilateral triangle, isosceles, if the triangle formed is isosceles and scalene if the triangle formed is scalene. Output no triangle is formed, if no triangle can be formed. Limits 1arrow_forwardHello! I need help creating a code in python that:1. Request the student's name2. Request the note obtained3. Request the percentage of the grade you just entered (If you enter a percentage that exceeds 100, it prints "The evaluated percentage of a subject cannot be greater than 100") if they add up to less than 100, the program asks the student if there are missing notes to add. If the answer is affirmative, the program returns to the beginning of the step, if the answer is negative, the program flow continues. 4. Get the accumulated grade which is obtained by adding the grades being multiplied by their percentage (should only be approximated to 2 decimal places before printing the result)the program ends when enough notes are added to reach 100% or when the user answers "N"example in the image thanksarrow_forwardarning Portal Courses Reports e-Services Academic Departments ETC CIMS Write a python program to accept a number and if the number is even calculate Z-y modulus x, by taking x and y input from user If number is positive.calculate Z-y to the powerx, by taking x and y input from user if the number s equal to 0 caculate Z-x to thne powery by tking xand y input from user fnumber is in tetween 1and 10 cakulate 7**y2.by taking and y input from user Otherwise display Invalid input:arrow_forwardNote: You are not allowed to use more than four variables in your program.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Introduction to Operators in C; Author: Neso Academy;https://www.youtube.com/watch?v=50Pb27JoUrw;License: Standard YouTube License, CC-BY