├── C++ Access Specifiers.txt ├── C++ Access Strings.txt ├── C++ Assignment Operators.txt ├── C++ Boolean Data Types.txt ├── C++ Boolean Expressions.txt ├── C++ Booleans.txt ├── C++ Break.txt ├── C++ Character Data Type 1.txt ├── C++ Character Data Types 2.txt ├── C++ Class Methods Inside Example.txt ├── C++ Class Methods Outside Example.txt ├── C++ Class Methods Parameters.txt ├── C++ Classes and Objects Multiple.txt ├── C++ Classes and Objects.txt ├── C++ Comments.txt ├── C++ Comparison Operators.txt ├── C++ Conditions and If Statements.txt ├── C++ Constructors.txt ├── C++ Continue.txt ├── C++ Data Types.txt ├── C++ Default Parameters value.txt ├── C++ Dereference.txt ├── C++ DoWhile Loop.txt ├── C++ Encapsulation Access Private Members.txt ├── C++ Files and read file.txt ├── C++ For Loop.txt ├── C++ Function Overloading 1.txt ├── C++ Function Overloading 2.txt ├── C++ Functions - Pass By Reference.txt ├── C++ How To Add Two Numbers.txt ├── C++ Inheritance Access.txt ├── C++ Inheritance.txt ├── C++ Logical Operators &&,ll,!.txt ├── C++ Math.txt ├── C++ Memory Address.txt ├── C++ Modify Pointers.txt ├── C++ Multilevel Inheritance.txt ├── C++ Multiple Inheritance.txt ├── C++ Multiple Parameters.txt ├── C++ Numbers and Strings.txt ├── C++ Omit Array Size.txt ├── C++ Output (Print Text).txt ├── C++ Pointers.txt ├── C++ Polymorphism.txt ├── C++ References.txt ├── C++ Short Hand If Else.txt ├── C++ String Concatenation.txt ├── C++ String Data Types.txt ├── C++ String Length.txt ├── C++ String Namespace.txt ├── C++ Strings.txt ├── C++ Switch Statements.txt ├── C++ The Return Keyword 1.txt ├── C++ The Return Keyword 2.txt ├── C++ The Return Keyword 3.txt ├── C++ User Input Strings.txt ├── C++ User Input.txt ├── C++ Variables.txt ├── C++ While Loop.txt ├── C++ cmath Header.txt ├── C++Exceptions try and catch.txt ├── C++arithmetic Operators.txt ├── C++variables Identifiers.txt ├── README.md ├── c++ Access the Elements of an Array.txt ├── c++ Add Variables Together.txt ├── c++ Break in While Loop.txt ├── c++ Call a Function.txt ├── c++ Change an Array Element.txt ├── c++ Constructor Parameters 1.txt ├── c++ Constructor Parameters.txt ├── c++ Continue in While Loop.txt ├── c++ Creating a Simple Calculator.txt ├── c++ Declare Many Variables.txt ├── c++ Handle Any Type of Exceptions (...).txt ├── c++ Loop Through an Array 1 count.txt ├── c++ Loop Through an Array.txt ├── c++ Numeric Types (double).txt ├── c++ Numeric Types (float).txt ├── c++ Numeric Types (int).txt ├── c++ Omit Elements on Declaration.txt ├── c++ Omitting Namespace.txt ├── c++ The else Statement.txt ├── c++ The else if Statement.txt ├── c++ function Parameters and Arguments.txt ├── c++ hellow world.txt ├── c++ output (print text next endl).txt └── c++ output (print text next line).txt /C++ Access Specifiers.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class MyClass { 5 | public: // Public access specifier 6 | int x; // Public attribute 7 | private: // Private access specifier 8 | int y; // Private attribute 9 | }; 10 | 11 | int main() { 12 | MyClass myObj; 13 | myObj.x = 25; // Allowed (x is public) 14 | myObj.y = 50; // Not allowed (y is private) 15 | return 0; 16 | } // Creater By Sanusanth 17 | -------------------------------------------------------------------------------- /C++ Access Strings.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string myString = "Hello"; 7 | cout << myString[0]; 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ Assignment Operators.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x = 10; 6 | x += 5; 7 | cout << x; 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ Boolean Data Types.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | bool isCodingFun = true; 6 | bool isFishTasty = false; 7 | cout << isCodingFun << "\n"; 8 | cout << isFishTasty; 9 | return 0; 10 | } // Creater By Sanusanth 11 | -------------------------------------------------------------------------------- /C++ Boolean Expressions.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x = 10; 6 | int y = 9; 7 | cout << (x > y); 8 | return 0; 9 | } //Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ Booleans.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | bool isCodingFun = true; 6 | bool isFishTasty = false; 7 | cout << isCodingFun << "\n"; 8 | cout << isFishTasty; 9 | return 0; 10 | } // Creater By Sanusanth 11 | -------------------------------------------------------------------------------- /C++ Break.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | for (int i = 0; i < 10; i++) { 6 | if (i == 4) { 7 | break; 8 | } 9 | cout << i << "\n"; 10 | } 11 | return 0; 12 | } // Creter By Sanusanth 13 | 14 | -------------------------------------------------------------------------------- /C++ Character Data Type 1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main () { 5 | char a = 65, b = 66, c = 67; 6 | cout << a; 7 | cout << b; 8 | cout << c; 9 | return 0; 10 | } // Creater By Sanusanth 11 | -------------------------------------------------------------------------------- /C++ Character Data Types 2.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main () { 5 | char myGrade = 'B'; 6 | cout << myGrade; 7 | return 0; 8 | } // Creater By Sanusanth 9 | -------------------------------------------------------------------------------- /C++ Class Methods Inside Example.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class MyClass { // The class 5 | public: // Access specifier 6 | void myMethod() { // Method/function 7 | cout << "Hello World!"; 8 | } 9 | }; 10 | 11 | int main() { 12 | MyClass myObj; // Create an object of MyClass 13 | myObj.myMethod(); // Call the method 14 | return 0; 15 | } // Creater By Sanusanth 16 | -------------------------------------------------------------------------------- /C++ Class Methods Outside Example.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class MyClass { // The class 5 | public: // Access specifier 6 | void myMethod(); // Method/function declaration 7 | }; 8 | 9 | // Method/function definition outside the class 10 | void MyClass::myMethod() { 11 | cout << "Hello World!"; 12 | } 13 | 14 | int main() { 15 | MyClass myObj; // Create an object of MyClass 16 | myObj.myMethod(); // Call the method 17 | return 0; 18 | } // Creater By Sanusanth 19 | -------------------------------------------------------------------------------- /C++ Class Methods Parameters.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Car { 5 | public: 6 | int speed(int maxSpeed); 7 | }; 8 | 9 | int Car::speed(int maxSpeed) { 10 | return maxSpeed; 11 | } 12 | 13 | int main() { 14 | Car myObj; 15 | cout << myObj.speed(200); 16 | return 0; 17 | } // Creater By Sanusanth 18 | -------------------------------------------------------------------------------- /C++ Classes and Objects Multiple.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Car { 6 | public: 7 | string brand; 8 | string model; 9 | int year; 10 | }; 11 | 12 | int main() { 13 | Car carObj1; 14 | carObj1.brand = "BMW"; 15 | carObj1.model = "X5"; 16 | carObj1.year = 1999; 17 | 18 | Car carObj2; 19 | carObj2.brand = "Ford"; 20 | carObj2.model = "Mustang"; 21 | carObj2.year = 1969; 22 | 23 | cout << carObj1.brand << " " << carObj1.model << " " << carObj1.year << "\n"; 24 | cout << carObj2.brand << " " << carObj2.model << " " << carObj2.year << "\n"; 25 | return 0; 26 | } // Creater By Sanusanth 27 | -------------------------------------------------------------------------------- /C++ Classes and Objects.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class MyClass { // The class 6 | public: // Access specifier 7 | int myNum; // Attribute (int variable) 8 | string myString; // Attribute (string variable) 9 | }; 10 | 11 | int main() { 12 | MyClass myObj; // Create an object of MyClass 13 | 14 | // Access attributes and set values 15 | myObj.myNum = 15; 16 | myObj.myString = "Some text"; 17 | 18 | // Print values 19 | cout << myObj.myNum << "\n"; 20 | cout << myObj.myString; 21 | return 0; 22 | } // Creater By Sanusanth 23 | -------------------------------------------------------------------------------- /C++ Comments.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // This is a comment 6 | cout << "Hello World!"; 7 | return 0; 8 | } // Creater By Sanusanth 9 | -------------------------------------------------------------------------------- /C++ Comparison Operators.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x = 5; 6 | int y = 3; 7 | cout << (x > y); // returns 1 (true) because 5 is greater than 3 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ Conditions and If Statements.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | if (20 > 18) { 6 | cout << "20 is greater than 18"; 7 | } 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ Constructors.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class MyClass { // The class 5 | public: // Access specifier 6 | MyClass() { // Constructor 7 | cout << "Hello World!"; 8 | } 9 | }; 10 | 11 | int main() { 12 | MyClass myObj; // Create an object of MyClass (this will call the constructor) 13 | return 0; 14 | } // Creater By Sanusanth 15 | -------------------------------------------------------------------------------- /C++ Continue.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | for (int i = 0; i < 10; i++) { 6 | if (i == 4) { 7 | continue; 8 | } 9 | cout << i << "\n"; 10 | } 11 | return 0; 12 | } // Creater By Sanusanth 13 | 14 | -------------------------------------------------------------------------------- /C++ Data Types.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main () { 6 | // Creating variables 7 | int myNum = 5; // Integer (whole number) 8 | float myFloatNum = 5.99; // Floating point number 9 | double myDoubleNum = 9.98; // Floating point number 10 | char myLetter = 'D'; // Character 11 | bool myBoolean = true; // Boolean 12 | string myString = "Hello"; // String 13 | 14 | // Print variable values 15 | cout << "int: " << myNum << "\n"; 16 | cout << "float: " << myFloatNum << "\n"; 17 | cout << "double: " << myDoubleNum << "\n"; 18 | cout << "char: " << myLetter << "\n"; 19 | cout << "bool: " << myBoolean << "\n"; 20 | cout << "string: " << myString << "\n"; 21 | 22 | return 0; 23 | } // Creater By Sanusanth 24 | -------------------------------------------------------------------------------- /C++ Default Parameters value.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | void myFunction(string country = "Norway") { 6 | cout << country << "\n"; 7 | } 8 | 9 | int main() { 10 | myFunction("Sweden"); 11 | myFunction("India"); 12 | myFunction(); 13 | myFunction("USA"); 14 | return 0; 15 | } // Creater By Sanusanth 16 | -------------------------------------------------------------------------------- /C++ Dereference.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string food = "Pizza"; // Variable declaration 7 | string* ptr = &food; // Pointer declaration 8 | 9 | // Reference: Output the memory address of food with the pointer 10 | cout << ptr << "\n"; 11 | 12 | // Dereference: Output the value of food with the pointer 13 | cout << *ptr << "\n"; 14 | return 0; 15 | } // Creater By Sanusanth 16 | -------------------------------------------------------------------------------- /C++ DoWhile Loop.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int i = 0; 6 | do { 7 | cout << i << "\n"; 8 | i++; 9 | } 10 | while (i < 5); 11 | return 0; 12 | } // Creater By Sanusanth 13 | -------------------------------------------------------------------------------- /C++ Encapsulation Access Private Members.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Employee { 5 | private: 6 | int salary; 7 | 8 | public: 9 | void setSalary(int s) { 10 | salary = s; 11 | } 12 | int getSalary() { 13 | return salary; 14 | } 15 | }; 16 | 17 | int main() { 18 | Employee myObj; 19 | myObj.setSalary(50000); 20 | cout << myObj.getSalary(); 21 | return 0; 22 | } // Creater By Sanusanth 23 | -------------------------------------------------------------------------------- /C++ Files and read file.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main () { 7 | // Create a text file 8 | ofstream MyWriteFile("filename.txt"); 9 | 10 | // Write to the file 11 | MyWriteFile << "Files can be tricky, but it is fun enough!"; 12 | 13 | // Close the file 14 | MyWriteFile.close(); 15 | 16 | // Create a text string, which is used to output the text file 17 | string myText; 18 | 19 | // Read from the text file 20 | ifstream MyReadFile("filename.txt"); 21 | 22 | // Use a while loop together with the getline() function to read the file line by line 23 | while (getline (MyReadFile, myText)) { 24 | // Output the text from the file 25 | cout << myText; 26 | } 27 | 28 | // Close the file 29 | MyReadFile.close(); 30 | } // Creater By Sanusanth 31 | -------------------------------------------------------------------------------- /C++ For Loop.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | for (int i = 0; i < 5; i++) { 6 | cout << i << "\n"; 7 | } 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ Function Overloading 1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int plusFuncInt(int x, int y) { 5 | return x + y; 6 | } 7 | 8 | double plusFuncDouble(double x, double y) { 9 | return x + y; 10 | } 11 | 12 | int main() { 13 | int myNum1 = plusFuncInt(8, 5); 14 | double myNum2 = plusFuncDouble(4.3, 6.26); 15 | cout << "Int: " << myNum1 << "\n"; 16 | cout << "Double: " << myNum2; 17 | return 0; 18 | } // Creater By Sanusanth 19 | -------------------------------------------------------------------------------- /C++ Function Overloading 2.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int plusFunc(int x, int y) { 5 | return x + y; 6 | } 7 | 8 | double plusFunc(double x, double y) { 9 | return x + y; 10 | } 11 | 12 | int main() { 13 | int myNum1 = plusFunc(8, 5); 14 | double myNum2 = plusFunc(4.3, 6.26); 15 | cout << "Int: " << myNum1 << "\n"; 16 | cout << "Double: " << myNum2; 17 | return 0; 18 | } // Creater By Sanusanth 19 | -------------------------------------------------------------------------------- /C++ Functions - Pass By Reference.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void swapNums(int &x, int &y) { 5 | int z = x; 6 | x = y; 7 | y = z; 8 | } 9 | 10 | int main() { 11 | int firstNum = 10; 12 | int secondNum = 20; 13 | 14 | cout << "Before swap: " << "\n"; 15 | cout << firstNum << secondNum << "\n"; 16 | 17 | swapNums(firstNum, secondNum); 18 | 19 | cout << "After swap: " << "\n"; 20 | cout << firstNum << secondNum << "\n"; 21 | 22 | return 0; 23 | } // Creater By Sanusanth 24 | -------------------------------------------------------------------------------- /C++ How To Add Two Numbers.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x, y; 6 | int sum; 7 | cout << "Type a number: "; 8 | cin >> x; 9 | cout << "Type another number: "; 10 | cin >> y; 11 | sum = x + y; 12 | cout << "Sum is: " << sum; 13 | return 0; 14 | } // Creater By Sanusanth 15 | -------------------------------------------------------------------------------- /C++ Inheritance Access.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Base class 5 | class Employee { 6 | protected: // Protected access specifier 7 | int salary; 8 | }; 9 | 10 | // Derived class 11 | class Programmer: public Employee { 12 | public: 13 | int bonus; 14 | void setSalary(int s) { 15 | salary = s; 16 | } 17 | int getSalary() { 18 | return salary; 19 | } 20 | }; 21 | 22 | int main() { 23 | Programmer myObj; 24 | myObj.setSalary(50000); 25 | myObj.bonus = 15000; 26 | cout << "Salary: " << myObj.getSalary() << "\n"; 27 | cout << "Bonus: " << myObj.bonus << "\n"; 28 | return 0; 29 | } // Creater By Sanusanth 30 | -------------------------------------------------------------------------------- /C++ Inheritance.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | // Base class 6 | class Vehicle { 7 | public: 8 | string brand = "Ford"; 9 | void honk() { 10 | cout << "Tuut, tuut! \n" ; 11 | } 12 | }; 13 | 14 | // Derived class 15 | class Car: public Vehicle { 16 | public: 17 | string model = "Mustang"; 18 | }; 19 | 20 | int main() { 21 | Car myCar; 22 | myCar.honk(); 23 | cout << myCar.brand + " " + myCar.model; 24 | return 0; 25 | } // Creater By Sanusanth 26 | -------------------------------------------------------------------------------- /C++ Logical Operators &&,ll,!.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x = 5; 6 | int y = 3; 7 | cout << (x > 3 && x < 10); // returns true (1) because 5 is greater than 3 AND 5 is less than 10 ( 8 | ll,!) 9 | return 0; 10 | } // Creater By Sanusanth 11 | -------------------------------------------------------------------------------- /C++ Math.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << min(5, 10); 6 | return 0; 7 | } // Creater By Sanusanth 8 | -------------------------------------------------------------------------------- /C++ Memory Address.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string food = "Pizza"; 7 | 8 | cout << &food; 9 | return 0; 10 | } 11 | // Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /C++ Modify Pointers.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string food = "Pizza"; 7 | string* ptr = &food; 8 | 9 | // Output the value of food 10 | cout << food << "\n"; 11 | 12 | // Output the memory address of food 13 | cout << &food << "\n"; 14 | 15 | // Access the memory address of food and output its value 16 | cout << *ptr << "\n"; 17 | 18 | // Change the value of the pointer 19 | *ptr = "Hamburger"; 20 | 21 | // Output the new value of the pointer 22 | cout << *ptr << "\n"; 23 | 24 | // Output the new value of the food variable 25 | cout << food << "\n"; 26 | return 0; 27 | } // Creater By Sanusanth 28 | -------------------------------------------------------------------------------- /C++ Multilevel Inheritance.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Parent class 5 | class MyClass { 6 | public: 7 | void myFunction() { 8 | cout << "Some content in parent class." ; 9 | } 10 | }; 11 | 12 | // Child class 13 | class MyChild: public MyClass { 14 | }; 15 | 16 | // Grandchild class 17 | class MyGrandChild: public MyChild { 18 | }; 19 | 20 | int main() { 21 | MyGrandChild myObj; 22 | myObj.myFunction(); 23 | return 0; 24 | } // Creater By Sanusanth 25 | -------------------------------------------------------------------------------- /C++ Multiple Inheritance.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Base class 5 | class MyClass { 6 | public: 7 | void myFunction() { 8 | cout << "Some content in parent class.\n" ; 9 | } 10 | }; 11 | 12 | // Another base class 13 | class MyOtherClass { 14 | public: 15 | void myOtherFunction() { 16 | cout << "Some content in another class.\n" ; 17 | } 18 | }; 19 | 20 | // Derived class 21 | class MyChildClass: public MyClass, public MyOtherClass { 22 | }; 23 | 24 | int main() { 25 | MyChildClass myObj; 26 | myObj.myFunction(); 27 | myObj.myOtherFunction(); 28 | return 0; 29 | } // Creater By Sanusanth 30 | -------------------------------------------------------------------------------- /C++ Multiple Parameters.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | void myFunction(string fname, int age) { 6 | cout << fname << " Refsnes. " << age << " years old. \n"; 7 | } 8 | 9 | int main() { 10 | myFunction("Liam", 3); 11 | myFunction("Jenny", 14); 12 | myFunction("Anja", 30); 13 | return 0; 14 | } // Creater By Sanusanth 15 | -------------------------------------------------------------------------------- /C++ Numbers and Strings.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main () { 6 | string x = "10"; 7 | string y = "20"; 8 | string z = x + y; 9 | cout << z; 10 | return 0; 11 | } // Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /C++ Omit Array Size.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string cars[5] = {"Volvo", "BMW", "Ford"}; 7 | cars[3] = "Mazda"; 8 | cars[4] = "Tesla"; 9 | for(int i = 0; i < 5; i++) { 10 | cout << cars[i] << "\n"; 11 | } 12 | return 0; 13 | } // Creater By Sanusanth 14 | -------------------------------------------------------------------------------- /C++ Output (Print Text).txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << "Hello World!"; 6 | cout << "I am learning C++"; 7 | return 0; 8 | } // Creater By Sanusanth 9 | -------------------------------------------------------------------------------- /C++ Pointers.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string food = "Pizza"; // A string variable 7 | string* ptr = &food; // A pointer variable that stores the address of food 8 | 9 | // Output the value of food 10 | cout << food << "\n"; 11 | 12 | // Output the memory address of food 13 | cout << &food << "\n"; 14 | 15 | // Output the memory address of food with the pointer 16 | cout << ptr << "\n"; 17 | return 0; 18 | } // Creater By Sanusanth 19 | -------------------------------------------------------------------------------- /C++ Polymorphism.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | // Base class 6 | class Animal { 7 | public: 8 | void animalSound() { 9 | cout << "The animal makes a sound \n" ; 10 | } 11 | }; 12 | 13 | // Derived class 14 | class Pig : public Animal { 15 | public: 16 | void animalSound() { 17 | cout << "The pig says: wee wee \n" ; 18 | } 19 | }; 20 | 21 | // Derived class 22 | class Dog : public Animal { 23 | public: 24 | void animalSound() { 25 | cout << "The dog says: bow wow \n" ; 26 | } 27 | }; 28 | 29 | int main() { 30 | Animal myAnimal; 31 | Pig myPig; 32 | Dog myDog; 33 | 34 | myAnimal.animalSound(); 35 | myPig.animalSound(); 36 | myDog.animalSound(); 37 | return 0; 38 | } // Creater By Sanusanth 39 | -------------------------------------------------------------------------------- /C++ References.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string food = "Pizza"; 7 | string &meal = food; 8 | 9 | cout << food << "\n"; 10 | cout << meal << "\n"; 11 | return 0; 12 | } // Creater By Sanusanth 13 | -------------------------------------------------------------------------------- /C++ Short Hand If Else.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int time = 20; 6 | if (time < 18) { 7 | cout << "Good day."; 8 | } else { 9 | cout << "Good evening."; 10 | } 11 | return 0; 12 | } // Creater By Sanusanth 13 | -------------------------------------------------------------------------------- /C++ String Concatenation.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main () { 6 | string firstName = "sanu "; 7 | string lastName = "santh"; 8 | string fullName = firstName + lastName; 9 | cout << fullName; 10 | return 0; 11 | } // Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /C++ String Data Types.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string greeting = "Hello"; 7 | cout << greeting; 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ String Length.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 7 | cout << "The length of the txt string is: " << txt.size(); 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ String Namespace.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | std::string greeting = "Hello"; 6 | std::cout << greeting; 7 | return 0; 8 | } // Creater By Sanusanth 9 | -------------------------------------------------------------------------------- /C++ Strings.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string greeting = "Hello"; 7 | cout << greeting; 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /C++ Switch Statements.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int day = 4; 6 | switch (day) { 7 | case 1: 8 | cout << "Monday"; 9 | break; 10 | case 2: 11 | cout << "Tuesday"; 12 | break; 13 | case 3: 14 | cout << "Wednesday"; 15 | break; 16 | case 4: 17 | cout << "Thursday"; 18 | break; 19 | case 5: 20 | cout << "Friday"; 21 | break; 22 | case 6: 23 | cout << "Saturday"; 24 | break; 25 | case 7: 26 | cout << "Sunday"; 27 | break; 28 | } 29 | return 0; 30 | } // Creater By Sanusanth 31 | -------------------------------------------------------------------------------- /C++ The Return Keyword 1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int myFunction(int x) { 5 | return 5 + x; 6 | } 7 | 8 | int main() { 9 | cout << myFunction(3); 10 | return 0; 11 | } // Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /C++ The Return Keyword 2.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int myFunction(int x, int y) { 5 | return x + y; 6 | } 7 | 8 | int main() { 9 | cout << myFunction(5, 3); 10 | return 0; 11 | } // Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /C++ The Return Keyword 3.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int myFunction(int x, int y) { 5 | return x + y; 6 | } 7 | 8 | int main() { 9 | int z = myFunction(5, 3); 10 | cout << z; 11 | return 0; 12 | } // Creater By Sanusanth 13 | -------------------------------------------------------------------------------- /C++ User Input Strings.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string fullName; 7 | cout << "Type your full name: "; 8 | getline (cin, fullName); 9 | cout << "Your name is: " << fullName; 10 | return 0; 11 | } // Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /C++ User Input.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x; 6 | cout << "Type a number: "; // Type a number and press enter 7 | cin >> x; // Get user input from the keyboard 8 | cout << "Your number is: " << x; 9 | return 0; 10 | } // creater By Sanusanth 11 | -------------------------------------------------------------------------------- /C++ Variables.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int myNum = 15; 6 | cout << myNum; 7 | return 0; 8 | } // creater By Sanusanth 9 | -------------------------------------------------------------------------------- /C++ While Loop.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int i = 0; 6 | while (i < 5) { 7 | cout << i << "\n"; 8 | i++; 9 | } 10 | return 0; 11 | } // Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /C++ cmath Header.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | cout << sqrt(64) << "\n"; 7 | cout << round(2.6) << "\n"; 8 | cout << log(2) << "\n"; 9 | return 0; 10 | } 11 | // Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /C++Exceptions try and catch.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | try { 6 | int age = 15; 7 | if (age >= 18) { 8 | cout << "Access granted - you are old enough."; 9 | } else { 10 | throw (age); 11 | } 12 | } 13 | catch (int myNum) { 14 | cout << "Access denied - You must be at least 18 years old.\n"; 15 | cout << "Age is: " << myNum; 16 | } 17 | return 0; 18 | }// Creater By Sanusanth 19 | -------------------------------------------------------------------------------- /C++arithmetic Operators.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int sum1 = 100 + 50; // 150 (100 + 50) 6 | int sum2 = sum1 + 250; // 400 (150 + 250) 7 | int sum3 = sum2 + sum2; // 800 (400 + 400) 8 | cout << sum1 << "\n"; 9 | cout << sum2 << "\n"; 10 | cout << sum3; 11 | return 0; 12 | } 13 | // Creater By Sanusanth 14 | -------------------------------------------------------------------------------- /C++variables Identifiers.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Good name 6 | int minutesPerHour = 60; 7 | 8 | // OK, but not so easy to understand what m actually is 9 | int m = 60; 10 | 11 | cout << minutesPerHour << "\n"; 12 | cout << m; 13 | return 0; 14 | } // Creater By Sanusanth 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C-basic-simple-program 2 | What is C++? C++ is a general-purpose, object-oriented programming language. 3 | It was created by Bjarne Stroustrup at Bell Labs circa 1980. 4 | C++ is very similar to C (invented by Dennis Ritchie in the early 1970s). 5 | C++ is so compatible with C that it will probably compile over 99% of C programs without changing a line of source code. 6 | Though C++ is a lot of well-structured and safer language than C as it OOPs based. 7 | Some computer languages are written for a specific purpose. 8 | Like, Java was initially devised to control toasters and some other electronics. 9 | C was developed for programming OS. 10 | Pascal was conceptualized to teach proper programming techniques. 11 | But C++ is a general-purpose language. It well deserves the widely acknowledged nickname "Swiss Pocket Knife of Languages." 12 | C++ is a cross-platform language that can be used to create high-performance applications. 13 | C++ was developed by Bjarne Stroustrup, as an extension to the C language. 14 | C++ gives programmers a high level of control over system resources and memory. 15 | The language was updated 3 major times in 2011, 2014, and 2017 to C++11, C++14, and C++17. 16 | About C++ Programming Multi-paradigm Language - C++ supports at least seven different styles of programming. 17 | Developers can choose any of the styles. General Purpose Language - You can use C++ to develop games, desktop apps, operating systems, and so on. Speed - Like C programming, the performance of optimized C++ code is exceptional. Object-oriented - C++ allows you to divide complex problems into smaller sets by using objects. 18 | 19 | Why Learn C++? 20 | C++ is used to develop games, desktop apps, operating systems, browsers, and so on because of its performance. 21 | After learning C++, it will be much easier to learn other programming languages like Java, Python, etc. C++ helps you to understand the internal architecture of a computer, how computer stores and retrieves information. How to learn C++? C++ tutorial from Programiz - We provide step by step C++ tutorials, examples, and references. Get started with C++. 22 | Official C++ documentation - Might be hard to follow and understand for beginners. Visit official C++ documentation. 23 | Write a lot of C++ programming code- The only way you can learn programming is by writing a lot of code. 24 | Read C++ code- Join Github's open-source projects and read other people's code. C++ best programming language? The answer depends on perspective and requirements. Some tasks can be done in C++, though not very quickly. For example, designing GUI screens for applications. 25 | Other languages like Visual Basic, Python have GUI design elements built into them. Therefore, they are better suited for GUI type of task. Some of the scripting languages that provide extra programmability to applications. Such as MS Word and even photoshop tend to be variants of Basic, not C++. C++ is still used widely, and the most famous software have their backbone in C++. This tutorial will help you learn C++ basic and the advanced concepts. Who uses C++? Some of today's most visible used systems have their critical parts written in C++. Examples are Amadeus (airline ticketing) Bloomberg (financial formation), Amazon (Web commerce), Google (Web search) Facebook (social media) Many programming languages depend on C++'s performance and reliability in their implementation. Examples include: Java Virtual Machines JavaScript interpreters (e.g., Google's V8) Browsers (e.g., Internet Explorer, Mozilla's Firefox, Apple's Safari, and Google's Chrome) Application and Web frameworks (e.g., Microsoft's .NET Web services framework). Applications that involve local and wide area networks, user interaction, numeric, graphics, and database access highly depend on C++ language. 26 | 27 | Why Use C++ 28 | 29 | C++ is one of the world's most popular programming languages. C++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems. C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs. C++ is portable and can be used to develop applications that can be adapted to multiple platforms. C++ is fun and easy to learn! As C++ is close to C# and Java, it makes it easy for programmers to switch to C++ or vice versa Definition - What does C++ Programming Language mean? C++ is an object oriented computer language created by notable computer scientist Bjorne Stroustrop as part of the evolution of the C family of languages. Some call C++ “C with classes” because it introduces object oriented programming principles, including the use of defined classes, to the C programming language framework. C++ is pronounced "see-plus-plus." 30 | 31 | C++ Variables 32 | 33 | Variables are the backbone of any programming language. A variable is merely a way to store some information for later use. We can retrieve this value or data by referring to a "word" that will describe this information. Once declared and defined they may be used many times within the scope in which they were declared. C++ Control Structures When a program runs, the code is read by the compiler line by line (from top to bottom, and for the most part left to right). This is known as "code flow." When the code is being read from top to bottom, it may encounter a point where it needs to make a decision. Based on the decision, the program may jump to a different part of the code. It may even make the compiler re-run a specific piece again, or just skip a bunch of code. You could think of this process like if you were to choose from different courses from Guru99. You decide, click a link and skip a few pages. In the same way, a computer program has a set of strict rules to decide the flow of program execution. 34 | 35 | C++ Syntax 36 | 37 | The syntax is a layout of words, expression, and symbols. 38 | Well, it's because an email address has its well-defined syntax. 39 | You need some combination of letters, numbers, potentially with underscores (_) or periods (.) in between, followed by an at the rate (@) symbol, followed by some website domain (company.com). So, syntax in a programming language is much the same. They are some well-defined set of rules that allow you to create some piece of well-functioning software. But, if you don't abide by the rules of a programming language or syntax, you'll get errors. C++ Tools In the real world, a tool is something (usually a physical object) that helps you to get a certain job done promptly. Well, this holds true with the programming world too. A tool in programming is some piece of software which when used with the code allows you to program faster. There are probably tens of thousands, if not millions of different tools across all the programming languages. Most crucial tool, considered by many, is an IDE, an Integrated Development Environment. An IDE is a software which will make your coding life so much easier. IDEs ensure that your files and folders are organized and give you a nice and clean way to view them. Types of C++ Errors Another way to look at C++ in a practical sense is to start enumerating different kinds of errors that occur as the written code makes its way to final execution. First, there are syntax errors where the code is actually written in an illegible way. This can be a misuse of punctuation, or the misspelling of a function command or anything else that compromises the integrity of the syntax as it is written. Another fundamental type of error is a compiler error that simply tells the programmer the compiler was not able to do its work effectively. As a compiler language, C++ relies on the compiler to make the source code into machine readable code and optimize it in various ways. A third type of error happens after the program has been successfully compiled. Runtime errors are not uncommon in C++ executables. What they represent is some lack of designated resource or non-working command in the executable program. In other words, the syntax is right, and the program was compiled successfully, but as the program is doing its work, it encounters a problem, whether that has to do with interdependencies, operating system requirements or anything else in the general environment in which the program is trying to work. Over time, C++ has remained a very useful language not only in computer programming itself, but in teaching new programmers about how object oriented programming works. 40 | -------------------------------------------------------------------------------- /c++ Access the Elements of an Array.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"}; 7 | cout << cars[0]; 8 | return 0; 9 | } // Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /c++ Add Variables Together.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x = 5; 6 | int y = 6; 7 | int sum = x + y; 8 | cout << sum; 9 | return 0; 10 | } // Creater By Sanusanth 11 | -------------------------------------------------------------------------------- /c++ Break in While Loop.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int i = 0; 6 | while (i < 10) { 7 | cout << i << "\n"; 8 | i++; 9 | if (i == 4) { 10 | break; 11 | } 12 | } 13 | return 0; 14 | } 15 | \\ Creater By Sanusanth 16 | -------------------------------------------------------------------------------- /c++ Call a Function.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void myFunction() { 5 | cout << "I just got executed!\n"; 6 | } 7 | 8 | int main() { 9 | myFunction(); 10 | myFunction(); 11 | myFunction(); 12 | return 0; 13 | } \\ Creater By Sanusanth 14 | -------------------------------------------------------------------------------- /c++ Change an Array Element.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"}; 7 | cars[0] = "Opel"; 8 | cout << cars[0]; 9 | return 0; 10 | } \\ Creater By Sanusanth 11 | -------------------------------------------------------------------------------- /c++ Constructor Parameters 1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Car { // The class 5 | public: // Access specifier 6 | string brand; // Attribute 7 | string model; // Attribute 8 | int year; // Attribute 9 | Car(string x, string y, int z); // Constructor declaration 10 | }; 11 | 12 | // Constructor definition outside the class 13 | Car::Car(string x, string y, int z) { 14 | brand = x; 15 | model = y; 16 | year = z; 17 | } 18 | 19 | int main() { 20 | // Create Car objects and call the constructor with different values 21 | Car carObj1("BMW", "X5", 1999); 22 | Car carObj2("Ford", "Mustang", 1969); 23 | 24 | // Print values 25 | cout << carObj1.brand << " " << carObj1.model << " " << carObj1.year << "\n"; 26 | cout << carObj2.brand << " " << carObj2.model << " " << carObj2.year << "\n"; 27 | return 0; 28 | } \\ Creater By Sanusanth 29 | -------------------------------------------------------------------------------- /c++ Constructor Parameters.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Car { // The class 5 | public: // Access specifier 6 | string brand; // Attribute 7 | string model; // Attribute 8 | int year; // Attribute 9 | Car(string x, string y, int z) { // Constructor with parameters 10 | brand = x; 11 | model = y; 12 | year = z; 13 | } 14 | }; 15 | 16 | int main() { 17 | // Create Car objects and call the constructor with different values 18 | Car carObj1("BMW", "X5", 1999); 19 | Car carObj2("Ford", "Mustang", 1969); 20 | 21 | // Print values 22 | cout << carObj1.brand << " " << carObj1.model << " " << carObj1.year << "\n"; 23 | cout << carObj2.brand << " " << carObj2.model << " " << carObj2.year << "\n"; 24 | return 0; 25 | } \\ Creater By Sanusanth 26 | -------------------------------------------------------------------------------- /c++ Continue in While Loop.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int i = 0; 6 | while (i < 10) { 7 | if (i == 4) { 8 | i++; 9 | continue; 10 | } 11 | cout << i << "\n"; 12 | i++; 13 | } 14 | return 0; 15 | } \\ Creater By Sanusanth 16 | -------------------------------------------------------------------------------- /c++ Creating a Simple Calculator.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x, y; 6 | int sum; 7 | cout << "Type a number: "; 8 | cin >> x; 9 | cout << "Type another number: "; 10 | cin >> y; 11 | sum = x + y; 12 | cout << "Sum is: " << sum; 13 | return 0; 14 | } \\ Creater By Sanusanth 15 | -------------------------------------------------------------------------------- /c++ Declare Many Variables.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x = 5, y = 6, z = 50; 6 | cout << x + y + z; 7 | return 0; 8 | } \\ Creater By Sanusanth 9 | -------------------------------------------------------------------------------- /c++ Handle Any Type of Exceptions (...).txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | try { 6 | int age = 15; 7 | if (age >= 18) { 8 | cout << "Access granted - you are old enough."; 9 | } else { 10 | throw 505; 11 | } 12 | } 13 | catch (...) { 14 | cout << "Access denied - You must be at least 18 years old.\n"; 15 | } 16 | return 0; 17 | } \\ Creater By Sanusanth 18 | -------------------------------------------------------------------------------- /c++ Loop Through an Array 1 count.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"}; 7 | for(int i = 0; i < 4; i++) { 8 | cout << i << ": " << cars[i] << "\n"; 9 | } 10 | return 0; 11 | } \\ Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /c++ Loop Through an Array.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"}; 7 | for(int i = 0; i < 4; i++) { 8 | cout << cars[i] << "\n"; 9 | } 10 | return 0; 11 | } \\ Creater By Sanusanth 12 | -------------------------------------------------------------------------------- /c++ Numeric Types (double).txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main () { 5 | double myNum = 19.99; 6 | cout << myNum; 7 | return 0; 8 | } \\ Creater By Sanusanth 9 | -------------------------------------------------------------------------------- /c++ Numeric Types (float).txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main () { 5 | float myNum = 5.75; 6 | cout << myNum; 7 | return 0; 8 | } \\ Creater By Sanusanth 9 | -------------------------------------------------------------------------------- /c++ Numeric Types (int).txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main () { 5 | int myNum = 1000; 6 | cout << myNum; 7 | return 0; 8 | } 9 | \\ Creater By Sanusanth 10 | -------------------------------------------------------------------------------- /c++ Omit Elements on Declaration.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string cars[5]; 7 | cars[0] = "Volvo"; 8 | cars[1] = "BMW"; 9 | cars[2] = "Ford"; 10 | cars[3] = "Mazda"; 11 | cars[4] = "Tesla"; 12 | for(int i = 0; i < 5; i++) { 13 | cout << cars[i] << "\n"; 14 | } 15 | return 0; 16 | } \\ Creater By Sanusanth 17 | -------------------------------------------------------------------------------- /c++ Omitting Namespace.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | std::cout << "Hello World!"; 5 | return 0; 6 | } \\ Creater By Sanusanth 7 | -------------------------------------------------------------------------------- /c++ The else Statement.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int time = 20; 6 | if (time < 18) { 7 | cout << "Good day."; 8 | } else { 9 | cout << "Good evening."; 10 | } 11 | return 0; 12 | } 13 | \\ Creater By Sanusanth 14 | -------------------------------------------------------------------------------- /c++ The else if Statement.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int time = 22; 6 | if (time < 10) { 7 | cout << "Good morning."; 8 | } else if (time < 20) { 9 | cout << "Good day."; 10 | } else { 11 | cout << "Good evening."; 12 | } 13 | return 0; 14 | } \\ Creater By Sanusanth 15 | -------------------------------------------------------------------------------- /c++ function Parameters and Arguments.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | void myFunction(string fname) { 6 | cout << fname << " Refsnes\n"; 7 | } 8 | 9 | int main() { 10 | myFunction("Liam"); 11 | myFunction("Jenny"); 12 | myFunction("Anja"); 13 | return 0; 14 | } 15 | \\ Creater By Sanusanth 16 | -------------------------------------------------------------------------------- /c++ hellow world.txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << "Hello World!"; 6 | return 0; 7 | } \\ Creater By Sanusanth 8 | -------------------------------------------------------------------------------- /c++ output (print text next endl).txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << "Hello World!" << endl; 6 | cout << "I am learning C++"; 7 | return 0; 8 | } \\ Creater By Sanusanth 9 | -------------------------------------------------------------------------------- /c++ output (print text next line).txt: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << "Hello World! \n"; 6 | cout << "I am learning C++"; 7 | return 0; 8 | } \\ Creater By Sanusanth 9 | --------------------------------------------------------------------------------