Things I Learned This Week :-
Basic Structure Of A C++ Program :- It was exciting to explore header files, understand the main function, and figure out why we use
return 0
. If you're curious to learn more, check out my keynotes.Variables & Comments:- I learned how variables act as storage for data in a program and how they make coding flexible and dynamic. Comments are like notes in the code they help explain what’s happening. Want to know more? Head over to my keynotes.
Variables Scope & Data Types :- Scope defines where a variable can be accessed in a program. Data types like
int
,float
, andchar
help us decide what kind of data a variable can hold. Curious to explore them further? Refer to my keynotes.Basic Input/Output & More :- I learned how to interact with users by taking input with
cin
and displaying output withcout
. Input and output streams likecin
andcout
allow data to flow into and out of the program. For more details, refer to my keynotes.Header Files & Operators :- I learned that header files, like
#include <iostream>
, help us bring in built-in functions and libraries into our program. They're essential for adding functionality. Operators are symbols that perform operations on variables. I worked with arithmetic, logical, and comparison operators to manipulate data. Want to learn more? Refer to my keynotes.Reference Variables & Typecasting :- Reference Variables allow us to use the original variable directly without needing to refer to it repeatedly. Typecasting lets us convert one data type into another. For more on this, check out my keynotes.
Constants, Manipulators & Operator Precedence :- Constants are values that cannot be changed once defined. They’re super helpful when you want to make your program more reliable by preventing accidental changes to important variables. Manipulators are like magic tools for formatting input and output. Operator precedence taught me that math in code doesn’t always happen left to right, some operators take priority! Check out my keynotes for details.
Control Structures :- Control structures are the backbone of decision-making and program flow in C++. Check out my keynotes!
Steps That I Did :-
Explored the Basic Structure
Learned about the role of header files like
<iostream>
, the main function, and the importance of thereturn 0
statement.Wrote a basic "Hello World" program and understood how input/output works using
cin
andcout
.
Practiced Variables and Data Types
Created programs using different data types like
int
,float
, andchar
.Experimented with reference variables to see how they work as aliases for other variables.
Worked with Operators
Explored arithmetic, logical, and comparison operators by solving simple math-based problems.
Learned how operator precedence affects the evaluation of expressions.
Understood Scope and Comments
Tested variable scope by defining global and local variables in my programs.
Practiced using comments to document my code clearly.
Studied Typecasting
- Implemented both implicit and explicit typecasting to see how conversions between data types work.
Worked With Constants & Manipulators:
- I learned how to make values unchangeable with constants, ensuring program reliability, and used manipulators to format output beautifully.
Explored Control Structures:
- Explored how control structures like
if
,else
,switch
, and loops dictate the flow of a program, making decision-making and iteration efficient.
- Explored how control structures like
Challenges I Faced & How I Overcame Them :-
Basic Structure Of A C++ Program :-
When I started, I wasn’t sure why certain things like
#include <iostream>
andint main()
were necessary. I also found it confusing why every program ends withreturn 0
.How I Overcame It :-
I researched the purpose of header files, understood that
main()
is the entry point for the program, and learned thatreturn 0
indicates successful termination. Writing and analyzing a basic "Hello World" program clarified these concepts for me.Tip: Always start by understanding the structure—it’s like a template for every program you’ll write.
Basic Input/Output & More :-
The syntax of
cin
andcout
felt confusing at first. I often mixed up the>>
and<<
operators. Formatting the output to look clean was another challenge.How I Overcame It :-
I practiced simple programs like taking two numbers as input and displaying their sum. I also used manipulators like
std::setw
to align output properly.Tip: Focus on small tasks, like printing and reading basic values, before moving to complex input/output operations.
Header Files & Operators :-
I wasn’t sure which header files to include for certain tasks. Additionally, I got incorrect results from expressions like
3 + 5 * 2
because I misunderstood operator precedence.How I Overcame It :-
I researched common header files like
<cmath>
for mathematical functions and practiced writing expressions with parentheses to control operator precedence.Tip: Use parentheses to make operations clear, and check the documentation to know which header files you need.
Resources I Used :-
Videos :- C++ Tutorials In Hindi By CodeWithHarry
Documentation :- cppreference.com
Conclusion :-
This week has been an exciting dive into the world of C++. From understanding the basic structure to experimenting with operators and reference variables, every step taught me something valuable. There were moments of confusion, plenty of trial and error, but also immense satisfaction when things clicked.
This is just the beginning, and I can’t wait to explore more in the coming weeks. Stay tuned for more updates, insights, and tips from my C++ learning adventure! Let’s keep building, one line of code at a time.
For all the source code, click here :- https://github.com/CodingDhairya-7/Learning-In-Public/tree/BasicToAdvanced-C%2B%2B.