Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- // variables declaration
- int x=92,y=7;
- string s="Programming is fun";
- char w='X';
- double a = 2.9999925;
- float b = 2.334f;
- int i; // This variable is not used so may get a warning.
- cout<<"The sum of two numbers is "<<x+y<<endl;
- cout<<"The difference of two numbers is "<<x-y<<endl;
- cout<<"The quotient of two numbers is "<<x/y<<endl;
- cout<<"The product of two numbers is "<<x*y<<endl;
- cout<<w<<w<<w<<s<<w<<w<<w;
- //conditional statement < > <= >= <> != relational operators
- // boolean operators && (and) || (or) !(not)
- if (!(a>b || x<y)) { // true || false = true
- cout<<a<<" is greater than "<<b<<"."<<endl;
- cout<<"This is the second statement."<<endl;
- }
- else
- cout<<"Am here."<<endl;
- cout<<"Am here too."<<endl;
- //Looping
- for (int counter=1; counter<=10; counter+=2) {
- cout<<counter<<endl;
- }
- cout<<"end of loop"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement