1)the voltage of a resistor is calculated by ohm's law: V=RI. write a progra
ID: 3629984 • Letter: 1
Question
1)the voltage of a resistor is calculated by ohm's law: V=RI. write a program that will input resistance R, current I for several resistors, and will calculate and display the voltage for each resistor. the loop will terminate if your enter -1 as the resistance value.(Note that your program should output nothing when -1 is entered as the resistance valu)2) design a program that will help an elementary school student learn multiplication. Use rand() to generate two integer number between 1 to 9. you program will first ask a question such as: 6x 7=? the student then should type the anser on the same line. then your program checks the students answer. if it is correct print verygood and then let the student try the same question again repeatedly. the loop will end if the student enters "-1" as the answer
Explanation / Answer
Dear Friend Here is the programs u want PLEASE RATE First Program #include int main() { float res,I; float v; printf("%s ","please enter the values for the current and resistance"); scanf_s("%f %f",&I,&res); while(res!=-1) { v=res*I; printf("%s %f ","the voltage for this resitor = ",v); printf("%s ","please enter the values for the current and resistance"); scanf_s("%f %f",&I,&res); } } Second Program #include #include int main() { int ans=1,cans; while(ans!=-1) { int iRand = (rand() % 9) + 1; int iRand2 = (rand() % 9) + 1; printf("%s %d %s %d ","what is the result for ",iRand," x ",iRand2); scanf_s("%d",&ans); cans=iRand*iRand2; if(ans==-1) break; else if(cans==ans) printf("%s ","correct answer"); else { printf("%s ","wrong answer"); printf("%s %d ","correct answer = ",cans); } } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.