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 4E
The factorial of an integer n. written n!, is the product of the consecutive integers 1 through n. For example, 5 factorial is calculated as
5
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Computer Engineering lab
Problem: Feed Nibble Monster Till Full
Write a program that generates a number in [0, 500] at the beginning -- this corresponds to how hungry the monster is -- and keeps asking the user to feed the monster until that number falls to zero.
Each time the user feeds the monster a nibble, hunger decreases by the decimal value of the character (i.e. if the user feeds 'A' hunger decreases by 65). But when the user feeds the monster some character that isn't a nibble, the hunger increases by the decimal value of the character (since puking depletes energy).
Use while loop.
Sample runs:
Notice the loop exits after one iteration, because hunger was very low and one nibble made the monster full:
Notice hunger increasing after non-nibble (pink highlight):
Notice that the program just keeps going when the user feeds the monster only non-nibbles. Do you think the program will keep running forever if the user never gives the monster nibbles?
3 Write a program to compute the sum of two matrices and then print it. Firstly user
will be asked to enter the order of matrix (number of rows and columns) and then
two matrices.
For example if the user entered order as 2, 2 i.e. two rows and two columns and
matrices as
First Matrix:-
3 4
Second Matrix:-
4 5
-15
Then output of the program (sum of First and Second matrix) will be
5 7
2 9
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
Write a for loop that displays every fifth number, 0 through 100.
Starting Out with C++: Early Objects
What are the design issues for character string types?
Concepts of Programming Languages (11th Edition)
The variable a starts with the value 10. The variable b starts with the value 2. The variable c starts with the...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
TestScores Class Design a TestScores class that has member variables to hold three test scores. The class shoul...
Starting Out with C++ from Control Structures to Objects (9th Edition)
Look at the following array definition: const int numbers[SIZE] = { 18, 17, 12, 14 }; Suppose we want to pass t...
Starting Out with C++: Early 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
- Perfect number, a positive integer that is equal to the sum of its proper divisors. The smallest perfect number is 6, which is the sum of 1, 2, and 3. Other perfect numbers are 28, 496, and 8,128. Draw a flow chart of perfect number.arrow_forward(Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forward15. Write a program to implement and test the algorithm that you designed for Exercise 15 of Chapter 1. (You may assume that the value of . In your program, declare a named constant PI to store this value.)arrow_forward
- A structure that allows repeated execution of a block of statements is a(n) _____________. sequence selection array looparrow_forward(Computation) A magic square is a square of numbers with N rows and N columns, in which each integer value from 1 to (N * N) appears exactly once, and the sum of each column, each row, and each diagonal is the same value. For example, Figure 7.21 shows a magic square in which N=3, and the sum of the rows, columns, and diagonals is 15. Write a program that constructs and displays a magic square for a given odd number N. This is the algorithm:arrow_forwardpython please explainarrow_forward
- Fibonacci sequence: The first two numbers of the fibonacci sequence are 1 and 1, and sequential numbers are the sum of the previous two. Write a program that prompts the user for an integer n and then prints the first n numbers of the Fibonacci sequence (Please type answer no write by hend)arrow_forwardExercise#1: Number Sequence Using nested loops, continue and break, write a program that prompts the user to input data for five students. Each student's data contains student first name and test scores. The program should accept positive integers only for test scores and ignore non-positive integers. Each student may has a different number of test scores; the program should receive input for test scores until input "0". Finally, the program outputs each student name with the sum of his/her marks. Sample Input/Output: Enter Student name: Khaled 65 78 -40 56 -25 89 0 The student 'Khaled' has the total marks = 288 Enter Student name: Kamal 37 55 44 -77 22 18 56 26 0 The student 'Kamal' has the total marks = 258 Enter Student name: Ali 66 33 87 66 87 -25 25 39 78 0 The student 'Ali' has the total marks = 481 Enter Student name: Taher 72 67 -33 0 The student 'Taher' has the total marks = 139 Enter Student name: Ahmed 75 68 84 -18 90 0 The student 'Ahmed' has the total marks = 317…arrow_forwardProblem E: Dice Game Looped Write a program that allows two users to play the dice game in Problem D 10 times. At the conclusion of the game, print out how many times player 1 won, how many times player 2 won, and how many times both players tied. In python codearrow_forward
- The shape is: *** Part 2 Add this comment: # Ass 1: Part 2 Write a program that ask the user to enter two integers N and M then prints the summation of even numbers from N to M. (Note: N and M included if were even numbers). Samplel: Please enter N value: 0 Please enter M value: 10 The sum is: 30 Sample2: Please enter N value: 4 Please enter M value: 8 The sum is: 18 hugill gi eolarrow_forwardPython Calender library- Write a program that takes input year number from user and print the calender of whole year with day of each date.arrow_forwardin c++ languagearrow_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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY