<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rohit Juyal</title>
    <description>The latest articles on DEV Community by Rohit Juyal (@rohit_juyal_68a5f2251c433).</description>
    <link>https://dev.to/rohit_juyal_68a5f2251c433</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1552852%2F59826e14-e26a-4e32-85bc-c724e6a39c25.png</url>
      <title>DEV Community: Rohit Juyal</title>
      <link>https://dev.to/rohit_juyal_68a5f2251c433</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rohit_juyal_68a5f2251c433"/>
    <language>en</language>
    <item>
      <title>Day 02</title>
      <dc:creator>Rohit Juyal</dc:creator>
      <pubDate>Sun, 06 Apr 2025 21:24:36 +0000</pubDate>
      <link>https://dev.to/rohit_juyal_68a5f2251c433/day-02-2c36</link>
      <guid>https://dev.to/rohit_juyal_68a5f2251c433/day-02-2c36</guid>
      <description>&lt;p&gt;&lt;em&gt;Written on: 06 April, 2025.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📝 Comments in C++
&lt;/h2&gt;

&lt;p&gt;We use comments to explain what a code do. It is ignored by compiler and is used for other developers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is a single-line comment&lt;/span&gt;

&lt;span class="cm"&gt;/*
This is a 
multi-line comment
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📦 Preprocessor Directives
&lt;/h2&gt;

&lt;p&gt;At the top of most C++ programs, you’ll often see lines starting with &lt;code&gt;#&lt;/code&gt;. These are &lt;strong&gt;preprocessor directives&lt;/strong&gt;, and they give instructions to the compiler before the actual compilation starts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line tells the compiler to include the &lt;strong&gt;iostream&lt;/strong&gt; file — a pre-written file that contains useful code for &lt;strong&gt;input and output&lt;/strong&gt; operations.&lt;/p&gt;




&lt;h2&gt;
  
  
  💬 Input/Output in C++
&lt;/h2&gt;

&lt;p&gt;To print something on the screen in C++, we use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Hello, world!"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;std&lt;/code&gt; stands for &lt;strong&gt;standard&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cout&lt;/code&gt; is the function used for &lt;strong&gt;console output&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; is the &lt;strong&gt;insertion operator&lt;/strong&gt; (used to send output to the screen).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;endl&lt;/code&gt; means &lt;strong&gt;end line&lt;/strong&gt;, just like pressing “Enter”, it moves cursor to new line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another way of writing is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line allows you to &lt;strong&gt;skip writing &lt;code&gt;std::&lt;/code&gt;&lt;/strong&gt; every time. But be careful! Importing the entire &lt;code&gt;std&lt;/code&gt; namespace can be heavy in larger programs. A better approach is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧠 Namespaces
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;namespace&lt;/strong&gt; is like a region that allow us to group names for variables etc to avoid conflicts. "std" is standard C++ library for names. &lt;br&gt;
We can also create our own namespaces.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;my_own&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;do_something&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// do some thing&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;my_own&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;do_something&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// calling the function inside the namespace&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🌐 Real-World Namespace Examples
&lt;/h2&gt;

&lt;p&gt;Here are some common namespaces you’ll see in C++:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;std → Standard C++ Library (e.g., std::cout, std::endl)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;cv → OpenCV library (e.g., cv::Mat, cv::imread)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Eigen → Eigen library for linear algebra (e.g., Eigen::MatrixXd)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📌 Functions: What Are They?
&lt;/h2&gt;

&lt;p&gt;In simple words, a &lt;strong&gt;function&lt;/strong&gt; is a name given to a block of code that performs a specific task. It allows us to reuse code and makes our programs more organised.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;addNumbers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// code to add numbers&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 &lt;strong&gt;Key Point&lt;/strong&gt;:  &lt;/p&gt;

&lt;h2&gt;
  
  
  Every function &lt;strong&gt;returns a value&lt;/strong&gt;. We use &lt;code&gt;return 0;&lt;/code&gt; to indicate that the function is executed successfully.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  🛠️ Methods: Functions Inside Objects
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Methods&lt;/strong&gt; are also functions, but they belong to &lt;strong&gt;objects or classes&lt;/strong&gt;. I will learn about objects later. &lt;/p&gt;

&lt;p&gt;Even the &lt;code&gt;main()&lt;/code&gt; function is technically a method. It's the &lt;strong&gt;starting point&lt;/strong&gt; of any C++ program.&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 Variables
&lt;/h2&gt;

&lt;p&gt;To store data, we use &lt;strong&gt;variables&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;abc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c1"&gt;// Declaration&lt;/span&gt;
&lt;span class="n"&gt;abc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// Assignment&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or in one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;abc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Initialization&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are certain keywords which we can't use as variable names, as they have meaning in C++.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Why &lt;code&gt;main.cpp&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;Big projects often contains many files, so it’s common to name your main file &lt;code&gt;main.cpp&lt;/code&gt;. It makes us clear where the program begins execution. This is just a naming convention for better understanding and structuring.&lt;/p&gt;




&lt;h2&gt;
  
  
  💻✨ Data Types in C++
&lt;/h2&gt;

&lt;p&gt;The data we store in variables, is divided into categories called &lt;strong&gt;data types&lt;/strong&gt;. Each data type tells the compiler what kind of value a variable will hold. This avoids confusion and prevents error. &lt;/p&gt;




&lt;h2&gt;
  
  
  🔢 &lt;code&gt;int&lt;/code&gt; – Integer Type
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;int&lt;/code&gt; data type is used to store &lt;strong&gt;whole numbers&lt;/strong&gt; — that is, numbers &lt;strong&gt;without decimal points&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2025&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;temperature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔒 Constant Values
&lt;/h2&gt;

&lt;p&gt;If you don’t want a variable’s value to change, declare it as &lt;code&gt;const&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;abc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;231&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// abc = 200;  ❌ This will give an error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ✅ Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add comments to keep your code readable.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;#include&lt;/code&gt; to bring in standard or custom files.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;std::cout&lt;/code&gt; or &lt;code&gt;using namespace std&lt;/code&gt; for output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Namespaces&lt;/strong&gt; help organize and avoid conflicts in code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Functions&lt;/strong&gt; do specific tasks and return values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Methods&lt;/strong&gt; are functions connected to objects.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;int&lt;/code&gt; data type is used for storing whole numbers. &lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;const&lt;/code&gt; to lock variable values.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;About me(a little more detail): Hi, I am Rohit. I started my career late in life i.e. last year, right now I am 35. I am currently working in BPO. My aim is to get into HFT. I know it's not a joke &amp;amp; age and other factors not on my side. But let's see how things goes on. A year earlier I was just sitting on my desk unemployed hoping for life to become better. If not that I will be happy trying.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>cpp</category>
    </item>
    <item>
      <title>"Hello C++"</title>
      <dc:creator>Rohit Juyal</dc:creator>
      <pubDate>Sat, 05 Apr 2025 08:59:34 +0000</pubDate>
      <link>https://dev.to/rohit_juyal_68a5f2251c433/hello-c-3m6i</link>
      <guid>https://dev.to/rohit_juyal_68a5f2251c433/hello-c-3m6i</guid>
      <description>&lt;p&gt;Basics of C++&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It's an object oriented language&lt;/li&gt;
&lt;li&gt;It's statically typed language, meaning we know the data type of the variable (we define it)&lt;/li&gt;
&lt;li&gt;We can manage memory in it, as it has concept of pointers&lt;/li&gt;
&lt;li&gt;It's a compiled language, compiler converts c++ code into binary&lt;/li&gt;
&lt;li&gt;As we can have binary code file in the end, C++ program can be said platform independent i.e. can run anywhere &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My first program: &lt;/p&gt;

&lt;h1&gt;
  
  
  include 
&lt;/h1&gt;

&lt;p&gt;int main()&lt;br&gt;
{&lt;br&gt;
std::cout &amp;lt;&amp;lt; "Hello World" &amp;lt;&amp;lt; std::endl;&lt;br&gt;
return 0;&lt;br&gt;
} &lt;/p&gt;

&lt;p&gt;Explanation(what ever I was able to understand): &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To run program we need to have pre-written files, iostream is one of that and #include includes that. &lt;/li&gt;
&lt;li&gt;std::cout will show "Hello World" on the screen.&lt;/li&gt;
&lt;li&gt;Lines inside should end with semi-colon ;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My setup: I am using Linux as pc is old(windows &amp;amp; vscode working slow), I have installed vim and installed g++( it is a compiler and contains files needed to make program). Not that hectic, easy to use. But took me a week to search what is good for me.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>cpp</category>
    </item>
  </channel>
</rss>
