<?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>Forem: Mayank Roy</title>
    <description>The latest articles on Forem by Mayank Roy (@code__mancer).</description>
    <link>https://forem.com/code__mancer</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%2F1838581%2Fcf91829e-82ef-42c7-8858-b792c5fc82f8.jpeg</url>
      <title>Forem: Mayank Roy</title>
      <link>https://forem.com/code__mancer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/code__mancer"/>
    <language>en</language>
    <item>
      <title>🛠️ LinkedIn Post: Major Updates in DevConnect</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Fri, 18 Jul 2025 14:01:49 +0000</pubDate>
      <link>https://forem.com/code__mancer/linkedin-post-major-updates-in-devconnect-6ce</link>
      <guid>https://forem.com/code__mancer/linkedin-post-major-updates-in-devconnect-6ce</guid>
      <description>&lt;h2&gt;
  
  
  🔍 What’s New?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1️⃣ Enhanced Repo Cards&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• 🚀 Refined layout in both Dashboard and MainFeed for a clean, polished look&lt;br&gt;
 • 📋 Added Copy Clone Link buttons for one-click access&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2️⃣ Richer Media Layout&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• 🎨 Refined image/video grid styling—crisp, responsive, and visually appealing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3️⃣ 🔐 Stronger Sign-up Protection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• 🔄 Password normalized before hashing&lt;br&gt;
 • ✅ Enforced full validation: length, character types &amp;amp; edge cases&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💡 Why It Matters&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better UX = happier users&lt;/li&gt;
&lt;li&gt;Enhanced security = peace of mind&lt;/li&gt;
&lt;li&gt;Faster workflows = dev momentum&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;📌 What’s Next&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lightbox/modal previews&lt;/li&gt;
&lt;li&gt;Inline error alerts&lt;/li&gt;
&lt;li&gt;Accessibility improvements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thrilled to see how these changes improve DevConnect—stay tuned for more upgrades! 🌟&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>I’m excited to share some 🔥 updates in DevConnect</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Thu, 17 Jul 2025 13:13:04 +0000</pubDate>
      <link>https://forem.com/code__mancer/im-excited-to-share-some-updates-in-devconnect-5h6o</link>
      <guid>https://forem.com/code__mancer/im-excited-to-share-some-updates-in-devconnect-5h6o</guid>
      <description>&lt;p&gt;&lt;strong&gt;✨ feat:&lt;/strong&gt; Added CommentBox &amp;amp; CommentList components to enable seamless user comments!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ feat:&lt;/strong&gt; Refactored MainFeed and LikeButton to include commenting and improve repo display.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔧 feat:&lt;/strong&gt; Cleaned up media upload logic, integrated comments and likes—everything now works together beautifully in the feed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it matters:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Users can now comment directly on posts and see updates instantly—better engagement!&lt;/li&gt;
&lt;li&gt;Cleaned component structure and Redux logic help maintainability and scalability.&lt;/li&gt;
&lt;li&gt;UI is more intuitive and interactive, blending likes, comments, and media seamlessly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💬 I’d love your feedback: How do you approach comments in social features? Any libraries or patterns you swear by?&lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>🚀I’m excited to share the latest improvements in DevConnect!</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Wed, 16 Jul 2025 10:26:32 +0000</pubDate>
      <link>https://forem.com/code__mancer/im-excited-to-share-the-latest-improvements-in-devconnect-358d</link>
      <guid>https://forem.com/code__mancer/im-excited-to-share-the-latest-improvements-in-devconnect-358d</guid>
      <description>&lt;h2&gt;
  
  
  ✨ What’s new:
&lt;/h2&gt;

&lt;p&gt;Improved repo display in MainFeed — simplified logic, removed &lt;strong&gt;useFetchRepos&lt;/strong&gt; hook, and built cleaner component structure.&lt;br&gt;
CommentBox feature — users can now add comments directly on posts. The functionality is powered by a new &lt;strong&gt;createAsyncThunk&lt;/strong&gt; in the &lt;strong&gt;Redux slice&lt;/strong&gt; and handled cleanly via &lt;strong&gt;extraReducers&lt;/strong&gt;.&lt;br&gt;
UI clarity boost — enhanced layouts with refined styling, making media, likes, and comments easy to read and interact with.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ The why behind the changes:
&lt;/h2&gt;

&lt;p&gt;Removed unnecessary abstraction (&lt;strong&gt;useFetchRepos&lt;/strong&gt;) to reduce complexity and improve render performance.&lt;br&gt;
Leveraged Redux Toolkit’s &lt;strong&gt;createAsyncThunk&lt;/strong&gt; for robust async handling—just like industry standards .&lt;br&gt;
Ensured a seamless user experience: comment submissions instantly update the feed via optimized state handling.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔍 What this means for users:
&lt;/h2&gt;

&lt;p&gt;Quick, responsive commenting experience.&lt;br&gt;
Streamlined UI with intuitive layout and feedback.&lt;br&gt;
Clearer codebase = faster iteration for future enhancements.&lt;/p&gt;

&lt;h2&gt;
  
  
  🙌 Next steps:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt; Add delete &amp;amp; edit options for comments&lt;/li&gt;
&lt;li&gt; Style feedback/loading states&lt;/li&gt;
&lt;li&gt; Optimize media previews&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Curious to hear your input—what’s your approach to handling real-time comments in web apps?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>redux</category>
      <category>react</category>
    </item>
    <item>
      <title>🚀 What’s New in DevConnect</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Mon, 14 Jul 2025 12:05:00 +0000</pubDate>
      <link>https://forem.com/code__mancer/whats-new-in-devconnect-4d0o</link>
      <guid>https://forem.com/code__mancer/whats-new-in-devconnect-4d0o</guid>
      <description>&lt;p&gt;&lt;strong&gt;📥 Media upload revamped –&lt;/strong&gt; improved file handling and refreshed UI for smoother post creation via the Dashboard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔁 Refactored backend logic –&lt;/strong&gt; streamlined both create &amp;amp; update flows, now using githubRepoName for clarity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 New hook added –&lt;/strong&gt; useFetchRepos neatly fetches GitHub repository data, keeping concerns separated and components clean.&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 Why It Matters
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;⚡️ Upload fast, post faster –&lt;/strong&gt; better performance and UX when adding images/videos.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧹 Cleaner code&lt;/strong&gt; = &lt;strong&gt;fewer bugs&lt;/strong&gt;, easier maintenance, and less confusion around repo fields.&lt;/p&gt;

&lt;p&gt;✨ Modular patterns with hooks make fetching GitHub repos reusable and efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  👀 What’s Next?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Adding cross-check badges (stars/forks) next to GitHub links.&lt;/li&gt;
&lt;li&gt;Implementing error/loading feedback in the UI.&lt;/li&gt;
&lt;li&gt;Building out comments &amp;amp; notifications features.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  💬 I'd Love Your Feedback
&lt;/h2&gt;

&lt;p&gt;How do you handle media file uploads and GitHub data in your web apps? Any best practices or libraries you'd recommend?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>backend</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🚀 DevConnect Progress</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Fri, 11 Jul 2025 14:15:05 +0000</pubDate>
      <link>https://forem.com/code__mancer/devconnect-progress-294d</link>
      <guid>https://forem.com/code__mancer/devconnect-progress-294d</guid>
      <description>&lt;p&gt;&lt;strong&gt;✅ Added Like toggling&lt;/strong&gt; — users can now like/unlike posts, stored in Redux&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔄 Refactored how Dashboard fetches posts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💡 Introduced new LikeButton component for consistent UI across app&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🤯 My biggest headache?
&lt;/h2&gt;

&lt;p&gt;Turns out the root cause was a damn route &lt;strong&gt;spelling mistake&lt;/strong&gt; (/post instead of /posts) — yeah, wasted &lt;strong&gt;HOURS&lt;/strong&gt; on that one. 😫 And if that wasn’t enough, the like state wasn’t updating instantly in the UI due to a mix‑up between React component state and Redux state. Figuring that out taught me so much about state flow and debugging in React + Redux .&lt;/p&gt;

&lt;h2&gt;
  
  
  ✅ Why it matters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Centralized state with Redux ensures like counts are always accurate and consistent.&lt;/li&gt;
&lt;li&gt;A reusable LikeButton simplifies future maintenance and styling.&lt;/li&gt;
&lt;li&gt;Cleaner fetch logic = fewer bugs and better performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🎯 What’s next?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Improve real-time UI updates (optimistic rendering when liking/unliking)&lt;/li&gt;
&lt;li&gt;Add feedback/loading indicators around like actions&lt;/li&gt;
&lt;li&gt;Build out comments feature next 🚧&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  💬 I'd love your insights:
&lt;/h2&gt;

&lt;p&gt;Ever spent hours debugging a typo route issue? How did you stop that cycle?&lt;br&gt;
How do you handle global vs component state for UI vs data?&lt;br&gt;
Your tips or stories would be amazing to hear!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>redux</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🚀 New endpoint: Fetch user profile data reliably on demand</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Thu, 10 Jul 2025 04:26:47 +0000</pubDate>
      <link>https://forem.com/code__mancer/new-endpoint-fetch-user-profile-data-reliably-on-demand-50nh</link>
      <guid>https://forem.com/code__mancer/new-endpoint-fetch-user-profile-data-reliably-on-demand-50nh</guid>
      <description>&lt;p&gt;🛡️ Global error handler: Centralized Express middleware to catch and format API errors consistently&lt;/p&gt;

&lt;p&gt;📦 Clean imports: Refactored Axios imports to streamline HTTP calls across components&lt;/p&gt;

&lt;h2&gt;
  
  
  🐛 My debugging nightmare
&lt;/h2&gt;

&lt;p&gt;I spent hours chasing down an elusive error—requests were sporadically failing, but the message didn’t point to any file or component. Tracking it felt like chasing ghosts through async routes. Debugging this taught me the difference between scattered try/catch and a centralized error .&lt;br&gt;
That moment was brutal…but so rewarding when I finally found and fixed the root cause. Seriously, nothing sharpens your skills quite like those moments.&lt;/p&gt;

&lt;h2&gt;
  
  
  ✅ Why this matters
&lt;/h2&gt;

&lt;p&gt;🧩 Cleaner code – one place for all error handling makes services easier to maintain&lt;/p&gt;

&lt;p&gt;📈 Better UX – users see consistent error messages, not ugly stack traces&lt;/p&gt;

&lt;p&gt;⚡ Developer sanity – less time lost debugging and more time building&lt;/p&gt;

&lt;p&gt;💭 What’s next?&lt;/p&gt;

&lt;p&gt;Improving frontend UX around loading/error states&lt;br&gt;
More API endpoints: updating profiles, fetching followers, etc.&lt;br&gt;
Deepening test coverage for error paths&lt;/p&gt;

&lt;p&gt;🎙️ I’d love your input&lt;br&gt;
Any tips for debugging Express errors faster?&lt;br&gt;
How do you handle Axios imports and error handling in large React apps?&lt;br&gt;
Always grateful for insights from the community 🙏 &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>devbugsmash</category>
      <category>react</category>
    </item>
    <item>
      <title>🚀 DevConnect Progress Update!</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Wed, 09 Jul 2025 07:12:46 +0000</pubDate>
      <link>https://forem.com/code__mancer/devconnect-progress-update-3k58</link>
      <guid>https://forem.com/code__mancer/devconnect-progress-update-3k58</guid>
      <description>&lt;h2&gt;
  
  
  Just pushed two major improvements:
&lt;/h2&gt;

&lt;p&gt;🔀 Enhanced routing &amp;amp; UI components — improved how posts are created, edited, and displayed.&lt;/p&gt;

&lt;p&gt;🗂️ Dashboard tabs added — now users can easily switch between Posts, Media, and GitHub repos.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fun fact:
&lt;/h2&gt;

&lt;p&gt;while building the profile post feed, I accidentally overwrote the Main feed—so everything showed up in the wrong place! 😅 Good catch during testing, and now it’s fixed.&lt;/p&gt;

&lt;p&gt;Also, I admit: I didn’t document these changes from the start, but I’m committing to better documentation going forward 📚✅.&lt;/p&gt;

&lt;h2&gt;
  
  
  ✅ Why it matters:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Cleaner navigation and UI make DevConnect more intuitive.&lt;/li&gt;
&lt;li&gt;Tabs give focused access to different content types.&lt;/li&gt;
&lt;li&gt;And hey—errors like these remind me testing matters more than perfection.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  💭 Over to you:
&lt;/h2&gt;

&lt;p&gt;Have feedback on the new tab setup?&lt;br&gt;
What's your go-to pattern for documenting UI changes?&lt;br&gt;
Let me know—I’m all ears!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>buildinpublic</category>
    </item>
    <item>
      <title>🚧 Pre-Launch DevConnect Update:</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Tue, 08 Jul 2025 08:36:51 +0000</pubDate>
      <link>https://forem.com/code__mancer/pre-launch-devconnect-update-4p43</link>
      <guid>https://forem.com/code__mancer/pre-launch-devconnect-update-4p43</guid>
      <description>&lt;p&gt;Still no live demo yet… but hit a major milestone today: DevConnect can now fetch GitHub repos and support image/video uploads—despite a hell of a learning curve!&lt;/p&gt;

&lt;p&gt;🧑‍💻 What’s Working (So Far):&lt;/p&gt;

&lt;p&gt;✅ GitHub Integration: DevConnect now fetches public repos from GitHub—it feels amazing to see real code showing up in the profile!&lt;/p&gt;

&lt;p&gt;✅ Media Uploads: Image and video uploads work (thanks, Cloudinary), even though I accidentally uploaded test videos 30 times before fixing my file-path logic.&lt;/p&gt;

&lt;p&gt;⚠️ Challenges Along the Way:&lt;/p&gt;

&lt;p&gt;🐞 That ONE async bug: a missing await caused duplicate uploads—my Cloudinary account saw a surge in nonsense. Debugging that definitely earned me ☕.&lt;/p&gt;

&lt;p&gt;🧩 State management chaos: toggling between Context &amp;amp; Redux Toolkit had me rethinking my approach—but it's in a solid place now.&lt;/p&gt;

&lt;p&gt;🧭 UI polish: making responsive post cards look nice on mobile took way more effort than I expected.&lt;/p&gt;

&lt;p&gt;🎯 Why Keep Building&lt;br&gt;
I'm working on DevConnect pre-launch to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blend social + code sharing—so devs don’t have to juggle GitHub and Twitter separately.&lt;/li&gt;
&lt;li&gt;Create an early beta community, whose feedback will help shape features like comments on repos and like buttons.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; While there’s no live button yet, every bug fix and user test brings it closer. I’m also researching how to tease development publicly—informed by advice to build excitement early on 🧠.&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 Can You Help?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What feature matters most to you? Issues tracker? Project boards? Commenting on repos?&lt;/li&gt;
&lt;li&gt;Want to swing by the early demo? DM me—I’d appreciate any feedback.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;DevConnect is still in progress:&lt;/strong&gt; no &lt;em&gt;&lt;strong&gt;live demo&lt;/strong&gt;&lt;/em&gt; yet.&lt;br&gt;
But it's already pulling real GitHub repos + uploading media.&lt;br&gt;
Lots of cleanup &amp;amp; polish still ahead—just sharing wins and lessons early 👊.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Day 8: Exploring Functions in C++ - The Building Blocks of Reusability</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Sun, 19 Jan 2025 08:41:49 +0000</pubDate>
      <link>https://forem.com/code__mancer/day-8-exploring-functions-in-c-the-building-blocks-of-reusability-3oib</link>
      <guid>https://forem.com/code__mancer/day-8-exploring-functions-in-c-the-building-blocks-of-reusability-3oib</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Functions in C++ (Syntax, Return Type, etc.)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A function is a block of code designed to perform a specific task.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Functions in C++ follow this basic syntax:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  returnType functionName(parameters) {
    // function body
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Return Type:&lt;/strong&gt; Specifies the data type of the value returned by the function. Use &lt;code&gt;void&lt;/code&gt; if no value is returned.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Function Name:&lt;/strong&gt; Describes what the function does.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Parameters:&lt;/strong&gt; Input values for the function (optional).&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

// Function to check tea temperature
int checkTeaTemperature(int temperature) {
    return temperature;
}

int main() {
    int temp = checkTeaTemperature(85);  // Function call
    cout &amp;lt;&amp;lt; "The tea temperature is " &amp;lt;&amp;lt; temp &amp;lt;&amp;lt; "°C" &amp;lt;&amp;lt; endl;
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Declaring a Function&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Function declaration tells the compiler about the function’s name, return type, and parameters. It’s also called a &lt;strong&gt;function prototype&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The function body is defined elsewhere.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

// Declaring the function (prototype)
void serveChai(int cups);

int main() {
    serveChai(3);  // Function call
    return 0;
}

// Function definition is done later
void serveChai(int cups) {
    cout &amp;lt;&amp;lt; "Serving " &amp;lt;&amp;lt; cups &amp;lt;&amp;lt; " cups of chai!" &amp;lt;&amp;lt; endl;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Defining a Function&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A function definition includes the full function with the body.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You must define the function after declaring it if it’s not inline.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

// Function definition with body
void makeChai() {
    cout &amp;lt;&amp;lt; "Boiling water, adding tea leaves, and serving chai!" &amp;lt;&amp;lt; endl;
}

int main() {
    makeChai();  // Calling the function
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Calling a Function&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To execute a function, you call it by its name followed by parentheses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the function takes arguments, pass them inside the parentheses.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

// Function to brew tea
void brewChai() {
    cout &amp;lt;&amp;lt; "Chai is being brewed!" &amp;lt;&amp;lt; endl;
}

int main() {
    brewChai();  // Function call
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Function Parameters (Formal, Actual, Default Parameters)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Formal parameters:&lt;/strong&gt; Defined in the function signature.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Actual parameters:&lt;/strong&gt; Values passed during the function call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Default parameters:&lt;/strong&gt; Parameters with default values if none are passed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

// Function with default parameter
void serveChai(string teaType = "Masala Chai") {
    cout &amp;lt;&amp;lt; "Serving " &amp;lt;&amp;lt; teaType &amp;lt;&amp;lt; endl;
}

int main() {
    serveChai();               // Uses default parameter
    serveChai("Green Chai");    // Uses actual parameter
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Pass by Value&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pass by value&lt;/strong&gt; means the function receives a copy of the argument. Changes made inside the function do not affect the original variable.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

void pourChai(int cups) {
    cups = cups + 1;  // Modifies local copy
    cout &amp;lt;&amp;lt; "Poured " &amp;lt;&amp;lt; cups &amp;lt;&amp;lt; " cups of chai!" &amp;lt;&amp;lt; endl;
}

int main() {
    int chaiCups = 2;
    pourChai(chaiCups);  // Passing by value
    cout &amp;lt;&amp;lt; "Total chai cups outside function: " &amp;lt;&amp;lt; chaiCups &amp;lt;&amp;lt; endl;
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Pass by Reference&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pass by reference&lt;/strong&gt; passes the actual variable, so changes in the function affect the original variable.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

void refillChai(int &amp;amp;cups) {  // Pass by reference
    cups += 2;
    cout &amp;lt;&amp;lt; "Refilled to " &amp;lt;&amp;lt; cups &amp;lt;&amp;lt; " cups of chai!" &amp;lt;&amp;lt; endl;
}

int main() {
    int chaiCups = 3;
    refillChai(chaiCups);  // Passing by reference
    cout &amp;lt;&amp;lt; "Total chai cups now: " &amp;lt;&amp;lt; chaiCups &amp;lt;&amp;lt; endl;
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8. Scope of Variables&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables declared inside a function have &lt;strong&gt;local scope&lt;/strong&gt; (accessible only within the function).&lt;/li&gt;
&lt;li&gt;Variables declared outside all functions have &lt;strong&gt;global scope&lt;/strong&gt; (accessible from any function).
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

int globalChaiStock = 100;  // Global variable

void serveChai() {
    int localCups = 5;  // Local variable
    cout &amp;lt;&amp;lt; "Serving " &amp;lt;&amp;lt; localCups &amp;lt;&amp;lt; " cups from " &amp;lt;&amp;lt; globalChaiStock &amp;lt;&amp;lt; " total stock." &amp;lt;&amp;lt; endl;
}

int main() {
    serveChai();
    cout &amp;lt;&amp;lt; "Global chai stock after serving: " &amp;lt;&amp;lt; globalChaiStock &amp;lt;&amp;lt; endl;
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;9. Function Overloading&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function overloading allows multiple functions with the same name but different parameter types or numbers.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

// Function overloading
void brewChai(int cups) {
    cout &amp;lt;&amp;lt; "Brewing " &amp;lt;&amp;lt; cups &amp;lt;&amp;lt; " cups of chai." &amp;lt;&amp;lt; endl;
}

void brewChai(string teaType) {
    cout &amp;lt;&amp;lt; "Brewing " &amp;lt;&amp;lt; teaType &amp;lt;&amp;lt; "." &amp;lt;&amp;lt; endl;
}

int main() {
    brewChai(3);             // Calls int version
    brewChai("Masala Chai");  // Calls string version
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;10. Lambda Functions&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A  &lt;strong&gt;lambda function&lt;/strong&gt; is an anonymous function that can be defined inline using the&lt;code&gt;[]&lt;/code&gt; syntax.&lt;/li&gt;
&lt;li&gt;They’re useful for short, simple functions.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

using namespace std;



int main(){

   //lambda
   [](int cups){
        cout &amp;lt;&amp;lt; "Preparing " &amp;lt;&amp;lt; cups &amp;lt;&amp;lt; " cups of tea" &amp;lt;&amp;lt; endl;
   }(5);

    return 0;

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Function Declaration &amp;amp; Definition:&lt;/strong&gt; Tell the compiler about a function and define what it does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Calling Functions:&lt;/strong&gt; Execute the function by passing arguments if required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pass by Value/Reference:&lt;/strong&gt; Controls whether changes affect the original value or a copy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function Overloading:&lt;/strong&gt; Allows multiple functions with the same name but different parameter lists.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lambda Functions:&lt;/strong&gt; Short, inline functions used for simple tasks.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Day 7: Unlocking the Power of Loops in C++</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Sat, 11 Jan 2025 07:34:21 +0000</pubDate>
      <link>https://forem.com/code__mancer/day-7-unlocking-the-power-of-loops-in-c-4oc5</link>
      <guid>https://forem.com/code__mancer/day-7-unlocking-the-power-of-loops-in-c-4oc5</guid>
      <description>&lt;p&gt;&lt;strong&gt;Day 7 of my C++ journey introduced me to loops, the tools that bring repetition and efficiency to programming. I explored for, while, and do-while loops, understanding how they help execute code multiple times based on conditions.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1.While Loop
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Challenge: Write a program that keeps track of tea orders. Each time a cup of tea is made, decrease the number of cups remaining. The loop should run until all cups are served.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

using namespace std;

int main(){

    int teacups;

    cout &amp;lt;&amp;lt; "Enter the number of teacups to serve: " &amp;lt;&amp;lt; endl;
    cin &amp;gt;&amp;gt; teacups;

    //while loop
    while ( teacups &amp;gt; 0 ){
        teacups--;
        cout &amp;lt;&amp;lt; "Serving a cup of tea \n" &amp;lt;&amp;lt; teacups &amp;lt;&amp;lt; " remaining" &amp;lt;&amp;lt; endl ;

    }

    cout &amp;lt;&amp;lt; "All tea cups are served." &amp;lt;&amp;lt; endl;

    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Going through the code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;-&lt;code&gt;while&lt;/code&gt;loop is used to execute a block of code as long as a condition is &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The condition is checked before each&lt;code&gt;iteration&lt;/code&gt;of the loop.&lt;/li&gt;
&lt;li&gt;The loop will continue to execute as long as the condition is &lt;code&gt;true&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The loop will execute at least once, even if the condition is initially &lt;code&gt;false&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (condition){
      // Code to be executed
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here while checks if the teacups is greater than 0, if it is true, it will execute the code inside the loop. If the teacups is 0, the loop will not execute and the program will continue to the next line.&lt;/p&gt;

&lt;h2&gt;
  
  
  2.Do-While Loop
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Challenge: Create a program that asks the user if they want more tea. Keep asking them until they type “no” (case-insensitive), using a do-while loop.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;

using namespace std;

int main(){
    string response;
    do {
        cout &amp;lt;&amp;lt; "Do you want more tea (yes/no): " &amp;lt;&amp;lt; endl;
        getline(cin, response);
        cout &amp;lt;&amp;lt; "Here is your cup of tea enjoy!!" &amp;lt;&amp;lt; endl;
    } while (response != "no" &amp;amp;&amp;amp; response != "No");


    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Going through the code:&lt;/strong&gt;&lt;br&gt;
Here we have used the &lt;code&gt;do-while&lt;/code&gt; loop. The loop will execute at least &lt;code&gt;once&lt;/code&gt;, even if the condition is initially &lt;code&gt;false&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;do {
    // code to be executed
} while (condition);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;do&lt;/code&gt; prints the message and asks the user for input. Then it checks if the response is equal to &lt;code&gt;“no”&lt;/code&gt; or &lt;code&gt;“No”&lt;/code&gt;. If it is, it will execute the code inside the loop. If it is not, it will exit the loop and continue to the next line.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.For Loop
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Challenge: Write a program that prints the brewing instructions for making  cups of tea. The brewing process should be printed once for each cup using a for loop.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
using namespace std;

int main(){
    int teacups;

    cout &amp;lt;&amp;lt; "Enter the of teacups you want: " ;
    cin &amp;gt;&amp;gt; teacups;

    for(int i = 1; i&amp;lt;= teacups; i++){
        cout &amp;lt;&amp;lt; "Brewing cup  " &amp;lt;&amp;lt; i &amp;lt;&amp;lt; "  of tea.." &amp;lt;&amp;lt; endl;
    }


    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Going through the code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here we are using the &lt;code&gt;for&lt;/code&gt; loop. The loop will execute the code inside the loop for the specified number of times.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (initialization; condition; increment/decrement) {
    // code to be executed
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For loop has three parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialization: This is where you initialize the loop variable.&lt;/li&gt;
&lt;li&gt;Condition: This is where you check if the loop should continue or not.&lt;/li&gt;
&lt;li&gt;Increment/Decrement: This is where you update the loop variable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our case, we are initializing the loop variable with&lt;code&gt;i = 1&lt;/code&gt; and checking if the loop should continue with &lt;code&gt;i &amp;lt;= teaccups&lt;/code&gt;. If the condition is &lt;code&gt;true&lt;/code&gt;, the code inside the loop will be executed. If the condition is &lt;code&gt;false&lt;/code&gt;, the loop will exit and the program will continue to the next line.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Day 6: Learning Conditionals – The Building Blocks of Logic</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Fri, 10 Jan 2025 09:03:51 +0000</pubDate>
      <link>https://forem.com/code__mancer/day-6-learning-conditionals-the-building-blocks-of-logic-1h47</link>
      <guid>https://forem.com/code__mancer/day-6-learning-conditionals-the-building-blocks-of-logic-1h47</guid>
      <description>&lt;p&gt;*&lt;em&gt;Day 6 of my C++ journey was all about conditionals, the decision-makers of programming. I explored if, else, else if, and switch statements to handle different scenarios based on conditions. *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwxofnztfr64qudbxyct4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwxofnztfr64qudbxyct4.png" alt=" " width="498" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. If Statement&lt;br&gt;
Challenge:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Write a program that checks if the user wants to order Green Tea. If the user types “Green Tea,” the program should confirm their order.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
using namespace std;

int main(){

    string order;
    cout &amp;lt;&amp;lt; "What would you like to order? ";
    getline(cin, order);

    if(order == "Green Tea"){
        cout &amp;lt;&amp;lt; "Your Order For Green Tea is placed!" &amp;lt;&amp;lt; endl;
    }

    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Going through the code:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The string&lt;code&gt;order;&lt;/code&gt; line declares a variable named &lt;code&gt;order&lt;/code&gt; of type&lt;code&gt;string&lt;/code&gt; and does not assign a value to it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;cout &amp;lt;&amp;lt; "What would you like to order? ";&lt;/code&gt;line prints the string &lt;code&gt;"What would you like to order? "&lt;/code&gt; to the console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The&lt;code&gt;getline(cin, order);&lt;/code&gt; line reads a line of input from the console and assigns it to the order variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The&lt;code&gt;if(order == "Green Tea")&lt;/code&gt; line starts an if statement that checks if the &lt;code&gt;order&lt;/code&gt; variable is equal to the string &lt;code&gt;“Green Tea”&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The&lt;code&gt;cout &amp;lt;&amp;lt; "Your Order For Green Tea is placed!" &amp;lt;&amp;lt; endl;&lt;/code&gt; line prints the string &lt;code&gt;"Your Order For Green Tea is placed!"&lt;/code&gt; followed by a newline character to the console.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-&lt;code&gt;return 0;&lt;/code&gt; line indicates that the program has finished executing and returns a value of 0. It can return any value, but in this case, we are returning 0 as this is the exit code for a successful program execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. If-Else Statement&lt;br&gt;
Challenge:&lt;/strong&gt;&lt;br&gt;
Write a program that checks if a tea shop is open. If the current hour (input by the user) is between 8 AM and 6 PM, the shop is open; otherwise, it’s closed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

using namespace std;

int main(){

    int hour;

    cout &amp;lt;&amp;lt; "Enter the current hour (0-23):";
    cin  &amp;gt;&amp;gt; hour;

    if ( hour &amp;gt;= 8 &amp;amp;&amp;amp; hour &amp;lt;= 18){
        cout &amp;lt;&amp;lt; "The Shop is open" &amp;lt;&amp;lt; endl;
    }
    else{
        cout &amp;lt;&amp;lt; "The Shop is closed" &amp;lt;&amp;lt; endl;
    }


    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Going through the code:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;int hour;&lt;/code&gt;line declares a variable named hour of type &lt;code&gt;int&lt;/code&gt;and does not assign a value to it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;cout &amp;lt;&amp;lt; "Enter the current hour (0-23): ";&lt;/code&gt; line prints the string &lt;code&gt;“Enter the current hour (0-23): ”&lt;/code&gt; to the console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;cin &amp;gt;&amp;gt; hour;&lt;/code&gt; line reads an integer from the console and assigns it to the&lt;code&gt;hour&lt;/code&gt; variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;if(hour &amp;gt;= 8 &amp;amp;&amp;amp; hour &amp;lt;= 18)&lt;/code&gt; line starts an if statement that checks if the &lt;code&gt;hour&lt;/code&gt; variable is greater than or equal to 8 and less than or equal to 18.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;cout &amp;lt;&amp;lt; "The shop is Open" &amp;lt;&amp;lt; endl;&lt;/code&gt; line prints the string &lt;code&gt;“Tea shop is OPEN!”&lt;/code&gt; followed by a newline character to the console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The  &lt;code&gt;else {&lt;/code&gt; line starts an else block that is executed if the if statement is false.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;cout &amp;lt;&amp;lt; "The shop is closed" &amp;lt;&amp;lt; endl;&lt;/code&gt;line prints the string &lt;code&gt;"The shop is closed"&lt;/code&gt;followed by a newline character to the console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;return 0;&lt;/code&gt;line indicates that the program has finished executing and returns a value of 0. It can return any value, but in this case, we are returning 0 as this is the exit code for a successful program execution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Nested If-Else&lt;br&gt;
Challenge:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A tea shop offers discounts based on the number of tea cups ordered. Write a program that checks the number of cups ordered and applies a discount:* More than 20 cups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;20% discount&lt;/li&gt;
&lt;li&gt;Between 10 and 20 cups: 10% discount&lt;/li&gt;
&lt;li&gt;Less than 10 cups: No discount
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

using namespace std;

int main(){

    int cups;
    double pricePerCup = 2.5, totalPrice, discountedPrice ;

    cout &amp;lt;&amp;lt; "Enter the number of tea cups you want :" &amp;lt;&amp;lt; endl;
    cin &amp;gt;&amp;gt; cups;

    totalPrice = cups * pricePerCup;

    if( cups &amp;gt; 20 ){
        discountedPrice = totalPrice - (totalPrice * 0.20);
        cout &amp;lt;&amp;lt; "You have ordered  " &amp;lt;&amp;lt; cups &amp;lt;&amp;lt; "  cups you are eligible for 20% discount" &amp;lt;&amp;lt; endl ;
        cout &amp;lt;&amp;lt; "Original Price\t" &amp;lt;&amp;lt; totalPrice &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; "Discounted Price\t" &amp;lt;&amp;lt; discountedPrice &amp;lt;&amp;lt; endl ;
    }else if( cups &amp;gt;= 10 &amp;amp;&amp;amp; cups &amp;lt;= 20){
        discountedPrice = totalPrice - (totalPrice * 0.10);
         cout &amp;lt;&amp;lt; "You have ordered\t" &amp;lt;&amp;lt; cups &amp;lt;&amp;lt; "\tcups you are eligible for 10% discount" &amp;lt;&amp;lt; endl ;
        cout &amp;lt;&amp;lt; "Original Price\t" &amp;lt;&amp;lt; totalPrice &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; "Discounted Price\t" &amp;lt;&amp;lt; discountedPrice &amp;lt;&amp;lt; endl ;
    }else{
        cout &amp;lt;&amp;lt; "You are not eligible for a discount" &amp;lt;&amp;lt; endl;
    }



    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Switch Case&lt;br&gt;
Challenge:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Write a program that lets the user select a tea type from a menu. Use a switch statement to display the price based on the selected tea:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Green Tea: $2&lt;/li&gt;
&lt;li&gt;Black Tea: $4&lt;/li&gt;
&lt;li&gt;Oolong Tea: $10&lt;/li&gt;
&lt;li&gt;Chamoline Tea : $15
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;

using namespace std;

int main(){
    int choice;
    double price;

    cout &amp;lt;&amp;lt; "Select your tea \n";
    cout &amp;lt;&amp;lt; "1. Green Tea \n";
    cout &amp;lt;&amp;lt; "2. Black  Tea \n";
    cout &amp;lt;&amp;lt; "3. Oolong Tea \n";
    cout &amp;lt;&amp;lt; "4. Chamoline  Tea \n";
    cout &amp;lt;&amp;lt; "Enter your choice in number: \n";

    cin &amp;gt;&amp;gt; choice;

    switch(choice){
        case 1 :
            price = 2.0 ;
            cout &amp;lt;&amp;lt; "You have selected Green Tea. Price:  $" &amp;lt;&amp;lt; price &amp;lt;&amp;lt; endl ;
            break;
        case 2 :
            price = 4.0 ;
            cout &amp;lt;&amp;lt; "You have selected Black Tea. Price:  $" &amp;lt;&amp;lt; price &amp;lt;&amp;lt; endl ;
            break;
        case 3 :
            price = 10.0 ;
            cout &amp;lt;&amp;lt; "You have selected Oolong Tea. Price:  $" &amp;lt;&amp;lt; price &amp;lt;&amp;lt; endl ; 
            break;
        case 4 :
            price = 15.0 ;
            cout &amp;lt;&amp;lt; "You have selected Chamoline Tea. Price:  $" &amp;lt;&amp;lt; price &amp;lt;&amp;lt; endl ;
            break;
        default :
            cout &amp;lt;&amp;lt; "Invalid Choice!!" &amp;lt;&amp;lt; endl ;
            break;
    }


    return 0;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Day 5: Operators in C++ – Building Blocks of Logic</title>
      <dc:creator>Mayank Roy</dc:creator>
      <pubDate>Fri, 27 Dec 2024 06:20:58 +0000</pubDate>
      <link>https://forem.com/code__mancer/day-5-operators-in-c-building-blocks-of-logic-4kc0</link>
      <guid>https://forem.com/code__mancer/day-5-operators-in-c-building-blocks-of-logic-4kc0</guid>
      <description>&lt;p&gt;&lt;strong&gt;Understanding Operators in C++&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Operators are the backbone of programming in C++, allowing us to perform operations, make decisions, and control the flow of a program. On Day 5 of my C++ journey, I dived deep into the world of operators and uncovered how they act as the tools to manipulate and process data effectively. Here's a summary of what I learned:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arithmetic Operators&lt;/strong&gt;&lt;br&gt;
Write a program that calculates the price of tea packs. A user enters the number of tea packs they want, and the price per pack. Apply a 10% tax to the total price and display the final cost.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2q958t4gvpdan0btdfpn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2q958t4gvpdan0btdfpn.png" alt=" " width="631" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Assignment Operators&lt;/strong&gt;&lt;br&gt;
Create a program where the user inputs the number of tea bags they have. If the number is less than 10, give them 5 extra bags using the += assignment operator. Display the updated total.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1jf6xqtv83rosj0zotfy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1jf6xqtv83rosj0zotfy.png" alt=" " width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Relational Operators&lt;/strong&gt;&lt;br&gt;
A tea shop offers a loyalty program. Customers who buy more than 20 cups of tea get a special "Gold" badge, and those who buy 10 to 20 cups get a "Silver" badge. Write a program to display the badge they will receive based on the number of cups they buy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fio3n6gfyo0k8y3xra4zn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fio3n6gfyo0k8y3xra4zn.png" alt=" " width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logical Operators&lt;/strong&gt;&lt;br&gt;
Create a program that checks if a user is eligible for a tea subscription discount. The discount applies if the user is either a student or has purchased more than 15 cups. Ask the user to input their status (student or not) and their cup count. ​​&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsdy6wn3imnheeng9c3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsdy6wn3imnheeng9c3t.png" alt=" " width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

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