ese cheat sheet

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

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

View Full Document Right Arrow Icon
Quizs 9-14 Yellow Design a program in C which will compute, using the method of call by value , the highest grade in an examination. When executed, the program will do the following in sequence: 1. Ask the user to type on the keyboard the number of students taking the examination. 2. Ask the user to type on the keyboard the grades for the class. 3. Display on the console the grades. 4. Compute and display on the console the highest grade in the class. #include<stdio.h> #define max 100 float HighestGrade(float grade[],int number); main(){ int number,i; float grade[max],highest; printf("Enter the # of students: "); scanf("%d",&number); printf("\n"); for(i=0;i<number;i++){ printf("Enter the grade of student %d: ",i+1); scanf("%f",&grade[i]); } printf("\n"); for(i=0;i<number;i++){ printf("The grade of student %d is %.2f\n",i+1,grade[i]); } printf("\n"); highest = HighestGrade(grade,number); printf("The highest grade is %.2f",highest); } float HighestGrade(float grade[],int number){ int i; float highest=grade[0]; for(i=1;i<number;i++){ if(highest<grade[i]){ highest = grade[i]; } } return highest; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
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};
Background image of page 2
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 260 272 a+5 266 a[5] 21 ptra+3 262 *ptra 68 *(ptra+6) 66 270 --------------------------------------------------------------------------------------------------------------------------------------
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 23

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

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online