Advertisement
alfps

Untitled

Apr 20th, 2021
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.     // variables declaration
  7.     int x=92,y=7;
  8.     string s="Programming is fun";
  9.     char w='X';
  10.     double a = 2.9999925;
  11.     float b = 2.334f;
  12.     int i;      // This variable is not used so may get a warning.
  13.     cout<<"The sum of two numbers is "<<x+y<<endl;
  14.     cout<<"The difference of two numbers is "<<x-y<<endl;
  15.     cout<<"The quotient of two numbers is "<<x/y<<endl;
  16.     cout<<"The product of two numbers is "<<x*y<<endl;
  17.     cout<<w<<w<<w<<s<<w<<w<<w;
  18.    
  19.     //conditional statement < > <= >= <> != relational operators
  20.     // boolean operators && (and) || (or) !(not)
  21.     if (!(a>b || x<y)) { // true || false = true
  22.         cout<<a<<" is greater than "<<b<<"."<<endl;
  23.         cout<<"This is the second statement."<<endl;
  24.     }
  25.     else
  26.         cout<<"Am here."<<endl;
  27.     cout<<"Am here too."<<endl;
  28.    
  29.     //Looping
  30.     for (int counter=1; counter<=10; counter+=2) {
  31.         cout<<counter<<endl;
  32.     }
  33.     cout<<"end of loop"<<endl;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement