Homework 3 CSE 1310 Introduction to Computers and Programming Fall 2022 Submission Deadline: Tuesday, 11/08/2022, 11:59 PM Instructions: • For each problem, your code must...

1 answer below »
Questions are in the attached document.


Homework 3 CSE 1310 Introduction to Computers and Programming Fall 2022 Submission Deadline: Tuesday, 11/08/2022, 11:59 PM Instructions: • For each problem, your code must compile without error/warning and produce the required output, a 0 grade will be assigned otherwise for that problem. • No partial credit will be given for code that does not cleanly compile. • Submit one StudentName_ID.c file with all the codes within that single file. 1. Write a function named gradeEval to evaluate the grade received by a student using the following parameters: Marks >= 90 : Grade A Marks >= 80 : Grade B Marks >= 70 : Grade C Marks >= 60 : Grade D Marks >= 40 : Grade E Marks < 40 : grade f the function should take an integer as the input parameter and return a character output. in the main program, take 4 user inputs for the physics, chemistry, english, and mathematics marks received by a student. print a report card for the grades that the student has received. a sample output for a student who has received 84 in physics, 71 in chemistry, 68 in english, and 22 in math would be: report card physics: b chemistry: c english: d mathematics: f note: this is a similar question to one you’ve already solved in hw2. this time, instead of writing multiple switch/case or if-else blocks, you need to write only one in the function, and call that function 4 times in the main program to evaluate the grades for all 4 subjects. 2. take two numbers as user input, and store them in the variables x and y. generate a random integer between 1 to 4 using the rand() function and store it in the variable calc. print the value of the calc variable. then use switch-case statements to perform the following calculations if the value of calc is 1, print the value of x+y if the value of calc is 2, print the value of x-y if the value of calc is 3, print the value of x*y if the value of calc is 4, print the value of x/y sample output: please enter the value of x: 10 please enter the value of y: 20 randomized value of calc is: 3 your output is x*y = 200 note: please convert explicitly to float wherever required (i.e. for division operation) 3. write a c program to create a function print_average with 3 parameters that calculates and prints the average of the 3 numbers passed to it. in the main program, take user inputs for 3 numbers and print their average using the print_average function. do not write a print statement in the main function other than the one(s) prompting the user for input. sample output: enter the first number: 10 enter the second number: 20 enter the first number: 30 the average of 10, 20, and 30 is 20. 4. write a c program to take four integer inputs/values from the user and store them in an integer array. print the array in a single line. then ask the user to enter an index/position of the array between 0 to 3, and print the value corresponding to that index in the array. after that, ask the user to enter two indices between 0 to 3, and swap the values of the respective indices, then print the updated array. sample output: enter four numbers for the array – enter a number: 10 enter a number: 20 enter a number: 30 enter a number: 40 10 20 30 40 enter a position between 0 to 3 to print: 2 value currently present in index 2 is 30 enter two positions of the array to swap: 0 2 the updated array is 30 20 10 40 5. write a c function named makesquare with one parameter to take an integer input and return the square of that integer. in the main function, take four integer inputs from the user and store them in an integer array. print the array in a single line, then ask the user to enter an index value between 0 to 3. print the value currently present in that index of the array, and use the makesquare function to obtain its squared value. update the given index value with the squared value, and then print the array. sample output: enter four numbers for the array – enter a number: 10 enter a number: 20 enter a number: 30 enter a number: 40 10 20 30 40 enter a position between 0 to 3 to square: 2 current value of index 2 is 30 the updated array is 10 20 900 40 6. write a c function named makesquaredirectly with 3 parameters, the first being an integer array, and the second being an integer i, and the third being the number of elements in the array. this function should square the value of the ith index of the array, and then print the updated array (important! printing the array should be done in this function itself!). in the main function, take four integer inputs from the user and store them in an integer array of length 4. print the array in a single line, then ask the user to enter an index value between 0 to 3. square the value of the index and print the updated array by using the makesquaredirectly function. sample output: enter four numbers for the array – enter a number: 10 enter a number: 20 enter a number: 30 enter a number: 40 10 20 30 40 enter a position between 0 to 3 to square: 2 current value of index 2 is 30 the updated array is 10 20 900 40 7. write a function called arraysum to return the sum of all numbers in an int array. write another function isodd to evaluate whether an integer is an odd number. in the main function create an int array of size 5 and take user inputs for each index in the array. using the arraysum and isodd functions, evaluate and print whether the sum of all the numbers in the array is odd or even. sample output: enter four numbers for the array – enter a number: 10 enter a number: 20 enter a number: 30 enter a number: 40 the array is: 10 20 30 40 the sum of the numbers in the array is even 8. write a c function named makesquare with one parameter to take an integer input and return the square of that integer. in the main function, create a 3x2 2- d array, and take and store user inputs for all positions in the array. print the array, then ask the user to enter an value between 1 to 3. for the value entered, call the makesquare function on every element in the corresponding row (e.g. if user enters 2, call makesquare on every element in the second row of the 2-d array) and update each element with the squared value. at the end, print the updated array sample output: enter 9 numbers for the array: enter a number: 1 enter a number: 2 enter a number: 3 enter a number: 4 enter a number: 5 enter a number: 6 the array is 1 2 3 4 5 6 enter the row to square: 3 the updated array is 1 2 3 4 25 36 40="" :="" grade="" f="" the="" function="" should="" take="" an="" integer="" as="" the="" input="" parameter="" and="" return="" a="" character="" output.="" in="" the="" main="" program,="" take="" 4="" user="" inputs="" for="" the="" physics,="" chemistry,="" english,="" and="" mathematics="" marks="" received="" by="" a="" student.="" print="" a="" report="" card="" for="" the="" grades="" that="" the="" student="" has="" received.="" a="" sample="" output="" for="" a="" student="" who="" has="" received="" 84="" in="" physics,="" 71="" in="" chemistry,="" 68="" in="" english,="" and="" 22="" in="" math="" would="" be:="" report="" card="" physics:="" b="" chemistry:="" c="" english:="" d="" mathematics:="" f="" note:="" this="" is="" a="" similar="" question="" to="" one="" you’ve="" already="" solved="" in="" hw2.="" this="" time,="" instead="" of="" writing="" multiple="" switch/case="" or="" if-else="" blocks,="" you="" need="" to="" write="" only="" one="" in="" the="" function,="" and="" call="" that="" function="" 4="" times="" in="" the="" main="" program="" to="" evaluate="" the="" grades="" for="" all="" 4="" subjects.="" 2.="" take="" two="" numbers="" as="" user="" input,="" and="" store="" them="" in="" the="" variables="" x="" and="" y.="" generate="" a="" random="" integer="" between="" 1="" to="" 4="" using="" the="" rand()="" function="" and="" store="" it="" in="" the="" variable="" calc.="" print="" the="" value="" of="" the="" calc="" variable.="" then="" use="" switch-case="" statements="" to="" perform="" the="" following="" calculations="" if="" the="" value="" of="" calc="" is="" 1,="" print="" the="" value="" of="" x+y="" if="" the="" value="" of="" calc="" is="" 2,="" print="" the="" value="" of="" x-y="" if="" the="" value="" of="" calc="" is="" 3,="" print="" the="" value="" of="" x*y="" if="" the="" value="" of="" calc="" is="" 4,="" print="" the="" value="" of="" x/y="" sample="" output:="" please="" enter="" the="" value="" of="" x:="" 10="" please="" enter="" the="" value="" of="" y:="" 20="" randomized="" value="" of="" calc="" is:="" 3="" your="" output="" is="" x*y="200" note:="" please="" convert="" explicitly="" to="" float="" wherever="" required="" (i.e.="" for="" division="" operation)="" 3.="" write="" a="" c="" program="" to="" create="" a="" function="" print_average="" with="" 3="" parameters="" that="" calculates="" and="" prints="" the="" average="" of="" the="" 3="" numbers="" passed="" to="" it.="" in="" the="" main="" program,="" take="" user="" inputs="" for="" 3="" numbers="" and="" print="" their="" average="" using="" the="" print_average="" function.="" do="" not="" write="" a="" print="" statement="" in="" the="" main="" function="" other="" than="" the="" one(s)="" prompting="" the="" user="" for="" input.="" sample="" output:="" enter="" the="" first="" number:="" 10="" enter="" the="" second="" number:="" 20="" enter="" the="" first="" number:="" 30="" the="" average="" of="" 10,="" 20,="" and="" 30="" is="" 20.="" 4.="" write="" a="" c="" program="" to="" take="" four="" integer="" inputs/values="" from="" the="" user="" and="" store="" them="" in="" an="" integer="" array.="" print="" the="" array="" in="" a="" single="" line.="" then="" ask="" the="" user="" to="" enter="" an="" index/position="" of="" the="" array="" between="" 0="" to="" 3,="" and="" print="" the="" value="" corresponding="" to="" that="" index="" in="" the="" array.="" after="" that,="" ask="" the="" user="" to="" enter="" two="" indices="" between="" 0="" to="" 3,="" and="" swap="" the="" values="" of="" the="" respective="" indices,="" then="" print="" the="" updated="" array.="" sample="" output:="" enter="" four="" numbers="" for="" the="" array="" –="" enter="" a="" number:="" 10="" enter="" a="" number:="" 20="" enter="" a="" number:="" 30="" enter="" a="" number:="" 40="" 10="" 20="" 30="" 40="" enter="" a="" position="" between="" 0="" to="" 3="" to="" print:="" 2="" value="" currently="" present="" in="" index="" 2="" is="" 30="" enter="" two="" positions="" of="" the="" array="" to="" swap:="" 0="" 2="" the="" updated="" array="" is="" 30="" 20="" 10="" 40="" 5.="" write="" a="" c="" function="" named="" makesquare="" with="" one="" parameter="" to="" take="" an="" integer="" input="" and="" return="" the="" square="" of="" that="" integer.="" in="" the="" main="" function,="" take="" four="" integer="" inputs="" from="" the="" user="" and="" store="" them="" in="" an="" integer="" array.="" print="" the="" array="" in="" a="" single="" line,="" then="" ask="" the="" user="" to="" enter="" an="" index="" value="" between="" 0="" to="" 3.="" print="" the="" value="" currently="" present="" in="" that="" index="" of="" the="" array,="" and="" use="" the="" makesquare="" function="" to="" obtain="" its="" squared="" value.="" update="" the="" given="" index="" value="" with="" the="" squared="" value,="" and="" then="" print="" the="" array.="" sample="" output:="" enter="" four="" numbers="" for="" the="" array="" –="" enter="" a="" number:="" 10="" enter="" a="" number:="" 20="" enter="" a="" number:="" 30="" enter="" a="" number:="" 40="" 10="" 20="" 30="" 40="" enter="" a="" position="" between="" 0="" to="" 3="" to="" square:="" 2="" current="" value="" of="" index="" 2="" is="" 30="" the="" updated="" array="" is="" 10="" 20="" 900="" 40="" 6.="" write="" a="" c="" function="" named="" makesquaredirectly="" with="" 3="" parameters,="" the="" first="" being="" an="" integer="" array,="" and="" the="" second="" being="" an="" integer="" i,="" and="" the="" third="" being="" the="" number="" of="" elements="" in="" the="" array.="" this="" function="" should="" square="" the="" value="" of="" the="" ith="" index="" of="" the="" array,="" and="" then="" print="" the="" updated="" array="" (important!="" printing="" the="" array="" should="" be="" done="" in="" this="" function="" itself!).="" in="" the="" main="" function,="" take="" four="" integer="" inputs="" from="" the="" user="" and="" store="" them="" in="" an="" integer="" array="" of="" length="" 4.="" print="" the="" array="" in="" a="" single="" line,="" then="" ask="" the="" user="" to="" enter="" an="" index="" value="" between="" 0="" to="" 3.="" square="" the="" value="" of="" the="" index="" and="" print="" the="" updated="" array="" by="" using="" the="" makesquaredirectly="" function.="" sample="" output:="" enter="" four="" numbers="" for="" the="" array="" –="" enter="" a="" number:="" 10="" enter="" a="" number:="" 20="" enter="" a="" number:="" 30="" enter="" a="" number:="" 40="" 10="" 20="" 30="" 40="" enter="" a="" position="" between="" 0="" to="" 3="" to="" square:="" 2="" current="" value="" of="" index="" 2="" is="" 30="" the="" updated="" array="" is="" 10="" 20="" 900="" 40="" 7.="" write="" a="" function="" called="" arraysum="" to="" return="" the="" sum="" of="" all="" numbers="" in="" an="" int="" array.="" write="" another="" function="" isodd="" to="" evaluate="" whether="" an="" integer="" is="" an="" odd="" number.="" in="" the="" main="" function="" create="" an="" int="" array="" of="" size="" 5="" and="" take="" user="" inputs="" for="" each="" index="" in="" the="" array.="" using="" the="" arraysum="" and="" isodd="" functions,="" evaluate="" and="" print="" whether="" the="" sum="" of="" all="" the="" numbers="" in="" the="" array="" is="" odd="" or="" even.="" sample="" output:="" enter="" four="" numbers="" for="" the="" array="" –="" enter="" a="" number:="" 10="" enter="" a="" number:="" 20="" enter="" a="" number:="" 30="" enter="" a="" number:="" 40="" the="" array="" is:="" 10="" 20="" 30="" 40="" the="" sum="" of="" the="" numbers="" in="" the="" array="" is="" even="" 8.="" write="" a="" c="" function="" named="" makesquare="" with="" one="" parameter="" to="" take="" an="" integer="" input="" and="" return="" the="" square="" of="" that="" integer.="" in="" the="" main="" function,="" create="" a="" 3x2="" 2-="" d="" array,="" and="" take="" and="" store="" user="" inputs="" for="" all="" positions="" in="" the="" array.="" print="" the="" array,="" then="" ask="" the="" user="" to="" enter="" an="" value="" between="" 1="" to="" 3.="" for="" the="" value="" entered,="" call="" the="" makesquare="" function="" on="" every="" element="" in="" the="" corresponding="" row="" (e.g.="" if="" user="" enters="" 2,="" call="" makesquare="" on="" every="" element="" in="" the="" second="" row="" of="" the="" 2-d="" array)="" and="" update="" each="" element="" with="" the="" squared="" value.="" at="" the="" end,="" print="" the="" updated="" array="" sample="" output:="" enter="" 9="" numbers="" for="" the="" array:="" enter="" a="" number:="" 1="" enter="" a="" number:="" 2="" enter="" a="" number:="" 3="" enter="" a="" number:="" 4="" enter="" a="" number:="" 5="" enter="" a="" number:="" 6="" the="" array="" is="" 1="" 2="" 3="" 4="" 5="" 6="" enter="" the="" row="" to="" square:="" 3="" the="" updated="" array="" is="" 1="" 2="" 3="" 4="" 25="">
Answered Same DayNov 08, 2022

Answer To: Homework 3 CSE 1310 Introduction to Computers and Programming Fall 2022 Submission...

Vikas answered on Nov 08 2022
42 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here