Data Types & Conditions
View on GitHubData Types and Conditions
Data Types
In competitive programming, it is essential to know the different data types and their limits. The following are the most commonly used data types:
- Integer: It is a whole number (positive, negative, or zero) without any decimal point. In C++, the range of an integer is from -231 to 231-1. In Python, the range is not defined, and the integer can be of any length.
- Long long: It is an extended data type in C++ used when the range of an integer exceeds the limit of int. In C++, the range of a long long is from -263 to 263-1.
- Char: It is a data type that stores a single character. In C++, it is represented by single quotes. For example, 'a', 'b', 'c'.
- String: It is a data type that stores a sequence of characters. In C++, it is represented by double quotes. For example, "Hello".
- Boolean: It is a data type that can have only two values: true or false.
Conditions
Conditions are used to make decisions in a program. In competitive programming, some of the commonly used conditions are:
- If-else: It is used to execute a block of code if a condition is true and another if it is false.
- Switch: It is used to execute different blocks of code based on different conditions.
- Ternary operator: It is a shorthand version of the if-else statement. It is used to assign a value based on a condition.
Understanding data types and conditions is essential in competitive programming as it helps in writing optimized and efficient code.
And we are here to learn them in practice and get benefit of using them.
Enjoy Data Types and Conditions!
My Session @ ICPC SCU
Useful Materials
Video Materials
- Introduction to Programming (Adel Nasim)
- Writing your first program in C++ (Adel Nasim)
- Escape Sequence (Adel Nasim)
- Variabls vs Data type (Adel Nasim)
- Priorities & Calculations in C++ (Adel Nasim)
- Basic Arithmetic & Casting (Adel Nasim)
- Prefix, Postfix, and Compound assignment (Adel Nasim)
- Variable Scope (Local vs Global) (Adel Nasim)
- Selection Statement (Adel Nasim)
- Logical Operators (Adel Nasim)
- Switch Statement (Adel Nasim)
- Errors (Dr.Mostafa Saad)
- Division & Modulus (Dr.Mostafa Saad)
Reading Materials
- Introduction to C++ programming language (GeeksforGeeks)
- C++ programming basics (GeeksforGeeks)
- C++ Data Types (GeeksforGeeks)
- Variables in C++ (GeeksforGeeks)
- Decision Making in C++ (GeeksforGeeks)