{"id":21260501,"url":"https://github.com/tanmayvaij/cpp-syntax","last_synced_at":"2025-10-26T17:03:22.206Z","repository":{"id":153628631,"uuid":"539922660","full_name":"tanmayvaij/cpp-syntax","owner":"tanmayvaij","description":"Overview of the syntax of C++ language ","archived":false,"fork":false,"pushed_at":"2022-09-25T17:05:25.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T21:47:43.585Z","etag":null,"topics":["c-plus-plus","cpp","cpp17","syntax"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tanmayvaij.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-22T10:24:04.000Z","updated_at":"2022-10-20T05:03:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"ff2f0aae-17fa-4ab3-9bb7-da7507b4a35d","html_url":"https://github.com/tanmayvaij/cpp-syntax","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanmayvaij%2Fcpp-syntax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanmayvaij%2Fcpp-syntax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanmayvaij%2Fcpp-syntax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanmayvaij%2Fcpp-syntax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanmayvaij","download_url":"https://codeload.github.com/tanmayvaij/cpp-syntax/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243695537,"owners_count":20332626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","cpp","cpp17","syntax"],"created_at":"2024-11-21T04:19:14.330Z","updated_at":"2025-10-26T17:03:17.168Z","avatar_url":"https://github.com/tanmayvaij.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ Synax\n\n### 1. Hello World\n```cpp\n#include \u003ciostream\u003e\nusing namespace std;\n\nint main () {\n\n    cout \u003c\u003c \"Hello World\";\n\n    return 0;\n\n}\n```\n\u003cbr/\u003e\n\n### 2. Data Types\n\n\n// Sample script - script_02.cpp\n\n| Data Type | Size |\n|-----------|------|\n| int | 4 bytes |\n| float | 4 bytes |\n| char | 1 byte |\n| bool | 1 byte |\n| short int | 2 bytes |\n| long int | 8 bytes |\n| long long int | 8 bytes |\n| double | 8 bytes |\n| long double | 16 bytes |\n\n\u003cbr/\u003e\n\n### 3. Taking user Input\n\n```cpp\n// script_03.cpp\n#include \u003ciostream\u003e\nusing namespace std;\n\nint main () {\n\n    int n;\n    cin \u003e\u003e n;\n    cout \u003c\u003c \"Entered number is:- \" \u003c\u003c n \u003c\u003c endl;\n\n    return 0;\n\n}\n```\n\u003cbr/\u003e\n\n### 4. Conditional Statements\n\n```cpp\n// Sample script - script_04.cpp\n\nif (/*condition*/) {\n    // code\n}\nelse if (/*condition*/) {\n    // code\n}\nelse {\n    // code\n}\n\n// Ternary Operator\n\n/* Condition */ ? : /* Expression 1 */ : /* Expression 2 */;\n```\n\u003cbr/\u003e\n\n### 5. Loops\n\n```cpp\n// Sample script - script_05.cpp\n\n// 1. for loop\n\nfor ( /* Initialize */; /*Condition*/ ; /* Counter */ ) {\n    // code\n}\n\n// 2. while loop\n\nwhile ( /*condition*/ ) {\n    // code\n}\n\n// 3. do while loop\n\ndo {\n    // code\n}\nwhile ( /*condition*/ );\n```\n\u003cbr/\u003e\n\n### 6. Break and Continue\n\n```cpp\n// Sample script - script_06.cpp\n\n#include \u003ciostream\u003e\nusing namespace std;\n\nint main () {\n\n    for ( int i = 0; i \u003c 10; i++ ) {\n        if ( i == 2 ) {\n            continue;\n        }\n        else if ( i == 6 ) {\n            break;\n        }\n        else {\n            cout \u003c\u003c i \u003c\u003c endl;\n        }\n    }\n\n    return 0;\n\n}\n\n/*\nOutput:-\n0\n1\n3\n4\n5\n*/\n```\n\u003cbr/\u003e\n\n### 7. Switch - Case\n\n```cpp\n// Sample script - script_07.cpp \n\nswitch ( /* expression */ ) {\n\n    case /*value*/:\n        // code\n        break;\n\n    /*\n        cases\n    */\n\n    default:\n        // code\n        break;\n}\n\n```\n\u003cbr/\u003e\n\n### 8. Operators in C++\n\u003cbr/\u003e\n\n\u003e Assignment Operators\n\n| Operator | Description |\n| -------- | ----------- |\n| + | Adds two operands |\n| - | Subtracts second operand from the first |\n| * | Multiplies both operands |\n| / | Divides numerator by de-numerator |\n| % | Modulus Operator and remainder of after an integer division |\n| ++ | Increment operator, increases integer value by one |\n| -- | Decrement operator, decreases integer value by one |\n\n\u003cbr/\u003e\n\n\u003e Relational Operators\n\n| Operator | Description |\n| -------- | ----------- |\n| == | Checks if the values of two operands are equal or not, if yes then condition becomes true. |\n| != | Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. |\n| \u003e | Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. |\n| \u003c | Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. |\n| \u003e= | Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true |\n| \u003c= | Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. |\n\n\u003cbr/\u003e\n\n\u003e Logical Operators\n\n| Operator | Description |\n| -------- | ----------- |\n| \u0026\u0026 | Called Logical AND operator. If both the operands are non-zero, then condition becomes true. |\n| \u0026#124;\u0026#124; | Called Logical OR Operator. If any of the two operands is non-zero, then condition becomes true. |\n| ! | Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true, then Logical NOT operator will make false. |\n\n\u003cbr/\u003e\n\n\u003e Bitwise Operators\n\n| Operator | Description |\n| -------- | ----------- |\n| \u0026 | Binary AND Operator copies a bit to the result if it exists in both operands. |\n| \u0026#124; | Binary OR Operator copies a bit if it exists in either operand. |\n| ^ | Binary XOR Operator copies the bit if it is set in one operand but not both. |\n| ~ | Binary Ones Complement Operator is unary and has the effect of 'flipping' bits. |\n| \u003c\u003c | Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. |\n| \u003e\u003e | Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. |\n\n\u003cbr/\u003e\n\n\u003e Assignment Operators\n\n| Operator | Description |\n| -------- | ----------- |\n| = | Simple assignment operator, Assigns values from right side operands to left side operand. |\n| += | Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand. |\n| -= | Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand. |\n| *= | Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operand. |\n| /= | Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand. |\n| %= | Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operand. |\n| \u003c\u003c= | Left shift AND assignment operator. |\n| \u003e\u003e= | Right shift AND assignment operator. |\n| \u0026= | Bitwise AND assignment operator. |\n| ^= | Bitwise exclusive OR and assignment operator. |\n| \u0026#124;= | Bitwise inclusive OR and assignment operator. |\n\n\u003cbr/\u003e\n\n### 9. Comments in C++\n\n```cpp\n// Single Line Comment\n\n/*\n    This is a \n    multiline comment\n*/\n```\n\n### 10. Functions\n\n```cpp\n// Sample script:- script_08.cpp\n\nreturnType functionName(parameter1, parameter2, ...) {\n    // function body\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanmayvaij%2Fcpp-syntax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanmayvaij%2Fcpp-syntax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanmayvaij%2Fcpp-syntax/lists"}