├── coverage ├── network_concepts │ └── README.md ├── database_concepts │ └── README.md ├── file_access_methods │ └── README.md ├── system_development_life_cycle │ └── README.md ├── object_oriented_programming_concepts │ └── README.md ├── README.md ├── data_structure │ └── README.md └── program_simulation │ └── README.md ├── cpp ├── ccp ├── samplecodes ├── loops.cpp ├── arrays.cpp ├── ccp.cpp ├── samplecodes.cpp └── README.md ├── .vscode └── settings.json └── README.md /coverage/network_concepts/README.md: -------------------------------------------------------------------------------- 1 | # Network Concepts 2 | -------------------------------------------------------------------------------- /coverage/database_concepts/README.md: -------------------------------------------------------------------------------- 1 | # Database Concepts 2 | -------------------------------------------------------------------------------- /coverage/file_access_methods/README.md: -------------------------------------------------------------------------------- 1 | # File Access Methods 2 | -------------------------------------------------------------------------------- /coverage/system_development_life_cycle/README.md: -------------------------------------------------------------------------------- 1 | # System Development Life Cycle 2 | -------------------------------------------------------------------------------- /coverage/object_oriented_programming_concepts/README.md: -------------------------------------------------------------------------------- 1 | # Object Oriented Programming Concepts 2 | -------------------------------------------------------------------------------- /cpp/ccp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/condinoaljoseph/ict-specialist-proficiency-notes/HEAD/cpp/ccp -------------------------------------------------------------------------------- /cpp/samplecodes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/condinoaljoseph/ict-specialist-proficiency-notes/HEAD/cpp/samplecodes -------------------------------------------------------------------------------- /coverage/README.md: -------------------------------------------------------------------------------- 1 | # Exam Coverage 2 | 3 | - Data Structure 4 | - Database Concepts 5 | - File Access Methods 6 | - Network Concepts 7 | - Object Oriented Programming Concepts 8 | - Program Simulation 9 | - Sytem Development Life Cycle 10 | -------------------------------------------------------------------------------- /coverage/data_structure/README.md: -------------------------------------------------------------------------------- 1 | # Data Structure 2 | 3 | ## Arrays 4 | 5 | ### Sorting Arrays 6 | 7 | ```c 8 | #include 9 | 10 | void printArr(int arr[], int l) { 11 | for(int i = 0; i<=l - 1; i++) { 12 | printf("%d\n", arr[i]); 13 | } 14 | } 15 | 16 | int main() { 17 | int arr[5] = {32, 23, 3, 12, 43}; 18 | int arr_count; 19 | 20 | arr_count = sizeof(arr) / sizeof(arr[0]); 21 | 22 | for (int i = 0; i < arr_count; i++) { 23 | for (int j = 0; j < arr_count; j++) { 24 | if (arr[j] > arr[j + 1]) { 25 | int temp = arr[j]; 26 | arr[j] = arr[j+1]; 27 | arr[j+1] = temp; 28 | } 29 | } 30 | } 31 | 32 | printArr(arr, arr_count); 33 | 34 | return 0; 35 | } 36 | ``` 37 | 38 | ### Loop with Array 39 | 40 | ```c 41 | #include 42 | 43 | int main() { 44 | int marks[5]; 45 | int n; 46 | int sum = 0; 47 | int average; 48 | 49 | printf("enter: "); 50 | scanf("%d", &n); 51 | 52 | if (n > 5) { 53 | printf("must not greater than 5"); 54 | return 0; 55 | } 56 | 57 | for (int i=0; i 4 | 5 | int main () { 6 | int range; 7 | 8 | std::cout << "number here: "; 9 | std::cin >> range; 10 | 11 | for (int i = 1; i <= range; i++) 12 | { 13 | for (int j = 1; j<=i; j++) 14 | { 15 | if (j == 1 || j == i || i == range) 16 | { 17 | std::cout << "+"; 18 | } 19 | else 20 | { 21 | std::cout << "-"; 22 | } 23 | } 24 | std::cout << "\n"; 25 | } 26 | 27 | return 0; 28 | } 29 | 30 | 31 | // Box pattern 32 | #include 33 | 34 | int main() { 35 | int x; 36 | std::cout << "box number: "; 37 | std::cin >> x; 38 | 39 | // algo 40 | for (int i = 1; i<=x; i++) { 41 | for (int j = 1; j<=x; j++) { 42 | std::cout << "*"; 43 | } 44 | std::cout << "\n"; 45 | } 46 | 47 | return 0; 48 | } 49 | 50 | 51 | // ++++++++++ 52 | // + + 53 | // + + 54 | // + + 55 | // + + 56 | // + + 57 | // + + 58 | // + + 59 | // + + 60 | // ++++++++++ 61 | 62 | #include 63 | 64 | int main() { 65 | int range = 10; 66 | 67 | for (int i = 1; i<=range; i++) { 68 | for (int j = 1; j<=range; j++) { 69 | if (j == 1 || j == range || i == 1 || i == range) { 70 | std::cout << "+"; 71 | } else { 72 | std::cout << " "; 73 | } 74 | } 75 | std::cout << "\n"; 76 | } 77 | } -------------------------------------------------------------------------------- /cpp/arrays.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #include 5 | using std::setw; 6 | 7 | int main () { 8 | 9 | int n[ 5 ] = {54, 3, 4, 9, 7}; 10 | 11 | for(int i = 0; i < 5; i++){ 12 | std::cout << n[i] << "\n"; 13 | } 14 | 15 | return 0; 16 | } 17 | 18 | 19 | #include 20 | 21 | #include 22 | using std::setw; 23 | 24 | void cout (int arr[], int l) 25 | { 26 | for (int i = 0; i<=l - 1; i++){ 27 | std::cout << "%d\n" << arr[i]; 28 | } 29 | }; 30 | int main(){ 31 | int arr[5] = {32, 23, 3, 12, 43}; 32 | int arr_count; 33 | 34 | arr_count = sizeof(arr) / sizeof(arr[0]); 35 | 36 | for (int i = 0; i < arr_count; i++) 37 | { 38 | for (int j = 0; j < arr_count; j++) 39 | { 40 | if (arr[j] > arr[j + 1]) 41 | { 42 | int temp = arr[j]; 43 | arr[j] = arr[j+1]; 44 | arr[j+1] = temp; 45 | } 46 | } 47 | } 48 | 49 | std::cout << arr << arr_count; 50 | return 0; 51 | } 52 | 53 | 54 | 55 | // LOOP WITH ARRAY |DONE| 56 | #include 57 | 58 | int main() { 59 | int marks[5]; 60 | int n; 61 | int sum = 0; 62 | int average; 63 | 64 | std::cout << "enter: "; 65 | std::cin >> n; 66 | 67 | if (n > 5){ 68 | std::cout << "must not greater than 5"; 69 | return 0; 70 | } 71 | 72 | for (int i = 0; i < n; i++){ 73 | std::cin >> marks[i]; 74 | 75 | sum += marks[i]; 76 | } 77 | 78 | average = sum / n; 79 | std::cout << "average: " << average; 80 | 81 | return 0; 82 | } -------------------------------------------------------------------------------- /cpp/ccp.cpp: -------------------------------------------------------------------------------- 1 | // #include 2 | // using namespace std; 3 | 4 | // #include 5 | // using std::setw; 6 | 7 | // int main () { 8 | 9 | // int n[ 5 ] = {54, 3, 4, 9, 7}; 10 | 11 | // for(int i = 0; i < 5; i++){ 12 | // std::cout << n[i] << "\n"; 13 | // } 14 | 15 | // return 0; 16 | // } 17 | 18 | // //NOT YET CONVERTED TO CPP |SORTING ARRAYS| 19 | // #include 20 | 21 | // #include 22 | // using std::setw; 23 | 24 | // void cout (int arr[], int l) 25 | // { 26 | // for (int i = 0; i<=l - 1; i++){ 27 | // std::cout << "%d\n" << arr[i]; 28 | // } 29 | // }; 30 | // int main(){ 31 | // int arr[5] = {32, 23, 3, 12, 43}; 32 | // int arr_count; 33 | 34 | // arr_count = sizeof(arr) / sizeof(arr[0]); 35 | 36 | // for (int i = 0; i < arr_count; i++) 37 | // { 38 | // for (int j = 0; j < arr_count; j++) 39 | // { 40 | // if (arr[j] > arr[j + 1]) 41 | // { 42 | // int temp = arr[j]; 43 | // arr[j] = arr[j+1]; 44 | // arr[j+1] = temp; 45 | // } 46 | // } 47 | // } 48 | 49 | // std::cout << arr << arr_count; 50 | // return 0; 51 | // } 52 | 53 | 54 | 55 | // LOOP WITH ARRAY |DONE| 56 | #include 57 | #include 58 | 59 | int main() { 60 | int marks[5]; 61 | int n; 62 | int sum = 0; 63 | int average; 64 | 65 | std::cout << "enter: "; 66 | std::cin >> n; 67 | 68 | if (n > 5){ 69 | std::cout << "must not greater than 5"; 70 | return 0; 71 | } 72 | 73 | for (int i = 0; i < n; i++){ 74 | std::cin >> marks[i]; 75 | 76 | sum += marks[i]; 77 | } 78 | 79 | average = sum / n; 80 | std::cout << "average: " << average; 81 | 82 | return 0; 83 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "iostream": "cpp", 4 | "iomanip": "cpp", 5 | "__bit_reference": "cpp", 6 | "__config": "cpp", 7 | "__debug": "cpp", 8 | "__errc": "cpp", 9 | "__functional_base": "cpp", 10 | "__hash_table": "cpp", 11 | "__locale": "cpp", 12 | "__mutex_base": "cpp", 13 | "__node_handle": "cpp", 14 | "__nullptr": "cpp", 15 | "__split_buffer": "cpp", 16 | "__string": "cpp", 17 | "__threading_support": "cpp", 18 | "__tuple": "cpp", 19 | "algorithm": "cpp", 20 | "array": "cpp", 21 | "atomic": "cpp", 22 | "bit": "cpp", 23 | "bitset": "cpp", 24 | "cctype": "cpp", 25 | "chrono": "cpp", 26 | "cmath": "cpp", 27 | "complex": "cpp", 28 | "cstdarg": "cpp", 29 | "cstddef": "cpp", 30 | "cstdint": "cpp", 31 | "cstdio": "cpp", 32 | "cstdlib": "cpp", 33 | "cstring": "cpp", 34 | "ctime": "cpp", 35 | "cwchar": "cpp", 36 | "cwctype": "cpp", 37 | "exception": "cpp", 38 | "functional": "cpp", 39 | "initializer_list": "cpp", 40 | "ios": "cpp", 41 | "iosfwd": "cpp", 42 | "istream": "cpp", 43 | "iterator": "cpp", 44 | "limits": "cpp", 45 | "locale": "cpp", 46 | "memory": "cpp", 47 | "mutex": "cpp", 48 | "new": "cpp", 49 | "optional": "cpp", 50 | "ostream": "cpp", 51 | "ratio": "cpp", 52 | "sstream": "cpp", 53 | "stdexcept": "cpp", 54 | "streambuf": "cpp", 55 | "string": "cpp", 56 | "string_view": "cpp", 57 | "system_error": "cpp", 58 | "tuple": "cpp", 59 | "type_traits": "cpp", 60 | "typeinfo": "cpp", 61 | "unordered_map": "cpp", 62 | "utility": "cpp", 63 | "vector": "cpp" 64 | } 65 | } -------------------------------------------------------------------------------- /cpp/samplecodes.cpp: -------------------------------------------------------------------------------- 1 | /* Takes a year as input. 2 | Checks to see if the year is a four-digit number. 3 | Displays whether or not the year falls on a leap year. 4 | */ 5 | #include 6 | 7 | int main() { 8 | int y = 0; 9 | 10 | std::cout << "Enter year: "; 11 | std::cin >> y; 12 | 13 | if (y < 1000 || y > 9999) { 14 | 15 | std::cout << "Invalid entry.\n"; 16 | 17 | } 18 | else if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) { 19 | 20 | std::cout << y; 21 | std::cout << " falls on a leap year.\n"; 22 | 23 | } 24 | else { 25 | std::cout << y; 26 | std::cout << " is not a leap year.\n"; 27 | 28 | } 29 | 30 | } 31 | 32 | 33 | 34 | /* 35 | calculate and print a simple list of squares of each numbers. 36 | */ 37 | 38 | #include 39 | 40 | int main() { 41 | 42 | int i = 0; 43 | int square = 0; 44 | 45 | // Write a while loop here: 46 | while (i < 10){ 47 | square = i * i; 48 | std::cout << i << " " << square << "\n"; 49 | i++; 50 | } 51 | 52 | } 53 | 54 | 55 | 56 | /* 57 | Let's the user inputs a number and guess from 1-10 58 | till they guess the right answer which is 8! Use a while loop 59 | to do the program, so they can guess up to 50 times. 60 | */ 61 | #include 62 | 63 | int main() { 64 | 65 | int guess; 66 | 67 | int tries = 0; 68 | 69 | std::cout << "I have a number 1-10.\n"; 70 | std::cout << "Please guess it: "; 71 | std::cin >> guess; 72 | 73 | // Write a while loop here: 74 | 75 | while (guess != 8 && tries < 50) { 76 | std::cout << "Wrong guess, try again: "; 77 | std::cin >> guess; 78 | 79 | tries++; 80 | } 81 | 82 | if (guess == 8) { 83 | 84 | std::cout << "You got it!\n"; 85 | 86 | } 87 | 88 | } 89 | 90 | 91 | 92 | /* 93 | Create a program that prints ther verses of the "99 Bottles" song, 94 | using decrementing for loop. 95 | */ 96 | #include 97 | 98 | int main() { 99 | 100 | // Write a for loop here: 101 | for (int i = 99; i > 0; i--){ 102 | std::cout << i << " bottles of pop on the wall.\n" ; 103 | std::cout << "Take one down and pass it around.\n" ; 104 | std::cout << i - 1 <<" bottles of pop on the wall.\n \n"; 105 | } 106 | 107 | } 108 | 109 | 110 | /* 111 | Let's the user input a number then add the all the numbers. 112 | */ 113 | #include 114 | 115 | int main() { 116 | 117 | int num = 0; 118 | int sum = 0; 119 | 120 | std::cout << "Enter a number: "; 121 | std::cin >> num; 122 | 123 | for (int i = 1; i <= num; i++) { 124 | 125 | sum = sum + i; 126 | std::cout << i << " "; 127 | 128 | } 129 | 130 | std::cout << "Sum: " << sum << "\n"; 131 | 132 | } -------------------------------------------------------------------------------- /coverage/program_simulation/README.md: -------------------------------------------------------------------------------- 1 | # Program Simulation 2 | 3 | ## Conditional Statement 4 | 5 | ```c 6 | #include 7 | 8 | int main() { 9 | int year; 10 | 11 | printf("enter year: "); 12 | scanf("%d", &year); 13 | 14 | if (year % 4 == 0) { 15 | printf("yes"); 16 | } else { 17 | printf("no"); 18 | } 19 | 20 | return 0; 21 | } 22 | 23 | ``` 24 | 25 | ## Loops 26 | 27 | ### Sample 1 28 | 29 | ```c 30 | // + 31 | // ++ 32 | // +-+ 33 | // +--+ 34 | // +---+ 35 | // +----+ 36 | 37 | #include 38 | 39 | int main () { 40 | int range; 41 | 42 | printf("number here: "); 43 | scanf("%d", &range); 44 | 45 | for (int i = 1; i<=range; i++) { 46 | for (int j = 1; j<=i; j++) { 47 | if (j == 1 || j == i || i == range) { 48 | printf("+"); 49 | } else { 50 | printf("-"); 51 | } 52 | } 53 | printf("\n"); 54 | } 55 | 56 | return 0; 57 | } 58 | ``` 59 | 60 | ### Sample 2 61 | 62 | ```c 63 | #include 64 | 65 | int main() { 66 | int x; 67 | printf("box number: "); 68 | scanf("%d", &x); 69 | 70 | // algo 71 | for (int i = 1; i<=x; i++) { 72 | for (int j = 1; j<=x; j++) { 73 | printf("*"); 74 | } 75 | printf("\n"); 76 | } 77 | 78 | return 0; 79 | } 80 | 81 | ``` 82 | 83 | ### Sample 3 84 | 85 | ```c 86 | // ++++++++++ 87 | // + + 88 | // + + 89 | // + + 90 | // + + 91 | // + + 92 | // + + 93 | // + + 94 | // + + 95 | // ++++++++++ 96 | 97 | #include 98 | 99 | int main() { 100 | int range = 10; 101 | 102 | for (int i = 1; i<=range; i++) { 103 | for (int j = 1; j<=range; j++) { 104 | if (j == 1 || j == range || i == 1 || i == range) { 105 | printf("+"); 106 | } else { 107 | printf(" "); 108 | } 109 | } 110 | printf("\n"); 111 | } 112 | } 113 | ``` 114 | 115 | ### Sample 4 116 | 117 | ```c 118 | #include 119 | 120 | int main() { 121 | int time, hr, min; 122 | 123 | printf("enter time in 24hr format: \n"); 124 | scanf("%d", &time); 125 | 126 | min = time % 100; 127 | hr = (time - min) / 100; 128 | 129 | if (hr > 12) { 130 | printf("%d:%.2d PM", hr - 12, min); 131 | } else { 132 | printf("%d:%.2d AM", hr, min); 133 | } 134 | 135 | return 0; 136 | } 137 | ``` 138 | 139 | ### Sample 5 140 | 141 | ```c 142 | #include 143 | int main() 144 | { 145 | int a[10], b[10], c[10], i, j, k=0, x, count; 146 | printf("Enter 10 elements for array A: "); 147 | for(i=0; i<10; i++) 148 | { 149 | scanf("%d", &a[i]); 150 | } 151 | printf("Enter 10 elements for array B: "); 152 | for(i=0; i<10; i++) 153 | { 154 | scanf("%d", &b[i]); 155 | } 156 | for(i=0; i<10; i++) 157 | { 158 | for(j=0; j<10; j++) 159 | { 160 | if(a[i]==b[j]) 161 | { 162 | count = 0; 163 | for(x=0; x **Source**: [https://dict.gov.ph/wp-content/uploads/2017/05/2017-ICT-Specialist-Proficiency-Examination-FAQ.pdf](https://dict.gov.ph/wp-content/uploads/2017/05/2017-ICT-Specialist-Proficiency-Examination-FAQ.pdf). I will update this readme when DICT release they're new pdf version. 10 | 11 | ### What is the ICT Specialist Proficiency Examination? 12 | 13 | The ICT Specialist Proficiency Examination is designed to evaluate the competence of an individual to perform programming or systems analysis and design functions. This is pursuant to PD 1408, which directs the National Computer Center (NCC) and the Civil Service Commission (CSC) to devise ways of determining the fitness of individuals in occupying highly technical ICT positions and through which the awarding of appropriate ICT (EDP) Specialist Eligibility will be based. NCC and CSC therefore conduct tests in the area of Computer Programming. 14 | 15 | ### What Civil Service Eligibility will be granted to successful examinees? 16 | 17 | The EDP Specialist Eligibility (EDPSE) shall be conferred to passers of the proficiency test, or passers of the training courses conducted by the Department of Information and Communications Technology (DICT), through the National ICT Competency Management Service (NCM), on courses on Systems Analysis and Design and Computer Programming _(granted pursuant to CSC Resolution No. 90-083 dated January 22, 1990)_. 18 | 19 | ### What positions can the earned eligibility be applied to? 20 | 21 | The EDPSE shall be considered appropriate only to functionally related positions belonging to the Information Technology/Management Information System Group, such as Data Encoder, Data Machine Operator, Auxiliary Machine Operator, Data Encoder-Controller, Computer Programmer, Information Systems Analyst, and to other positions as may be determined by the CSC. _(Provided under Item No. 8, Part V of CSC MC No. 12, s. 2003 re: Revised Policies on Qualification Standards)_. 22 | 23 | ### What are the benefits of the examination? 24 | 25 | The examination can be used: 26 | 27 | - by supervisors to evaluate competence of current or would-be programmers and systems analysts; 28 | - by an individual to assess his/her knowledge and skills for the purpose of continually improving his/her own technical abilities; and 29 | - by ICT training centers to enrich their curricula to enable their students to have a better chance of joining the corps of competent ICT professionals. 30 | 31 | ### Who can take the examination? 32 | 33 | To qualify, an applicant must be a Filipino citizen and a bachelor's degree holder or will graduate before the exam date (as certified by the Dean of the school) and must have undergone formal training in a college or training institution in the area of Programming. 34 | 35 | ### How does one apply? 36 | 37 | Application forms may be filed personally at the NCM Registrar's Office, 2/F, DICT Bldg., C.P. Garcia Ave., U.P. Diliman, Quezon City; or may be communicated through email at ncm.registrar@dict.gov.ph. 38 | 39 | ### What documents should be submitted? 40 | 41 | All duly accomplished application forms must be filed together with the following: 42 | 43 | - Two (2) passport-sized pictures with name tag; 44 | - Certified true copies of Transcript of Records duly authenticated by the Registrar of the school or the HRD Manager of the Office; 45 | - For those graduating before the examination date, a certification from the Dean that the applicant: 46 | - is a candidate for graduation before the exam date; and 47 | - has taken relevant ICT subjects in college; 48 | - Photocopy of NSO birth certificate 49 | 50 | ### How is the examination administered? 51 | 52 | Starting 2nd quarter of 2017, the certification process of Assess-Build-Certify will be implemented: 53 | 54 | **Assess**. All prospective examinees will be assessed by an authorized DICT representative for free. The tool, which the Competency Standards and Certification Management (CSCM) Division will design, will be a written examination that will assess the examinees' knowledge in Programming. It consists of questions on program simulation, number system, data structures, system development life cycle, basic Object-Oriented Programming concepts, basic Networking concepts, file access methods, and basic database concepts. The score attained from this assessment forms 30% of the total score of the examinee should he/she passes the assessment and takes the hands-on examination. Passing score for the Assessment is 25 55 | 56 | **Build**. Those who will not pass the assessment may have to undergo additional hours of training and/or learning activities that will enhance the examinee's knowledge and skills in Programming. It is strongly recommended that universities use the Programming curriculum of DICT or have their own curriculum accredited by the Department through its National ICT Competency Management Service. 57 | 58 | **Certify**. Those who pass the assessment will be eligible to take the ICT Proficiency Examination, which will be administered by an authorized CSCM staff. This hands-on examination is a 6-hour simple application development using the examinee's preferred language. Passing score for this exam is 70. 59 | 60 | An examinee who gets a rating of 80% or higher will be conferred with DICT's Certificate of Proficiency, which is the basis of CSC's conferment of the EDP (ICT) Specialist Eligibility. 61 | 62 | ### What languages can be used in the hands-on examination? 63 | 64 | Examinees may use any of the following programming languages: 65 | 66 | - C Language or C# 67 | - C++ 68 | - Java 69 | - Visual Basic 70 | 71 | ### How much is the examination fee? 72 | 73 | Only successful passers of the Diagnostic Exam will be charged with the examination fee of Five Hundred Pesos (P500.00) for professionals and Three Hundred Pesos (P300.00) for graduating students. 74 | 75 | ### When will the result of the examination be released? 76 | 77 | The result of the examination will be sent to the examinees via e-mail, six weeks from the date of the examination. 78 | 79 | ### Where is the examination center? 80 | 81 | The examination center is at the Department of Information & Communications Technology, C.P. Garcia Avenue, U.P., Diliman, Quezon City. 82 | -------------------------------------------------------------------------------- /cpp/README.md: -------------------------------------------------------------------------------- 1 | **`About C++`** 2 | - from human-readable form transform into machine language 3 | - a strongly typed language 4 | 5 | --------------------- 6 | **BASIC INPUT /OUTPUT** 7 | 8 | `C++` uses a convenient abstraction called `streams` to perform input and output operations in sequential media such as the screen, the keyboard or a file. A `stream` is an entity where a program can either insert or extract characters to/from. 9 | 10 | | STREAM | DESCRIPTION | 11 | |---|---| 12 | | cin | standard input stream | 13 | | cout | standard output stream | 14 | | cerr | standard error (output) stream | 15 | | clog | standard logging (output) stream | 16 | 17 | - `"` double qouting makes difference when it comes to `c++`; when the text is enclosed between them, the text is printed literally; when they are not, the text is interpreted as the identifier of a variable, and its value is printed instead 18 | - `std` abbreviation for standard 19 | 20 | - `::` is the `scope` operator 21 | 22 | - `=` indicates assignment, not equality in the mathematical sense 23 | 24 | - `>>` operator (“get from”) specifies where that input goes 25 | 26 | - `<<` operator inserts the data that follows it into the stream that precedes it 27 | 28 | - Don't forget to add a backslash n (`\n`) to insert a line break, `endl` manipulator can also be used to break lines 29 | 30 | - `getline` that takes the stream (`cin`) as first argument, and the string variable as second 31 | 32 | ------- 33 | - STRINGSTREAM 34 | - The standard header `` defines a type called `stringstream` that allows a string to be treated as a stream, and thus allowing extraction or insertion operations from/to strings in the same way as they are performed on `cin` and `cout` 35 | 36 | 37 | ---------- 38 | To run c++ on terminal: execute and run the program. 39 | 40 | to execute: 41 | 42 | `g++ filename -o a.out` 43 | 44 | `g++ filename` 45 | 46 | to run: 47 | 48 | `./a.out` 49 | 50 | `./my_executable.out` 51 | 52 | `./filename` 53 | 54 | ``` 55 | // single line comment 56 | /* ... */ multiple line comment 57 | ``` 58 | 59 | Code, save, run (IDE) 60 | Compile and Execute (terminal) 61 | 62 | ------------ 63 | `DATA TYPES`: 64 | | TYPE | USAGE | EX | 65 | |---|---|---| 66 | | Int | int num |0, 420 | 67 | | Double | floating-point num |3.14, -2.0 | 68 | |Char | characters | ‘a’, ‘@‘ | 69 | |String | seq of characters | “Hello World!”, “Codecademy” | 70 | |Bool | truth values | true, false | 71 | 72 | ---------- 73 | **`Arithmetic Operators`**: 74 | - `+` addition 75 | - `-` subtraction 76 | - `*` multiplication 77 | - `/` division 78 | - `%` modulo 79 | 80 | ```Note: The order of operations can be specified using parentheses ().``` 81 | 82 | ---------- 83 | `Variable` - is a location in memory where a value can be stored. Declare variables with data type and name before use 84 | 85 | 86 | 87 | ---------- 88 | `Formulas`: 89 | 90 | Fahrenheit (F) to Celsius (C) 91 | - C = (F - 32) / 1.8C=(F−32)/1.8 92 | 93 | To calculate `BMI` body mass index 94 | - bmi = weight / (height * height) 95 | 96 | | # | Planet | Relative Gravity | 97 | |---|---|---| 98 | | 1 | Mercury | 0.38 | 99 | | 2 | Venus | 0.91 | 100 | | 3 | Mars | 0.38 | 101 | | 4 | Jupiter | 2.34 | 102 | | 5 | Saturn | 1.06 | 103 | | 6 | Uranus | 0.92 | 104 | | 7 | Neptune | 1.19 | 105 | 106 | ------------ 107 | **`CONDITIONAL & LOGIC`** 108 | 109 | - ***if, else if, and else statements*** 110 | - `if` statement is used to test an expression for truth and execute some code based on it: if the condition is `true`, then the statements within are executed. Otherwise, the statements are skipped and the program continues on. 111 | - add an `else` clause to an `if` statement to provide code that will only be executed if the condition is `false`. So what happens if you want more than two possible outcomes? This is where `else if` comes in! The e`lse if` statement always comes after the `if` statement and before the `else` statement. The `else if` statement also takes a condition. 112 | - ***switch statements*** 113 | - `switch` statement provides an alternative syntax that is easier to read and write 114 | - the `switch` keyword initiates the statement and is followed by `()`, which contains the value that each case will compare. `One restriction` on this expression is that it must evaluate to an `integral type` (`int`, `char`, `short`, `long`, `long long`, or `enum`) 115 | - inside the block, `{}`, there are multiple cases. The `case` keyword checks if the expression matches the specified value that comes after it, the code that follows the `:` would run 116 | - `break` keyword tells the computer to exit the block and not execute any more code 117 | - At the end of each `switch` statement, there is a `default` statement. If none of the cases are `true`, then the code in the `default` statement will run. It’s essentially the `"else"` part. 118 | - ***Relational Opreators***(can compare 2 values): 119 | - `==` equal to 120 | - `!=` not equal to 121 | - `>` greater than 122 | - `<` less than 123 | - `>=` greater than or equal to 124 | - `<=` less than or equal to 125 | 126 | `note:` ***^=*** `swapping` 127 | 128 | - ***Logical Operators*** 129 | - `&&`: the `and` logical operator (only one needs to be `false`) 130 | - `||`: the `or` logical operator (only one needs to be `true`) 131 | - `!`: the `not` logical operator 132 | 133 | **`Introduction to Loops`** 134 | 135 | `Loops` - a programming tool that repeats some code or a set of instructions until a specified condition is reached. An `iteration` in your code when referring to your `loops`; `iterate` means `"to repeat"`. 136 | 137 | 2 Types of Loops: 138 | 1. while loops 139 | - The `while` loop looks very similar to an `if` statement. And just like an `if` statement, it executes the code inside of it if the condition is `true`. However, the difference is that the `while` loop will continue to execute the code inside of it, *over and over again*, as long as the condition is `true`. 140 | 2. for loops 141 | - A `for` loop is a *repetition* control structure that allows you to efficiently write a loop that needs to execute a specific number of times. 142 | - There are three separate parts to this separated by `;`: 143 | - The initialization of a *counter*: `int i = 0` 144 | - The continue condition: `i < 20` 145 | - The change in the counter (*in this case an increment*): `i++` 146 | 147 | *Syntax of a `For` loop* 148 | ``` 149 | for ( init; condition; increment ) { 150 | statement(s); 151 | } 152 | ``` 153 | 154 | *Incrementing `for` loop:* 155 | ``` 156 | for (int i = 0; i < 20; i++) 157 | { 158 | // Statements 159 | } 160 | ``` 161 | 162 | 163 | *Decrementing `for` loop:* 164 | ``` 165 | for (int i = 20; i > 0; i--) 166 | { 167 | // Statements 168 | } 169 | ``` 170 | 171 | 172 | 173 | **`Classifying Errors`** 174 | 1. ***Compile-time errors***: Errors found by the compiler. 175 | - `Syntax errors`: Errors that occur when we violate the rules of C++ syntax. eg: missing semi-colon `;`, closing parenthesis `)`, square bracket `]`, or curly brace `}` 176 | - `Type errors`: Errors that occur when there are mismatch between the types we declared. eg: `Forgetting to declare` a variable and `Storing a value` into the wrong type 177 | 2. ***Link-time errors***: Errors found by the linker when it is trying to combine object files into an executable program. 178 | 3. ***Run-time errors***: Errors found by checks in a running program. 179 | 4. ***Logic errors***: Errors found by the programmer looking for the causes of erroneous results. 180 | 181 | 182 | **Array** 183 | 184 | Using `sizeof()` 185 | - to find the length of an array is to divide the size of the array by the size of each element (in bytes). 186 | 187 | ***`arrSize = sizeof(arr)/sizeof(arr[0]);`*** 188 | 189 | ``` 190 | #include 191 | using namespace std; 192 | 193 | int main() { 194 | int arr[] = {10,20,30,40,50,60}; 195 | int arrSize = sizeof(arr)/sizeof(arr[0]); 196 | cout << "The size of the array is: " << arrSize; 197 | return 0; 198 | } 199 | ``` --------------------------------------------------------------------------------