Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming in C with comments please Lab 4 background info (I do not need the code for this) Part 1: Part 2: This lab retums

Programming in C with comments please
image text in transcribed
image text in transcribed
Lab 4 background info (I do not need the code for this)
Part 1:
image text in transcribed
Part 2:
image text in transcribed
This lab retums to the program you wrote for Lab 4. The first part of Lab 4 was the program that printed out factors of each number from 1 to some value entered by the user. The second part of Lab 4 modified the output for the factors so that it was right justified before the value of the row. For this program, you will use a 2-D array holding the values for each row including the spaces so that when printed, it will be right-justified and will look like the following Table of Factors from 1 to? (enter an integer): -10 125 10 10 You can picture the array that holds the above output looking like this: Columns0 Rows Space 10 ab Assignmen You will be creating a file called lab7.c today which will contain the program described above. The values in each column should be in a field width of 4. As always, you should take some time to think about this and come up with some sort of algorithm before haphazardly throwing down code. Make sure to test your code with several test cases. OUTPUT SAMPLE 2: Table of Factors from 1 to? (enter an integer): --35 maxNumFactors is 8 7 1 25 10 10 1 2 346 1212 13 1 2714 14 13 5 15 15 1 2 48 16 16 17 18 19 1 2 45 10 20 20 137 21 21 1 211 22 22 23 1 23 46 8 12 2424 152525 1 2 13 26 26 27 1 2 7 1428 28 29 1 23 5 6 10 15 3030 31 1 248 16 32 32 1 3 11 33 33 1 217 34 34 15 35 35 1 13 1 17 1 2369 18 1 19 1 23 13 927 1 29 1 31 You will be creating two files today, one called multTable.c and factorS.C In multTable.c. provide a C program that will de the following L. Prompt the user to enter an integor. Note: Use fprintt O and Escanffunctions throughout your program 2. Using loops, print out to the user a multiplication table from I to the number nicrod by the user SAMPLE OUTPUT Maltiplication Table from 3 to7 lenter an integer) 10 234S679 1 4610 12 14 16 18 20 36 9 12 15 18 21 24 27 30 6 12 18 24 30 36 42 48 54 714 21 28 35 42 4956 63 70 8 16 24 32 40 48 56 64 7280 9 18 27 36 45 54 63 72 81 90 0 20 30 40 50 60 70 80 90 100 . The mbers in the first column should be in a field of width 6 widh 2 spaces after the number, and each number in the remaining columns should be in a field of width 4 In factoES.,provide a C program that will do the following 1. Prompt the user to enter an integar. Note Use fprintt0 and Escant functions throughout your program 2. Using loops, print out to the user the factoes for each nummber from I to the number entered by the user SAMPLE OUTPUT Factors from 1 to 7 (enter an integer) 2 1 2 3 13 412 s 15 6 1236 7 1 812 4 913 12 5 10 10 The numbers in the finst column should be in a field of widh 4 with 2 spaces affer the number, and each number in the remaining columns should be just simplyd with 1 space after the d For this purt ofLab4, you wil beh programs from Part a irto one pmpan, but with the o lookng below: Table of Factors&Haltiples from 1 so7 enter an integer 22457810 24 16 20 24 28 32 36 2416 24 32 40 4856 64 72 234 12 12 24 36 60 2 84 56 108 120 13 13 26 3 52 65 78 91 304 127 330 5 15 0 45 75 90 105 320 135 150 117 17 34 5 68 85 102 119 336 153 170 236 91836 54 72 90 108 126 344 162 180 11 19 38 57 76 95 114 133 352 171 190 2 4510 202040 60 100 120 140 360 180 200 211 22 2244 110 132 154 176 398 220 38 161 184 207 230 123468 12 242448 2 6 120 144 168 392 236 240 525 2550 5 100 125 150 175 200 225 250 139 27 27 54 108 135 162 189 216 243 270 1247142 26 4 312 340 168 396 224 252 2 235 610 15 3060 90 320 150 180 210 240 270 300 Reminder About Style, Formatting, and Commenting Reqairements The top of your file should have a header comment, wibch shouldcomtain o Bricf description about what the peogram does o Any other helpful infomation that you think would be pood to have. Variables should be declarod at the top of the main function, and should have meaningful mames - One excoption to the rule of using meaningfal names foe variables is to useo on or some other single letler as a loop index variaNe mame this is a common, accaptable practice Always indent your code ta realable way. Some fmumng eumples may be found here: Don't forpet to use the -Wal1 fag when compiling, for esamplk: gce -Nall lab4.e You will be ceating a file called lab4.a soday whish will combine the two les that you created from Part a The output, as shown above, wall be a lde diffierent in that the factors will be right-ustified appearing before the number with the mukiplicati table for each line appearing atter. The rightustfication of the factors is non-trivial The width of the entire left side where the factors ashown wiB vary according to the highest number of factors for dat groupefnunben NetKe how intbe cumpk output below, the second talle is dufied more ithe right than the rst table became there are more fact n(for 12,there are 6 factes) than there are in the fiest table. This lab retums to the program you wrote for Lab 4. The first part of Lab 4 was the program that printed out factors of each number from 1 to some value entered by the user. The second part of Lab 4 modified the output for the factors so that it was right justified before the value of the row. For this program, you will use a 2-D array holding the values for each row including the spaces so that when printed, it will be right-justified and will look like the following Table of Factors from 1 to? (enter an integer): -10 125 10 10 You can picture the array that holds the above output looking like this: Columns0 Rows Space 10 ab Assignmen You will be creating a file called lab7.c today which will contain the program described above. The values in each column should be in a field width of 4. As always, you should take some time to think about this and come up with some sort of algorithm before haphazardly throwing down code. Make sure to test your code with several test cases. OUTPUT SAMPLE 2: Table of Factors from 1 to? (enter an integer): --35 maxNumFactors is 8 7 1 25 10 10 1 2 346 1212 13 1 2714 14 13 5 15 15 1 2 48 16 16 17 18 19 1 2 45 10 20 20 137 21 21 1 211 22 22 23 1 23 46 8 12 2424 152525 1 2 13 26 26 27 1 2 7 1428 28 29 1 23 5 6 10 15 3030 31 1 248 16 32 32 1 3 11 33 33 1 217 34 34 15 35 35 1 13 1 17 1 2369 18 1 19 1 23 13 927 1 29 1 31 You will be creating two files today, one called multTable.c and factorS.C In multTable.c. provide a C program that will de the following L. Prompt the user to enter an integor. Note: Use fprintt O and Escanffunctions throughout your program 2. Using loops, print out to the user a multiplication table from I to the number nicrod by the user SAMPLE OUTPUT Maltiplication Table from 3 to7 lenter an integer) 10 234S679 1 4610 12 14 16 18 20 36 9 12 15 18 21 24 27 30 6 12 18 24 30 36 42 48 54 714 21 28 35 42 4956 63 70 8 16 24 32 40 48 56 64 7280 9 18 27 36 45 54 63 72 81 90 0 20 30 40 50 60 70 80 90 100 . The mbers in the first column should be in a field of width 6 widh 2 spaces after the number, and each number in the remaining columns should be in a field of width 4 In factoES.,provide a C program that will do the following 1. Prompt the user to enter an integar. Note Use fprintt0 and Escant functions throughout your program 2. Using loops, print out to the user the factoes for each nummber from I to the number entered by the user SAMPLE OUTPUT Factors from 1 to 7 (enter an integer) 2 1 2 3 13 412 s 15 6 1236 7 1 812 4 913 12 5 10 10 The numbers in the finst column should be in a field of widh 4 with 2 spaces affer the number, and each number in the remaining columns should be just simplyd with 1 space after the d For this purt ofLab4, you wil beh programs from Part a irto one pmpan, but with the o lookng below: Table of Factors&Haltiples from 1 so7 enter an integer 22457810 24 16 20 24 28 32 36 2416 24 32 40 4856 64 72 234 12 12 24 36 60 2 84 56 108 120 13 13 26 3 52 65 78 91 304 127 330 5 15 0 45 75 90 105 320 135 150 117 17 34 5 68 85 102 119 336 153 170 236 91836 54 72 90 108 126 344 162 180 11 19 38 57 76 95 114 133 352 171 190 2 4510 202040 60 100 120 140 360 180 200 211 22 2244 110 132 154 176 398 220 38 161 184 207 230 123468 12 242448 2 6 120 144 168 392 236 240 525 2550 5 100 125 150 175 200 225 250 139 27 27 54 108 135 162 189 216 243 270 1247142 26 4 312 340 168 396 224 252 2 235 610 15 3060 90 320 150 180 210 240 270 300 Reminder About Style, Formatting, and Commenting Reqairements The top of your file should have a header comment, wibch shouldcomtain o Bricf description about what the peogram does o Any other helpful infomation that you think would be pood to have. Variables should be declarod at the top of the main function, and should have meaningful mames - One excoption to the rule of using meaningfal names foe variables is to useo on or some other single letler as a loop index variaNe mame this is a common, accaptable practice Always indent your code ta realable way. Some fmumng eumples may be found here: Don't forpet to use the -Wal1 fag when compiling, for esamplk: gce -Nall lab4.e You will be ceating a file called lab4.a soday whish will combine the two les that you created from Part a The output, as shown above, wall be a lde diffierent in that the factors will be right-ustified appearing before the number with the mukiplicati table for each line appearing atter. The rightustfication of the factors is non-trivial The width of the entire left side where the factors ashown wiB vary according to the highest number of factors for dat groupefnunben NetKe how intbe cumpk output below, the second talle is dufied more ithe right than the rst table became there are more fact n(for 12,there are 6 factes) than there are in the fiest table

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

Students also viewed these Databases questions