Write a program, that after the input of a resistance-value, by means of a while{}, checks if this value exists
in the E12 range (10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82 and decimal powers until 8,2 Mohm)
Use an array to store this E12 range.
1
Expert's answer
2011-10-18T08:40:00-0400
#include <iostream.h> main(){ int R[12]; R[0] = 10; R[1] = 12; R[2] = 15; R[3] = 18; R[4] = 22; R[5] = 27; R[6] = 33; R[7] = 39; R[8] = 47; R[9] = 56; R[10] = 68; R[11] = 82; bool E12=false; int dec=1; int i; cout<<"Enter resistance value:\n"; cin>>res; while ((E12==false)&&(dec<=82000000)){ & for (i=0;i<=11;i++){ if (res==R[i]*dec) E12=true; } & dec=dec*10; & } if (E12==true) cout<<"Resistance exists in the E12 range.\n"; if (E12==false) cout<<"Resistance doesn't exist in the E12 range.\n"; }
Comments
Leave a comment