Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Question
Chapter 6, Problem 6E
Program Plan Intro
- Include required header files.
- Declare the function “main ()”.
- Declare required variables “var1”, “var2”, “var3”, and “i”.
- Print the values of “var1”, and “var2”.
- Loop from 0 through 13 using “for” loop.
- Add the value of “var1” and “var2” and store it in a variable “var3”.
- Assign the value of “var2” to “var1”.
- Assign the value of “var3” to “var2”.
- Print the value of “var3”.
- Return the statement.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
I have an array of the first 50 Fibonacci numbers in the picture.
Your program should ask the user for a number between 5 and 21. Using that input as a location in the array, with that location and the next three locations (for example base, base+1, base+2 and base+3) you will multiply the outer values, base and base+3, (the first and last of the four). Do the same for the inner values (base+1 and base+2 multiplied) and then double that value.
These two values form the two sides of a right triangle. Now find the hypotenuse. Remember the Pythagorean theorem, which says a2 + b2 = c2. Our two sides are a and b, so we square each of them (remember a * a = a2, so just multiply each value by itself) and add them together. That gives you c2. Now all you need do is take the square root of that sum.
Given that the sqrt method normally returns a floating-point value (a double), we must force it to return a long integer for us in this case, so use the following line (with your own…
This program will create an array of 12 random integers (between 1-9) and remove all numbers less than or equal to another randomly generated integer (between 1-9)There are four steps to accomplish this.a. Create and fill an array of random integers between 1-9. The array must be size 12.b. Generate a random integer between 1-9.c. Write the code that will create a new array of the integers in the given array but with the numbers less than or equal to your random number removed.
For example, if you randomly generated 6 and the original array contains 1 8 9 4 4 7 2 2 5 8 4 7 your new array will contain 8 9 7 8 7d. Print the original array, the number generated, and the new array.i.e. The original array contained:1 8 9 4 4 7 2 2 5 8 4 7All numbers less than or equal to 4 to be removed.The new array contains:8 9 7 5 8 7*Keep in mind that because we are dealing with random numbers, it is possible that the random number you generate for numbers to be removed from the array is less than…
Using C++ Language
Start with the provided code and understand what it is doing. We are interested in computing the maximum grade out of the 6 quiz scores for each student in class. Assume the maximum class size is 10, but we will ask the teacher how many students there are in the class. It cannot be more than 10. In the below program, we create a two-dimensional array with the number of rows equal to the number of students (one for each student) and 6 columns (one column for each quiz grade).
code:
#include <iostream>using namespace std;const int COLS = 6;const int ROWS = 10;void computeMaximum (float grades[][COLS], int num, float maximum[]);void showArray(float array[], int size);int main(){ float grades[ROWS][COLS]; float maximum[ROWS]; int num; cout<<"How many students in the class?"; cin>>num; for (int row = 0; row < num; row++) { //enters 6 quiz grades for each student for (int col = 0; row< COLS; col++)…
Chapter 6 Solutions
Programming in C
Knowledge Booster
Similar questions
- Write a program and ask the user to enter their name. Use an array to reverse the name and then store the result in a new string. Display the reversed name on the console. Note: I need the code in C# Language.arrow_forwardWrite a program that reads 10 integers from the keyboard, store them in an array. Then modify the array so that each element is incremented by 1. Last, display the incremented array.arrow_forwardIt uses a one-dimensional array. You can refer to the PowerPoint slides, many of the tasks can be found there, but you need to apply them for this program. Note that the array will be filled with the integers when the user enters them. Consider the proper layout and correct indentation. Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array. You will add to the program. Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Do not do it all at once. Add the following to the program: Write a function to display some heading with useful information which will display on the screen for the user. Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the number of such numbers found. Write a function that determines…arrow_forward
- An amateur meteorologist wants to keep track of weather conditions during the past year’s three-month summer season and has designated each day as either rainy (‘R’), cloudy (‘C’), or sunny (‘S’). Write a program that stores this information in a 3 × 10 array of characters, where the row indicates the month (0 = June, 1 = July, 2 = August) and the column indicates the day of the month. Note that data are not being collected for the date greater than 10th f any month. The program should begin by reading the weather data from user. Then it should create a report that displays, for each month and for the whole three-month period, how many days were rainy, how many were cloudy, and how many were sunny. It should also report which of the three months had the largest number of rainy days.arrow_forwardWrite a program that will read the monthly salary of 10 employees and then calculates the income tax (i.e, 10% of the salary) and net salary. Hence you have to declare an array salary[10][3]. Your program should have 4 functions. The first function will be used to read monthly salary of 10 employees and put it in the first column of the array. The second function will be used to calculate the income tax for each employee and then store it in the second column of the array. The third function will be used to calculate the net salary of each employee and store it in the third column of the array. Finally, the fourth function will be used to display the gross salary, income tax and net salary for each employee. You must pass the array as reference in each function you used.arrow_forwardPlease help with the writing array program. Having hard time figuring out the code. Attatching the instruction, code outline and display result in the image.arrow_forward
- easy code please and simple librariesarrow_forwardUsing c++arrow_forwardA positive integer greater than 1 is said to be prime if it has no divisors other than 1 and itself. Write a program that asks the user to input an integer greater than 1, then display all of the prime numbers that less than or equal to the number entered. The program should work as follows: • Once the user has entered a number, the program should display an array with all of the integers from 2 up through the value entered. • The program should then use a loop to step through the array. The loop should pass each element to a method that displays the element whether it is prime number. Your result should look like, for example: Enter an integer greater than 1: 9 2, 3, 4, 5, 6, 7, 8, 9 2 is prime 3 is prime 4 is not prime 5 is prime 6 is not prime 7 is prime 8 is not prime 9 is not prime Using java programmingarrow_forward
- Write a program that reads 10 grades from the input and store them in an array. Use the values in the array to calculate the average of 10 marks. The program should then print the difference between each grade and the average.IN C PROGRAMarrow_forwardQuestion D Write a program that calculates the sum of all the elements in an array. Take input from user about the size of array and what are the elements in the array. Using Java code. Full explain this question and text typing work only We should answer our question within 2 hours takes more time then we will reduce Rating Dont ignore this line.arrow_forwardDebugging challenge: Consider the code example below. This program is designed to compare the contents of two arrays: if they are equal, the program should display "TRUE," if the arrays are not equal, the program should display "FALSE". However, even when the arrays have the same value, the program always prints "FALSE", regardless of the values in arrays a and b. What is going on here? What about the program causes the comparison to always fail? int a[4] {1, 2, 3, 4}; int b[4] = {1, 2, 3, 4}; if (a == b) { display ("TRUE"); else { display ("FALSE");arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning