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;

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

Programming Methodology (1). Implementing Methods main.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Hand Trace and Output for: int digit = 0; int number = 1423; do { digit = number % 10; System.out.println(digit); number = number / 10; } while (number.
CS110 Programming Language I
Public class ABC { private int information = 0; private char moreInformation = ‘ ‘; public ABC ( int newInfo, char moreNewInfo) { } public ABC () {} public.
Discussion1 Quiz. Q1 Which of the following are invalid Java identifiers (variable names)? a) if b) n4m3 c) Java d) e) DEFAULT_VALUE f) bad-choice.
Introduction to Programming with Java, for Beginners “Has a” Relationship.
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
1 Powers of Two: Trace Ex. Print powers of 2 that are  2 N. Increment i from 0 to N. Double v each time. int i = 0; int v = 1; while (i
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Introduction to VC++.NET #include”stdsfx.h” // includes contents of stdsfx.h into this program file #using // references prepackaged Microsoft code Using.
1 CS150 Introduction to Computer Science 1 Exponents & Output page & Section 3.8.
1 9/26/07CS150 Introduction to Computer Science 1 Exponents & Output page & Section 3.8.
The printf Method The printf method is another way to format output. It is based on the printf function of the C language. System.out.printf(,,,..., );
Computer Programming Lab(5).
Method for verifying a credit card number: Example:
CSC 1051 M.A. Papalaskari, Villanova University Repetition CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing.
Variable = expression type name; int x;x____________________ int y;y____________________ int z;z____________________.
Chapter 2 Practice.
Creating With Code.
PreAP Computer Science Quiz
C++ Character Set It is set of Characters/digits/symbol which is valid in C++. Example – A-Z, (white space) C++ Character Set It is set of.
Lecture 8 Using casts, Strings and WordUtil. Agenda Generating random numbers Casts – Casting a double into an int – Casting an int into a char – Casting.
Scope When we create variables and functions, they are limited in where they are visible and where they can be referenced For the most part, the identifiers.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 2.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Dialog Boxes.
Calling Methods. Review  We can declare and create objects: Dinosaur dino; dino = new Dinosaur();  We can also shortcut the first two lines: Dinosaur.
CSC 212 – Data Structures Lecture 2: Primitives, References, & Classes.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Building java programs, chapter 3 Parameters, Methods and Objects.
int num = 22; if (num > 0) if (num % 5 == 0) System.out.println(num); else System.out.println(num + “ is negative”);
A: A: double “4” A: “34” 4.
1 Class Chapter Objectives Use a while loop to repeat a series of statements Get data from user through an input dialog box Add error checking.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
THE DOUBLE VARIABLE The double variable can hold very large (or small) numbers. The maximum and minimum values are 17 followed by 307 zero’s.
(Monty) Python for loops Mr. Neat. Comparison JavaC++Python source code name.java.cpp.py Object Oriented? required optional functions/ methods ( bob.hide()
Chapter 11 Structures, Unions and Typedef 11.1 Structures Structures allow us to group related data items of different types under a common name. The individual.
REEM ALAMER REVISION FOR C LANGUAGE COURSE. OUTPUTS int main (void) { int C1, C2; int *p1, *p2; C1 = 8; p1 = &C1; C2 = *p1 / 2 + 5; p2 = &C2; printf ("C1.
Java for Beginners University Greenwich Computing At School DASCO
Two Dimensional Array Mr. Jacobs.
Chapter 2 Assignment and Interactive Input
Register Use Policy Conventions
Method Mark and Lyubo.
Review Operation Bingo
Operators and Expressions
Arrays & pointers C How to Program, 8/e.
Arrays November 8, 2017.
The switch statement: an alternative to writing a lot of conditionals
Selection Control Structure: Switch Case Statement
Bracket Operator.
Methods and Data Passing
Methods and Data Passing
See requirements for practice program on next slide.
Boolean Variables & Values
Fundamental Programming
Method for verifying a credit card number:
Input, Variables, and Mathematical Expressions
Quiz 11 February 13, 2019.
More Basics of Python Common types of data we will work with
Repetition CSC 1051 – Data Structures and Algorithms I Course website:
MIS 222 – Lecture 12 10/9/2003.
Optional Topic: User Input with Scanner
Methods and Data Passing
Presentation transcript:

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;

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;

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 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;

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 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;

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; 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;

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; 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;

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; 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?

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; “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

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; “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

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; “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

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; “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

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; “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

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; “B” 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; Class # 1 credit Letter Grade? 4 B

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; “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

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; “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 Class # 2 credit Letter Grade?

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; “B” while ( i <= 2) // true ”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 B Class # 2 credit Letter Grade? 3 A

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; “B” while ( i <= 2) // true ”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 B Class # 2 credit Letter Grade? 3 A

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; “B” while ( i <= 2) // true ”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 B Class # 2 credit Letter Grade? 3 A

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; “B” while ( i <= 2) // true ”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 B Class # 2 credit Letter Grade? 3 A

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; “B” while ( i <= 2) // true ”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 B Class # 2 credit Letter Grade? 3 A

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; “B” while ( i <= 2) // ”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 B Class # 2 credit Letter Grade? 3 A

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; “B” while ( i <= 2) // false ”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 B Class # 2 credit Letter Grade? 3 A

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_ QPcredit totCredit num LG string LG; “B” while ( i <= 2) // false ”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 B Class # 2 credit Letter Grade? 3 A

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_ QPcredit totCredit num LG string LG; “B” while ( i <= 2) // false ”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 B Class # 2 credit Letter Grade? 3 A GPA=