{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ese cheat sheet

ese cheat sheet - Quizs 9-14 Yellow Design a program in C...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Design a program in C which will compute, using the method of call by reference , the equivalent resistance to four resistors connected in series . When executed, the program will do the following in sequence: 1. Ask the user to type on the keyboard the values of the individual resistances in floating- point format. Assume all of the resistance values to be in kΩ. 2. Display on the console the names and values of the individual resistances. 3. Compute and display on the console the value of the equivalent resistance. The format of the output is to be one resistance value per line. SOLUTION: #include<stdio.h> float EquResistance(float *R1,float *R2,float *R3,float *R4); main(){ float R1,R2,R3,R4,equR; int i; printf("Enter resistance of resistor 1: "); scanf("%f",&R1); printf("Enter resistance of resistor 2: "); scanf("%f",&R2); printf("Enter resistance of resistor 3: "); scanf("%f",&R3); printf("Enter resistance of resistor 4: "); scanf("%f",&R4); printf("\n"); printf("The resistance of resisotr 1 is %.2f\n",R1); printf("The resistance of resisotr 2 is %.2f\n",R2); printf("The resistance of resisotr 3 is %.2f\n",R3); printf("The resistance of resisotr 4 is %.2f\n",R4); printf("\n"); equR = EquResistance(&R1,&R2,&R3,&R4); printf("The equivalent resistance is %.2f\n",equR); } float EquResistance(float *R1,float *R2,float *R3,float *R4){ return (*R1+*R2+*R3+*R4); } The following statements are part of a C program: int a[10]={68,22,30,25,19,21,66,38,46,23};
int *ptra; ptra=a; Assuming that the address of a[0] is 256 bytes, and that the compiler uses 2 bytes of RAM to store an integer number, find the values of the following quantities; Quantities Values a 256 ptra 256 &a[2] 260 &a[8] 272 a+5 266 a[5] 21 ptra+3 262 *ptra 68 *(ptra+6) 66 &*(ptra+7) 270 -------------------------------------------------------------------------------------------------------------------------------------- - Write a program in C which takes in the following input array of integer numbers a[4] = {58,22,45,33} and reorders the elements of the array through a swapping process to output the array b[4]={22,58,33,45}.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern