Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a program that requests two integers, min and max. Write a function nam

ID: 3699396 • Letter: 1

Question

1. Write a program that requests two integers, min and max. Write a function named output to print al1 odd numbers from inclusive. max down to min a) Main should handle all input. b) Implement a validation 1oop to c) Secondary function should handle all looping and output. verify that max is greater than min. Output Example: Enter two integers, min and max (separate by a space): 10 1 Max must be greater than min. Enter two integers, min and max (separate by a space): 1 10 9 7 5 3 2. Write a program to illustrate the Ohm's Law, I-V/R. The program wil1 first request to input (in ohm written which will return the value of and a out a table that shows the value of current under each increment of voltage. The maximum voltage is set to 50 volts. an initial voltage (in volt), a fixed resistance ) and an incremental interval for voltage. A function should be current (in amp) given a voltage resistance. Then the program will call the function and print a) Main should handle al1 input and output. (This requires that variables in main are updated by the function.) b) Secondary function should handle all calculations. c) Set precision to 2. Output Example: Enter the initial voltage (in volt): 40 Enter the resistance (in ohm): 10 Enter the voltage incremental interval (in volt): 2 Voltage (volt) Resistance (ohm) Current (amp) 40 42 10 10 10 10 10 10 4.00 4.20 4.40 4.60 4.80 5.00 46 48 50

Explanation / Answer

#include <iostream>

using namespace std;
void output(int min, int max) {
for(int i=max;i>=1;i--) {
if(i%2!=0){
cout<<i<<" ";
}
}
cout<<endl;
}
int main()
{
int min, max;
cout<<"Enter two integers, min and max: (separate by spacec): "<<endl;
cin >> min >> max;
if(min>max) {
cout<<"Max must be greater than min"<<endl;
}else {
output(min, max);
}

return 0;
}

Output:

#include <iostream>
#include <iomanip>
using namespace std;
double calc(int v, int r) {
return v/(double)r;
}
int main()
{
int v,r,inc;
cout<<"Enter the initial voltage (in volt): "<<endl;
cin>> v;
cout<<"Enter the resistance (in ohm): "<<endl;
cin >> r;
cout<<"Enter the voltage incremental interval (in volt): "<<endl;
cin >> inc;
cout<<"Voltage(in volt) Resistance(in volt) Current(in amp):"<<endl;
cout<<fixed<<setprecision(2);
for(int i= v;i<=50;i+=inc) {
cout<<i<<" "<<r<<" "<<calc(i,r)<<endl;   
}

return 0;
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote