Programming Exercises - Sheet 7 For this lab create a new workspace with a project for each of the problems respectively

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Programming Exercises - Sheet 7 For this lab create a new workspace with a project for each of the problems respectively

Post by answerhappygod »

Programming Exercises Sheet 7 For This Lab Create A New Workspace With A Project For Each Of The Problems Respectively 1
Programming Exercises Sheet 7 For This Lab Create A New Workspace With A Project For Each Of The Problems Respectively 1 (52.38 KiB) Viewed 61 times
Programming Exercises Sheet 7 For This Lab Create A New Workspace With A Project For Each Of The Problems Respectively 2
Programming Exercises Sheet 7 For This Lab Create A New Workspace With A Project For Each Of The Problems Respectively 2 (26.41 KiB) Viewed 61 times
Programming Exercises Sheet 7 For This Lab Create A New Workspace With A Project For Each Of The Problems Respectively 3
Programming Exercises Sheet 7 For This Lab Create A New Workspace With A Project For Each Of The Problems Respectively 3 (11.59 KiB) Viewed 61 times
Programming Exercises - Sheet 7 For this lab create a new workspace with a project for each of the problems respectively. Include a text description at the start of the program with author, date, Lab no and Lab Question Problem 1 Write a program using a switch statement (refer to lecture notes from week 7). The program should take in a number between 1 and 7 from the user. Next, the program should print out what day of the week it is depending on what the user inputs. E.g. if the user enters the number 1, the program should print to the screen "The Number 1 corresponds to Monday. If the user inputs 2, the program prints to the screen "The Number 2 corresponds to Tuesday" etc. Problem 2 Sometimes, we want to declare a variable that we don't want to be changed throughout the programme. We can declare constant variables (unchangeable and read-only) that don't change using the constant keyword before the variable declaration. You should always declare the variable as constant when you have values that are unlikely to change: Example: const int myllum - 15; // myliu will always be 15 Note: When you declare a constant variable, it must be assigned with a value. It is considered good practice to declare them with uppercase. It is not required, but useful for code readability and common for programmers. Constants should be declared before the main() function. Constant Naming Convention: Use uppercase words, joined with underscore. For example, MIN_VALUE, MAX_SIZE. Practice using a Constant Data Type at the beginning of the program used to solve the problem below. Write a program that calculates the volume and mass of a steel cylinder using the equation below. The user inputs the DIAMETER and height in meters. The program outputs the volume and mass. Pi and 2400 should be saved as constant Data Types Volume arh Massime = 2400KG/m Problem 3 Design a Program in C that will convert temperature readings from degrees Celsius ("C) to Fahrenheit (F). The user must enter a start and a finish value together with a step value. The program must convert all temperatures beginning with the start value at the given step interval. Use the formula overleaf: Page 1 of 3
(°Cx19.0/5) -32.0" Example Input: start value: 10 Finish value :16 Step value: 2 Desired Output: Celsius Fahrenheit 10 50.0 12 53.6 14 572 16 60.8 Problem 4 (a) Write a program that accepts your first name and returns it to the screen ten times using only the character conversion specifier (6) Write a program that accepts your first name and returns it to the screen ten times using only the string conversion specifier % Note-only the populated part of the array should appear Problems Create an array having 10 elements of type int called tab1_array. Populate the array elements individually prompting the user each time for an integer value Output the values to the user after all 10 are inputted in the following format: Tabl_array() - 1 labi_array[1] - 2 labl_array[2) - 3 : labi_array[8] - 9 1ab1_array(9) - 10 Problem 6 Using an array to store the values, write a program that calculates the squares, cubes and square roots of the numbers from 0 to 10 and uses tabs to print the following table of values: Number Square Cube Root 0.00 0 0 0 1 1 1 1.00 Page 2 of 3
2. 4 00 1.41 3 9 27 1.73 4 16 64 2.00 5 25 125 2.24 6 36 216 2.45 7 49 343 2.65 00 64 512 2.83 9 81 729 3.00 10 100 1000 3.16
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply