C++ Tutorial for Beginners - Learn C++ in 1 Hour

Programming with Mosh2 minutes read

The C++ course led by Mash Hamadani covers basic to advanced concepts, aiming to build confident coding skills and is practical, comprehensive, and easy to follow. Students will learn about key C++ features, syntax, the C++ Standard Library, and practical applications through exercises and structured lessons.

Insights

  • C++ course led by Mash Hamadani covers basics to advanced concepts, aiming for confident coding by course end. C++ remains relevant due to speed and memory efficiency, utilized by major companies like Adobe, Google, and Microsoft.
  • Learning C++ involves mastering syntax, Standard Library, and practical coding techniques. Course structure includes three parts with exercises, covering variables, mathematical expressions, input/output operations, libraries like cmath, and fundamental data types.

Get key ideas from YouTube videos. It’s free

Recent questions

  • What is C++ used for?

    C++ is used by major companies like Adobe, Google, Microsoft, Netflix, and NASA.

Related videos

Summary

00:00

Master C++ with Mash Hamadani's Course

  • Course covers everything from basics to advanced concepts in C++
  • Aim is to enable confident C++ coding by course end
  • Course is comprehensive, easy to follow, well-organized, and practical
  • No prior C++ or programming knowledge required
  • Instructor is Mash Hamadani, a software engineer with over 20 years of experience
  • C++ is used by major companies like Adobe, Google, Microsoft, Netflix, and NASA
  • New version of C++ released every three years, with version 20 being the latest
  • C++ is still relevant due to its speed and memory efficiency
  • Learning C++ involves mastering the language syntax and the C++ Standard Library (STL)
  • STL provides pre-written code for common functionalities like data structures and algorithms

16:13

"Enhancing Videos and Learning C++ Basics"

  • To change themes in videos, go to Preferences, Appearance and Behavior, Appearance, and select a theme.
  • More themes can be added by clicking a link and sorting by downloads to choose popular ones like Dracula.
  • Install the chosen theme to enhance the appearance of the videos in C Lion.
  • The course on C++ is structured into three parts: basics, intermediate, and advanced concepts.
  • Each part is about 3-4 hours long, with exercises to improve problem-solving skills.
  • The course covers data types, decision making, loops, functions, arrays, pointers, strings, and more.
  • Variables in programming store data temporarily in memory, with meaningful names and initialization.
  • Constants prevent variable value changes, using the const keyword before declaration.
  • Naming conventions like snake case, pascal case, camel case, and Hungarian notation are discussed.
  • Mathematical expressions in C++ involve operators like addition, subtraction, multiplication, division, modulus, and increment/decrement.

33:20

Understanding Increment Operator in C++ Operations

  • The increment operator, denoted as x++, is used for increasing a variable's value by 1.
  • There is no equivalent operator for multiplication or division, only increment and decrement.
  • The increment operator can be applied as a postfix or prefix, affecting the variable differently.
  • When applied as a postfix, the current value of x is assigned to another variable before incrementing x.
  • Applying the increment operator as a prefix first increments x and then assigns the new value to another variable.
  • Mathematical expressions prioritize multiplication and division over addition and subtraction.
  • Parentheses can alter the order of operations in mathematical expressions.
  • An exercise involves implementing a mathematical expression in C++ with given values for variables.
  • Techniques for writing to the console in C++ involve using the std namespace and stream insertion operator.
  • Reading input from the console in C++ is done using the c in object and stream extraction operator.

51:10

C++ Programming Basics and Functions

  • The program allows for reading multiple values, changing a label to enter values for x and y, declaring variables x and y, reading x and y, and printing their sum.
  • The program functions as a simple calculator, accepting input for x and y, and displaying the result.
  • The program can handle numbers separated by spaces, demonstrating flexibility in input format.
  • Chaining statements together is possible, reducing code length while maintaining functionality.
  • An exercise is given to convert temperatures from Fahrenheit to Celsius, requiring user input for Fahrenheit temperature and displaying the converted Celsius temperature.
  • The solution involves printing a label for Fahrenheit, reading the Fahrenheit temperature, calculating the Celsius temperature, and displaying it.
  • The lesson introduces the cmath library for mathematical functions, suggesting online resources for further information.
  • The seal function rounds up a value, while the floor function rounds down a value, with examples provided.
  • The pow function calculates the power of a number, requiring two arguments.
  • An exercise is proposed to calculate the area of a circle based on user input for the radius, with a solution involving pi and the power function.
  • Comments are discussed as a means to clarify code, with examples of single-line and multi-line comments provided.
  • The section on fundamental data types in C++ is introduced, covering integer, floating point, boolean, character, and string types, as well as arrays.
  • The distinction between statically typed languages like C++ and dynamically typed languages like Python is explained.
  • Various built-in data types in C++ are detailed, including int, short, long, double, float, long double, bool, and char.
  • Different ways to declare and initialize variables in C++ are demonstrated, including specifying types explicitly, using suffixes for float and long types, and utilizing the auto keyword for type inference.
  • Brace initialization is introduced as a modern C++ feature for initializing variables.

01:08:17

Variable initialization, number systems, and random numbers.

  • Using braces for variable initialization prevents assigning wrong values, causing compilation errors if incorrect values are input.
  • Brace initialization ensures variables are initialized to zero if no value is supplied, preventing unpredictable outcomes.
  • Different number systems like decimal, binary, and hexadecimal are used in math and programming for various purposes.
  • Hexadecimal numbers are more compact and are commonly used in programming to represent colors, simplifying color representation.
  • The "unsigned" keyword in C++ restricts numerical types from accepting negative values, potentially causing unexpected results.
  • Narrowing occurs when initializing a variable of a smaller type with a larger type, leading to data loss or warnings.
  • Random numbers in C++ are generated using the "rand" function from the "cstdlib" library, but require seeding with different values for true randomness.
  • Seeding the random number generator with the current time in seconds from 1970 ensures different random numbers on each program run, allowing for more randomness.
Channel avatarChannel avatarChannel avatarChannel avatarChannel avatar

Try it yourself — It’s free.