Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 4, Problem 5E
The following perfectly valid C
#
i
i
P
P
P
t
f
P
r
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Exercise 2 - Primer on Loop
Referring to the code for drawing an equilateral triangle provided to you earlier in this prac
sheet, you may have noticed that, in order to draw the triangle, we are repeating a set of two
commands three times i.e. robot.forward( 100) followed by robotright(120). Python (and many other
programming languages) provide us a tool called a "Loop" to repeat a certain set of steps a
certain number of times. As usual, in order to use loops, we have learn the correct Python
syntax for it. The following Python code uses a loop to draw the same equilateral triangle as the
code provided earlier:
import turtle
wn - turtle.Screen()
wn.bgcolor("white"
robot - turtle. Turtle()
robot. setheading(90)
robot shape("turtle")
robot.colort"green"
robot. pensize(3)
for i in range(3):
robot. forward( 100)
robot. right(120)
wn.exitonclick()
Note that the lines that fall under the line that starts with "for" have to be indented; this means
that you have to insert spaces or tabs (USE…
c++
A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and outputs whether the input is a palindrome.
If the input is bob, the output is:
bob is a palindrome
If the input is bobby, the output is:
bobby is not a palindrome
Hint: Start by just handling single-word input, and submit for grading. Once passing one single-word test cases, extend the program to handle phrases. If the input is a phrase, remove or ignore spaces.
356110.1926120.qx3zqy7
Write a program in C that take 5 digit number as an input from the user and perform the following tasks:1. Split a number into digits.2. Find the sum of the all the digits in the number.3. Find the product of the all the digits in the number.4. Find maximum number with in the number along with position.5. Printing the digits in the reverse order.
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
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
Explain how database administration tasks vary with the size and complexity of the database.
Database Concepts (8th Edition)
Write a program to print the value of EOF.
C Programming Language
(Factorials) Factorials are used frequently in probability problems. The factorial of a positive integer n (wri...
Java How To Program (Early Objects)
Can you use the copy template function with vector containers, even though copy requires forward iterators and ...
Problem Solving with C++ (10th Edition)
Modify the sequential search function in Figure 5.6 to allow for lists that are not sorted. def Search(List, Ta...
Computer Science: An Overview (12th 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
- Write a program that reads a set of floating-point numbers and prints out the ten largest numbers. As you process the inputs, do not store more than eleven numbers. When it holds more than ten values, remove the smallest value, as it cannot be a part of the answer. Program language c++arrow_forwardComputer Science IN C++ Test it in the main function Create e musicplayer with 3 songs. Play the current song. Play the next song. Play the next song. Play the next song. Play the previous song. Print the list of the songs using bool parameter true. Print the list of the songs using bool parameter falsearrow_forwardplease help me make a program using C Programming only about this problem plssS. PLEASE KINDLY EXPLAIN ALSO the logic or algorithm of the c program code because we are tasked to explain it orally in virtual class please... I promise to give helpful rating after. And please copy paste the code and send the screenshot too please.PROBLEM:Write a program that will accept a number n and display the sum of all even numbers and the sum of all odd numbers from 1 to n NOTE: C PROGRAMMING ONLY AND USE FOR LOOP TOPIC ONLYarrow_forward
- Make a C# programming of: 1. Cody at World Cup by CodeChum Tomorrow is the closing ceremony for the 2022 World Cup, and Cody and his friends want to know who the top scorer of the tournament is. John and the others insist that it Lionel Messi is the top-scorer (scoring 10) but Cody, a Ronaldo fan, is stubborn and decided to make a list of all the players who scored goals and order them randomly. He then must look for the highest number and see if that number is higher than Messi’s goals. Input the number of players then input the number of goals scored for each. Print "Not Messi" if the highest goals exceed 10 and "Okay, fine, it's Messi" if it doesn’t. Input Format First line should be a positive integer indicating the number of players, following lines indicate the goals scored by each. Input Sample 4 7 2 5 1 Output Format A single line containing a string Output Sample Okay,·fine,·it's·Messiarrow_forwardmain.c +c Test Cases Executions 1. FizzBuzz 2.0 by CodeChum Admin 1 E Run Tests Remember the game of FizzBuzz from the last time? Well, I thought of some changes in the game, and also with the help of loops as well. Firstly, you'll O Test Case 1 be asking for a random integer and then loop from 1 until that integer. Then, implement these conditions in the game: Your Output No Output • print "Fizz" if the number is divisible by 3 • print "Buzz" if the number is divisible by 5 • print "FizzBuzz" if the number is divisible by Expected Output both 3 and 5 Enter n: 15 • print the number itself if none of the above conditions are met 2 Fizz 4 Input Buzz Fizz 1. An integer 7 8 Output Fizz The first line will contain a message prompt to input Buzz the integer. The succeeding lines will contain either a string or 11 Fizz an integer. 13 14 FizzBuzzarrow_forwardWrite a program in C++ which adds, subtracts, multiplies, divides, and perform exponentiation on two specific numbers. The two numbers should be entered by the user. Each output should include a string describing what the numerical output is being displayed. Use the switch block so that the user is able to select which mathematical function to perform. Make sure the program has a neat menu for the user to use to select their choice. Also, avoid having the computer perform a division by zero if the user attempts it by outputting a warning message in its place (You can use an if statement to execute this). Include your C++ source code as well as the output of your program in your submissionarrow_forward
- On C language, please: 1. Write and execute a short computer program in C, C++ or Java (or Matlab m code if necessary) to do the following: Read integer numbers from the keyboard input until the same number is entered twice in a row. Numbers should all be within the range [-32768 ... +32767]. • Identify and print the smallest, largest, and average of the number entered (don't count the final duplicate number in the average). Submit the program and a screenshot of it executing properly, showing the inputs and outputs (smallest, largest and average). Use 12 to 15 values, scattered across the range of positive and negative numbers in the range listed above.arrow_forwardWrite a complete C++ program that reads a positive and non-zero integer then do the following: 1. Print all odd divisors (factors) of that integer in decreasing order. 2. Print the count of all even divisors. 3. Keep dividing the previous number by 2 until that number reaches zero then print how many times the division was executed. • Example: If the number 20 The odd divisor of 20 is 5, 1 in decreasing order The count of all even divisor is 4 The division was executed 10 timesarrow_forwardPart 2 only please!!! C++ Language. Part 1: As an avid Monopoly player, I've often wondered what the most common dice rolls are when you roll 2 6-sided dice and sum the result. To answer this question experimentally, write a program that asks the user how many trials they would like to run. Then, simulate the roll of 2 six-sided dice using rand() repeatedly, according to how many trials the user wanted to run. Finally, report the percentage of how many of the trials yielded a given sum for each of the possible sums from 2 to 12. Here is an example run: Each time the result for 1 die comes out and it’s 1 assign it the value of 1/num throws How many times do you want to throw a pair of six-sided dice? > 1000 The distribution of results from the 1000 trials is: (the numbers below are not actually correct) 2: .01 3: .04 4: .50 5: .10 6: .20 7: .30 8: .10 9: .10 10: .50 11:…arrow_forward
- 3. Identify the errors in the following C# program. Write the correct program. Explain the errors. ************PLEASE ANSWER WITH COMPLETELY ANSWER*********** using systempublic class PrimeNumberExample{public static void Main(string[] args){int n, i, m=0,;Console.Write("Enter the Number to check Prime: ");n = int.Parse(Console.ReadLine());m=n/2;for(i = 2; i <= m; i++){if(n % i == 0);{Console.Write("Number is not Prime.");flag=1;break:}}if (flag==0)Console.Write("Number is Prime.");}}arrow_forwardWhat is your conclusion/Observation?? Create a nested looping program in C-language that will produce the given output below (use any of the looping statements) ************************* --------------------------------------------------------------------------------- #include<stdio.h>#include<conio.h>#include<windows.h>void gotoxy(int x, int y){COORD pos ={x , y};SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);}main(){ int x,y; for (y=1; y<=5; y++) { gotoxy(x,y); printf("*"); getch(); }}arrow_forwardNote: Please answer in C++ Programming language. During Eid, it is a tradition for every father to give his children money to spend on entertainment. Chef has N coins; denote the value of the coin i by vi. Since today is Eid, Chef gives one coin to each of his two children. He wants the absolute value of the difference between the values of the coins given to the two children to be as small as possible to be as fair as possible. Help the chef by telling him the minimum possible difference between the values of the coins given to the two children. Of course, the chef cannot give the same coin to both children. Possible input 1 3 142 Required Output 1arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
What is Abstract Data Types(ADT) in Data Structures ? | with Example; Author: Simple Snippets;https://www.youtube.com/watch?v=n0e27Cpc88E;License: Standard YouTube License, CC-BY