Chapter 1 Quiz Questions (CGS-3464) Mahendra Kumar

Slides:



Advertisements
Similar presentations
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Advertisements

1 9/13/06CS150 Introduction to Computer Science 1 Type Casting.
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
Computer Science 1620 Other Data Types. Quick Review: checklist for performing user input: 1) Be sure variable is declared 2) Prompt the user for input.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
1 10/11/06CS150 Introduction to Computer Science 1 do/while and Nested Loops.
C++ Typecasting. Math Library Functions.. Operator / Operands A = x + y.
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
General Computer Science for Engineers CISC 106 Lecture 26 Dr. John Cavazos Computer and Information Sciences 04/24/2009.
Computer Science 1620 Lifetime & Scope. Variable Lifetime a variable's lifetime is finite Variable creation: memory is allocated to the variable occurs.
Basic Elements of C++ Chapter 2.
Software Engineering 1 (Chap. 1) Object-Centered Design.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Modular Programming Chapter Value and Reference Parameters computeSumAve (x, y, sum, mean) ACTUALFORMAL xnum1(input) ynum2(input) sumsum(output)
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
1 C++ Programming Basics Chapter 2 Lecture CSIS 10A.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Fundamental Programming: Fundamental Programming Introduction to C++
1 CS161 Introduction to Computer Science Topic #3.
First steps Jordi Cortadella Department of Computer Science.
Chapter 7 Additional Control Structures. 2 2 void GetYesOrNo (/* out */ char& response) // Inputs a character from the user // Postcondition: response.
Introduction to C++ Basic Elements of C++. C++ Programming: From Problem Analysis to Program Design, Fourth Edition2 The Basics of a C++ Program Function:
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 2 Elementary Programming.
1 Original Source : and Problem and Problem Solving.ppt.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
CS Class 03 Topics  Sequence statements Input Output Assignment  Expressions Read pages Read pages 40 – 49 for next time.
#include using namespace std; // Declare a function. void check(int, double, double); int main() { check(1, 2.3, 4.56); check(7, 8.9, 10.11); } void check(int.
Quiz 2 Results. What Is Wrong? #include using namespace std int Main() { // Say Hello 4 times for(i == 0; i < 3; i++) { cout >> "Hello World!"
Modular Programming – User Defined Functions. CSCE 1062 Outline  Modular programming – user defined functions  Value returning functions  return statement.
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
CS Jan 2007 Chapter 2 sections 1, 2, 4 – 6, 8,
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
Lecture 5: Expressions and Interactivity Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
1 CS 1430: Programming in C++. 2 Input: Input ends with -1 Sentinel-Controlled Loop Input: Input begins with.
12/14/2016CS150 Introduction to Computer Science 1 Announcements  Website is up!   All lecture slides, assignments,
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 Structure of Simple C++ Program Chapter 1 09/09/13.
Chapter five exercises. a. false; b. true; c. false; d. true; e. true; f. true; g. true; h. false.
Bill Tucker Austin Community College COSC 1315
Chapter Topics The Basics of a C++ Program Data Types
Basics (Variables, Assignments, I/O)
What Actions Do We Have Part 1
Computing Fundamentals
Basic Elements of C++.
Chapter 2 Assignment and Interactive Input
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Basic Elements of C++ Chapter 2.
Chapter 2 Elementary Programming
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Basics (Variables, Assignments, I/O)
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
Programming Funamental slides
Starting Out with C++: From Control Structures through Objects
CSC 102 Chabli Boler.
CS150 Introduction to Computer Science 1
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
CS150 Introduction to Computer Science 1
CS150 Introduction to Computer Science 1
What Actions Do We Have Part 1
The switch Statement When we want to compare a variable against several values to see which one it has, we can use the switch statement: switch (status)
Presentation transcript:

Chapter 1 Quiz Questions (CGS-3464) Mahendra Kumar

Question 1 Which of the following is a valid name for an identifier? 1.interest rate 2.2fast 3.cout 4._foobar_2

Question 2 What data types can be used to store numeric values with a decimal point, such as 3.14 ? 1.char 2.short, int 3.Long 4.float, double

Question 3 Which of the following statements will correctly output the quote: Dan Quayle once said, "Who's responsible for the riots? The rioters." 1.cout << "Dan Quayle once said, Who's responsible for the riots? The rioters."; 2.cout << "Dan Quayle once said, \"Who's responsible for the riots? The rioters. \" "; 3.cout << "Dan Quayle once said, "Who's responsible for the riots? The rioters. " "; 4.cout << "Dan Quayle once said, "Who\'s responsible for the riots? The rioters. " ";

Question 4 What value is stored in variable x? int x; x = 2 * * / 2;

Question 5 What value is stored in x after the following two statements are executed: int x; x = 2 / 4 * 4 / 2;

Question 6 Runners often think of their speed in terms of how many minutes and seconds it takes to run a mile, but most treadmills express speed in miles per hour. Which expression correctly converts from 6.5 miles per hour to output the pace in minutes and seconds? 1.int secsPerMile = static_cast int paceMins, paceSecs; paceMins = secsPerMile / 60; paceSecs = paceMin % 60; 2.int secsPerMile = static_cast int paceMins, paceSecs; paceMins = secsPerMile / 60; paceSecs = secsPerMile / 60 / 60; 3. int secsPerMile = static_cast int paceMins, paceSecs; paceMins = secsPerMile / 60; paceSecs = secsPerMile % 60; 4. int secsPerMile = static_cast int paceMins, paceSecs; paceMins = secsPerMile / 60; paceSecs = secsPerMile % 60;

Question 7 What will the following code output? int x, y; x=3; y=(++x)*2; cout << x << " " << y << endl;

Question 8 How can we input a value from the keyboard and store it in the variable named num? 1.cin >> num; 2.cout << num; 3.num = input(); 4.cin << num;

Question 9 Which of the following is an invalid comment? 1./* Comment regarding the program */ 2./************************** * Comment about the program **************************/ 3./* Comment regarding the program 4.// Comment regarding the program

Question 10 For a newer C++ compiler, what must be added to the top of the program to allow access to cin and cout? 1.#include 2.#include using namespace std; 3.#include using namespace std; 4.using namespace std;