what is output line of the following c++ code? please trace int i = 1, qp; data: 4, b, 3, a double...

24
What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG; while ( i <= 2) { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Upload: shannon-dickason

Post on 01-Apr-2015

217 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG; while ( i <= 2) { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Page 2: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP string LG; 1 while ( i <= 2) { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Page 3: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit string LG; 1 0.0 while ( i <= 2) { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Page 4: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num string LG; 1 0.0 0.0 while ( i <= 2) { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Page 5: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 0.0 0.0 while ( i <= 2) { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Page 6: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 0.0 0.0 while ( i <= 2) //true { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Page 7: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 0.0 0.0 while ( i <= 2) //true { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade?

Page 8: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 4 0.0 0.0 “B” while ( i <= 2) //true { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 B

Page 9: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 4 0.0 0.0 “B” while ( i <= 2) //true { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") //false { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 B

Page 10: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) //true { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") //false { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 B

Page 11: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) //true 4.0 { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") //false { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 B

Page 12: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QPcredit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) //true 4.0 12.0 { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") //false { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 B

Page 13: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QPcredit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // 2 4.0 12.0 { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 B

Page 14: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QPcredit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // true 2 4.0 12.0 { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 B

Page 15: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QPcredit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // true 2 4.0 12.0 { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade?

Page 16: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QPcredit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // true 2 3 4.0 12.0 ”A” { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 A

Page 17: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QPcredit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // true 2 3 4.0 12.0 ”A” { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // true { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 A

Page 18: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QPcredit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // true 2 4 3 4.0 12.0 ”A” { cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // true { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 A

Page 19: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QPcredit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // true 2 4 3 4.0 12.0 ”A” { 7.0 cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // true { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 A

Page 20: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // true 2 4 3 4.0 12.0 ”A” { 7.0 24.0 cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // true { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 A

Page 21: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // 2 4 3 4.0 12.0 ”A” { 3 7.0 24.0 cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 A

Page 22: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; _i_ QP credit totCredit num LG string LG; 1 3 4 0.0 0.0 “B” while ( i <= 2) // false 2 4 3 4.0 12.0 ”A” { 3 7.0 24.0 cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 A

Page 23: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; GPA _i_ QP credit totCredit num LG string LG; 3.43 1 3 4 0.0 0.0 “B” while ( i <= 2) // false 2 4 3 4.0 12.0 ”A” { 3 7.0 24.0 cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 A

Page 24: What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;

What is output line of the following C++ code? Please trace

int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; GPA _i_ QP credit totCredit num LG string LG; 3.43 1 3 4 0.0 0.0 “B” while ( i <= 2) // false 2 4 3 4.0 12.0 ”A” { 3 7.0 24.0 cout<<"Class # "<<i<<"credit Letter Grade? "; cin >>credit>>LG; if (LG == "A") // { QP = 4; } else { QP = 3; } totCredit = totCredit + credit; num = num + credit * QP; i = i + 1; } double GPA = num / totCredit; cout<<"GPA = "<<GPA<<endl;

Class # 1 credit Letter Grade? 4 BClass # 2 credit Letter Grade? 3 AGPA= 3.42857