Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to C++
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Bookmark and Share
Lecture Comments (19)

1 answer

Last reply by: Alvin Sylvain
Sat Sep 26, 2015 4:53 PM

Post by ido montia on July 20, 2015

Q 4 homeWork, "then truncating the part after the decimal point" how i do it alvin?

this is my code :

#include<iostream>
using namespace std;

int main(){

float E, S, W;
cout << "The sales taxes collected by East Harlem : ";
cin >> E;

cout << "The sales taxes collected by South Boston : ";
cin >> S;

cout << "The sales taxes collected by West Hollywood : ";
cin >> W;

float sum;

sum = float(E)+ float(S) + float(W);
cout << "The Answer is :  " << (sum + 0.5);
cin.get();
cin.get();
cin.get();

1 answer

Last reply by: Alvin Sylvain
Sun Oct 26, 2014 11:52 AM

Post by Timothy White on October 24, 2014

Does C++ not have identical/not identical operators? (=== and !==)
Several other languages I know use these because '1' == 1 is true in those languages. Is that different in C++?

1 answer

Last reply by: Alvin Sylvain
Thu Feb 6, 2014 6:38 PM

Post by Ram Manohar Oruganti on February 6, 2014

int a = 5, b;
b = a++*7+9*++a;
cout<<a; // prints 7 (which is fine)
cout<<b; // prints 96 and not 98! Why is it so?

0 answers

Post by Adulaziz Al-etaibi on December 9, 2013

hi alvin , can you look at my code ,  it worked but can you evaluate it  


homework 4
#include <iostream>
using namespace std;

int main (){
   
   double east , south ,west, tax_e , tax_s, tax_w, total_amount;
   
   
   
   cout << "enter the sale e branch sales aamount?"<<endl;
   
   cin >> east;
   cout << " enter sale tax percentage ?" << endl;
   cin >> tax_e;
   
   cout << "enter sales and and taxes branch s ?"<<endl;
   
   cin >> south;
   cout << " enter sale tax percentage ?" << endl;
   cin >> tax_s;
   
   cout << "enter sales and and taxes branch  w ?"<<endl;
   
   
   cin >>  west;
   cout << " enter sale tax percentage ?" << endl;
   cin >> tax_w;
   
   tax_e *= east;
   tax_s *= south;
   tax_w *= west;
   cout << tax_e << tax_s << tax_w;
   total_amount = (int)tax_e + (int)(tax_s +(int) tax_w);
   
   cout << "total tax amount is?
" << total_amount;
}

1 answer

Last reply by: Alvin Sylvain
Wed Oct 2, 2013 7:24 AM

Post by G Johnson on October 1, 2013

I can't see the answers when I click on the answer link. Could you tell me the same answer you told Karpis Sanosyan?

1 answer

Last reply by: Alvin Sylvain
Thu Sep 26, 2013 10:12 AM

Post by G Johnson on September 25, 2013

Im having the same issue as Karpis Sanosyan, when I run the program, the prompt goes out if I press a key and it doesn't show my program

5 answers

Last reply by: Russell Burnham
Tue Aug 13, 2013 5:25 PM

Post by Karpis Sanosyan on September 30, 2012

Hi, quick question how do you add a delay to a program. Because I am using Visual c++ and it times out before I can read whats written.

1 answer

Last reply by: Alvin Sylvain
Mon Sep 24, 2012 8:11 PM

Post by charles campbell on September 22, 2012

Hi, quick question.. @ 7:45 in this lecture you talk about assignment and you show 3 int variables.. If i were to have to use this example for some reason..why would I have three variables be set to 17? why not just make one int set to 17 and use whenever you need it..

hopefully this isnt a confusing question

Operators & Expression

  • Most operators work on two “parameters” and return a value
  • Some operators work on just one
  • One has three parameters
  • Assignment operators designate “assigning” a value to a variable
  • Arithmetic operators perform arithmetic on their parameters to return the arithmetic value
  • Compound operators perform both arithmetic and assignment
  • Increment /Decrement operators change their parameter by 1
  • Comparison operators compare their parameters for equality, inequality, which is greater, etc. Their value is the “truth” of the comparison.
  • Logical operators test the “truth” of their parameters
  • Types can be “cast” into other types, sometimes with truncation
  • Types can be “promoted” to larger types
  • Operator precedence; operations are performed left to right, except certain operators are performed before others
  • Expressions consist of Variables, constants, functions, and other expressions, connected with operators, to return a value
  • Here is a link to a comprehensive list of C++ operators, include their precedence: http://www.cplusplus.com/doc/tutorial/operators/

Operators & Expression

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Overview 0:11
  • Parameters for Operators 0:47
  • Left Side vs. Right Side 1:56
    • Example
  • Operators - Assignment 3:40
  • Assignment - Don't Confuse Readers 5:17
  • Operators - Arithmetic 7:53
  • Operators - Compound Assignment 9:38
  • Operators: Increment / Decrement 10:24
    • Examples
    • Pre- vs. Post-Operator
  • Operators - Comparators 12:19
  • Operators - Logical 13:38
    • Examples
  • Operators - Boolean Truth Tables 15:45
    • Examples
  • Operators - Input and Output 18:42
    • I/O Stream
  • Operators - Type Casting, Sizeof 20:42
    • 'Sizeof'
  • Type-Casting Cautions 22:27
    • Classic Example
  • Type Promotion 25:46
  • Operator Precedence 26:58
    • Firth Things: Unary Operators
  • Expressions 28:32
    • Examples
  • Cautions 30:17
    • Classic Example
  • Hey! Wrong Kind of Operator! 32:13