<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vijay Aneraye on Medium]]></title>
        <description><![CDATA[Stories by Vijay Aneraye on Medium]]></description>
        <link>https://medium.com/@vijayaneraye?source=rss-5f4cb3f190ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*talrijnntuHXRVMD.jpg</url>
            <title>Stories by Vijay Aneraye on Medium</title>
            <link>https://medium.com/@vijayaneraye?source=rss-5f4cb3f190ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 12:41:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vijayaneraye/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Choosing the Right Migration Strategy for Legacy Systems:]]></title>
            <link>https://medium.com/@vijayaneraye/choosing-the-right-migration-strategy-for-legacy-systems-a551509bd3ba?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/a551509bd3ba</guid>
            <category><![CDATA[enterprise-software]]></category>
            <category><![CDATA[digital-transformation]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[legacy-system-migration]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Mon, 25 May 2026 11:14:08 GMT</pubDate>
            <atom:updated>2026-05-25T11:14:08.922Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vUPQjHCJqcN5Vqk-okxbQ.png" /><figcaption>System migration strategy</figcaption></figure><p>───────────────────────────────────────────────</p><h4>WHY THIS ARTICLE EXISTS</h4><p>Every organisation eventually hits the same wall: the software running the core of the business is old, fragile, and expensive to maintain, but the business cannot afford to stop while it is being replaced.</p><p>This happens in banks and insurance companies. It happens in hospitals managing patient records. It happens in retailers running decade-old inventory systems. It happens in airlines, publishers, manufacturers, and government departments.</p><p>The problem is universal. This article explains how smart engineering teams handle it. No jargon, no unnecessary complexity. Just a clear, step-by-step approach you can actually use.</p><p>───────────────────────────────────────────────</p><h3>The Problem Every Organisation Faces Eventually</h3><p>Picture any large organisation, a bank, a hospital, a retailer, a government agency. They have millions of customers or users, hundreds of products or services, and years of data. Underneath all of that sits software built in a different era, sometimes before the internet as we know it today existed.</p><p>These old systems (called legacy systems) still work, but they are slow to update, expensive to run, and nearly impossible to connect to modern tools like AI, mobile apps, or real-time data processing.</p><p>The organisation wants to modernise. But it cannot just switch everything off and start fresh. A hospital cannot tell patients, “Sorry, no appointments this week, we’re rebuilding our system.” A bank cannot tell customers: “No payments this weekend.” A retailer cannot pause orders while upgrading its warehouse software.</p><p>The pressure is real, the risks are high, and the consequences of getting it wrong are severe.</p><p>❝ T<em>he question is never whether to modernise. It is about doing it safely, without disrupting customers, staff, regulators, or the business itself.</em> ❞</p><p>───────────────────────────────────────────────</p><h3>Why the “Blow It All Up and Rebuild” Approach Almost Always Fails</h3><p>The most tempting solution is also the most dangerous one: replace everything at once. Build a shiny new system, test it for a few months, and switch over on a quiet Sunday night.</p><p>In theory, it sounds clean and efficient. In practice, it almost always goes wrong.</p><p>⚠️ Real-world risk: In 2012, a major UK bank attempted a large-scale system migration that went badly. Millions of customers were locked out of their accounts for days. Regulators intervened. The bank paid hundreds of millions in fines and compensation. The IT director resigned. Similar stories exist in retail, healthcare, and government, wherever large, complex systems are switched over all at once.</p><p>In any large organisation, the hidden connections between systems run very deep. Order processing, customer records, fraud detection, reporting, identity checks, inventory, and billing, these all depend on each other in ways that are not always written down or even fully understood. A big-bang switch-over often uncovers these hidden connections too late.</p><p>───────────────────────────────────────────────</p><h3>The Smarter Approach: Replace It Piece by Piece</h3><p>The safest and most proven method for upgrading legacy systems is called the <strong><em>Strangler Fig Pattern</em></strong>, named after a plant that slowly grows around an old tree, eventually replacing it entirely while the tree still stands.</p><p>The idea is simple: instead of replacing everything at once, you replace one piece at a time. The old system keeps running. New, modern pieces are built alongside it. Gradually, the old system does less and less, until it can finally be retired.</p><h3>How it works:</h3><p>All user traffic → Smart routing layer → New modern services (for migrated features) OR Legacy system (still running)</p><p>Users see no difference. They still use the same app, website, or tool. But behind the scenes, modern systems are quietly taking over one function at a time.</p><p>───────────────────────────────────────────────</p><h3><strong>Which Parts Should Move First?</strong></h3><p>Not all systems carry the same risk. The guide below applies across industries from banks to retailers to healthcare providers.</p><p><strong>🟢 Move First — Low Risk</strong></p><p><strong>Notifications and alerts</strong>: Ideal starting point. Standalone, easy to roll back.</p><p><strong>Customer-facing dashboards</strong>: Early win. Delivers visible value with minimal operational risk.</p><p><strong>Reporting and analytics</strong>: Read-only systems. No risk to live operations.</p><p><strong>🟡 Move Mid-Phase — Medium Risk</strong></p><p><strong>Product or service configuration</strong>: Test thoroughly first. Run in parallel before cutting over.</p><p><strong>Recommendation or scoring engines</strong>: Validate outputs against the old system before switching over.</p><p><strong>🔴 Move Last — High Risk</strong></p><p><strong>Customer data store</strong>: Only after all API boundaries are stable and proven.</p><p><strong>Core transaction processing</strong>: The last thing to move. Any failure here affects everyone.</p><p><strong>Settlement, fulfilment, or dispatch:</strong> Regulatory or operational sign-off is usually required first.</p><p><strong><em>The rule of thumb: if a problem in that system would make the front page of a newspaper, move it last.</em></strong></p><p>───────────────────────────────────────────────</p><h3>A Seven-Step Playbook</h3><h4>Step 1: Map out exactly what you have</h4><p>Before moving anything, spend time understanding the current system in detail. This means mapping out every process flow, data store, reporting pipeline, external integration, and dependency, however undocumented they might be.</p><p>You cannot safely move something you do not fully understand. This phase is often underestimated, but skipping it causes most migration failures in every industry.</p><h4>Step 2: Start with the safest things first</h4><p>Not everything needs to move at the same time. Begin with systems that are relatively standalone and lower risk, such as notifications, dashboards, analytics, or customer-facing informational features.</p><p>Leave the core operational systems, the ones that process transactions, move money, dispatch orders, or record clinical events, until later, when the team has built confidence and experience.</p><h4>Step 3: Build a smart routing layer</h4><p>Install a traffic controller between your users and your systems. This layer decides whether a given request goes to the old system or the new one without the user knowing or caring.</p><p>Think of it like a post office that quietly redirects letters to the right address, even as the address is changing. Every request is logged, which also helps with audit and compliance requirements in regulated industries.</p><h4>Step 4: Move data carefully — very carefully</h4><p>Data migration is the hardest part of any system upgrade. Customer records, transaction histories, clinical notes, product catalogues, and configuration data often sit in old databases with complex, undocumented structures.</p><p>The safest approach is to keep the old data in place while you build the new system, and use a live data-sync process to keep both in step. Only once you are confident in the new system do you cut over the data fully. Rushing this step risks data loss, compliance breaches, and harm to the people your organisation serves.</p><h4>Step 5: Run old and new systems side by side</h4><p>For critical processes, billing calculations, order fulfilment, clinical decision support, and credit scoring, run the old and new systems in parallel for a period. Compare their outputs regularly.</p><p>If the new system produces a different result, investigate why before switching over. In any high-stakes environment, a subtle error can affect thousands of people and attract regulatory attention. Parallel running is your safety net.</p><h4>Step 6: Move users in phases, not all at once</h4><p>When you are ready to switch users to the new system, do it gradually:</p><p>Phase 1 → Internal staff and test accounts<br>Phase 2 → Low-volume or low-risk users<br>Phase 3 → Mid-tier users and standard accounts<br>Phase 4 → High-volume, complex, or high-value accounts</p><p>Save your most critical users for last, by then the team will have seen and fixed most problems. Phased rollouts also give regulators, auditors, and leadership much greater confidence.</p><h4>Step 7: Build in monitoring and the ability to reverse</h4><p>Every migration phase must include the ability to go backwards quickly. This is not optional; it is an operational expectation in any serious organisation.</p><p>Use feature flags (simple on/off switches for functionality), real-time dashboards, and automated alerts. If something goes wrong at 2 am on a Tuesday, your team should be able to roll back within minutes, not hours. Plan for failure because at some point, something will go wrong.</p><p>───────────────────────────────────────────────</p><h3>The Honest Tradeoffs of the incremental (piece-by-piece) migration approach:</h3><p>This approach is safer, but it is not free. Running two systems at once costs money, creates complexity, and takes longer than a big-bang rewrite. Any honest engineering leader needs to acknowledge this to their board and their regulator.</p><h4>What you gain:</h4><p>✅ Customers stay unaffected throughout</p><p>✅ Regulators see a controlled, auditable process</p><p>✅ Problems are caught early and fixed cheaply</p><p>✅ Teams build confidence gradually</p><p>✅ You can deliver value at every stage</p><h4>What it costs:</h4><p>❌ Running two systems simultaneously costs more</p><p>❌ The process takes longer than a full rewrite</p><p>❌ Keeping data in sync between systems is complex</p><p>❌ Teams need to maintain two codebases temporarily</p><p>───────────────────────────────────────────────</p><h3>What Good Looks Like</h3><p>A mature organisation approaching this challenge well would typically say something like this to its leadership:</p><p>❝ We are recommending an incremental, phased migration away from our legacy platform. We will begin with lower-risk, customer-facing features — notifications, dashboards, and configuration — while leaving core transaction processing on the existing system. We will use a routing layer to manage coexistence, run parallel processing on all critical operations, and migrate user groups progressively. Each phase will have a tested rollback plan. We expect the full transition to take 18–24 months, with measurable improvements in reliability, cost, and capability delivered throughout. ❞</p><p>───────────────────────────────────────────────</p><h3>The Bigger Picture</h3><p>Upgrading a legacy system is never purely a technology problem. It is a business continuity problem, an operational problem, and a people problem all at once.</p><p>The organisations that succeed at this are not necessarily the ones with the best engineers or the biggest budgets. They are the ones that plan carefully, communicate honestly with their stakeholders, move in small, safe steps, and prioritise the people they serve above all else.</p><p>The organisations that users and customers trust most are not the ones that move fastest. They are the ones who prove, over time, that they can be relied upon even while changing.</p><p>And in enterprise technology, reliability almost always wins over ambition.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a551509bd3ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the Hype: A Practical Guide to LLM Architecture and Mental Models]]></title>
            <link>https://medium.com/@vijayaneraye/beyond-the-hype-a-practical-guide-to-llm-architecture-and-mental-models-inspired-by-andrej-c62c377a307b?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/c62c377a307b</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[llm-agent]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Mon, 06 Apr 2026 12:17:36 GMT</pubDate>
            <atom:updated>2026-04-06T12:23:29.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G9P2rTv5DGmfEnzVCn8Ocw.png" /></figure><p>This guide is a practical synthesis of my key takeaways from Andrej Karpathy’s <a href="https://www.youtube.com/watch?v=7xTGNNLPyMI">Deep Dive into LLMs</a>. It’s an attempt to take his world-class technical explanations and apply them to a consistent, real-life scenario to help builders understand the “why” behind the code</p><p>To make abstract technical concepts like “RAG” or “Tokens” stick, people need to see how they show up in real-world software.</p><p>Let’s break it down using a single, relatable example:<br> 👉 <em>You’re building a travel app.</em></p><h3>🧠 The Builder’s LLM Guide (With Real-World Examples)</h3><p>Here’s your practical, real-world guide to understanding the key concepts behind LLM development.</p><h4><strong>🎭 1. The Mental Model: The “Brilliant but Forgetful Actor”</strong></h4><p><strong>Concept:</strong> LLMs don’t “know” things; they generate text based on patterns.</p><p><strong>Real-Life Example:</strong> Imagine hiring a world-class Shakespearean actor. If you ask him to play a doctor, he will sound exactly like a doctor, use medical jargon, and act the part perfectly. But he doesn’t have a medical degree. If you ask him for a real prescription, he might give you one that looks real but is actually poisonous.</p><p><strong>The Lesson:</strong> Treat the LLM as a performer, not a professor. It’s brilliant at <em>sounding</em> like a knowledgeable expert, but you, as the builder, are responsible for verifying the underlying facts.</p><h4><strong>🧱 2. Tokens: The “Word Scraps”</strong></h4><p><strong>Concept:</strong> Models process “tokens” (chunks of characters), not words.</p><p><strong>Real-Life Example:</strong> Think of tokens like Lego bricks. To build the word “hospital,” you might need two bricks: “hos-” and “-pital.” LLMs operate and bill based on these bricks.</p><p><strong>Builder Tip:</strong> If your travel app sends a massive 50-page PDF of hotel reviews to the LLM every time a user asks “Is there a pool?”, you are paying for a giant Lego castle just to find one tiny blue brick.</p><p><strong>The Lesson:</strong> Be concise. Don’t pay for bricks you don’t need. Keep prompts sharp and to the point to keep performance high and costs low.</p><h4><strong>🏗️ 3. Architecture Choices (Through a Travel App)</strong></h4><p>The key to good LLM design is knowing which architecture fits your problem. Let’s use the travel app as our lab.</p><p><strong>✏️ A. Simple Prompting</strong></p><p><strong>The Scenario:</strong> You want the app to turn a user’s messy notes into a clean packing list.</p><p><strong>Real-Life Example:</strong></p><ul><li>User types: “Going to Hawaii, need beach gear and hiking stuff.”</li><li>→ LLM outputs: “1. Swimsuit, 2. Sunscreen, 3. Hiking boots.”</li></ul><p><strong>Why it works:</strong> No external data is needed. The LLM already “knows” what people take to Hawaii based on its vast training data.</p><p><strong>📚 B. RAG (Retrieval-Augmented Generation)</strong></p><p><strong>The Scenario:</strong> A user asks, “What are the specific cancellation policies for the ‘Blue Wave’ hotel I booked?”</p><p><strong>Real-Life Example:</strong> The LLM doesn’t know your specific booking details. So, your app:</p><ol><li><strong>Searches</strong> your database for the “Blue Wave” contract.</li><li><strong>Grabs</strong> the relevant text: “Cancellations allowed 48 hours prior.”</li><li><strong>Hands</strong> that text to the LLM and says: “Using this text, answer the user.”</li></ol><p><strong>Why it works:</strong> This method, called <strong>Retrieval-Augmented Generation</strong>, anchors the LLM to real-time, accurate, and private data. It prevents “hallucinations” (making up a fake policy).</p><blockquote><strong><em>Visualizing the Flow: Simple vs. RAG</em></strong></blockquote><blockquote>Here is a simple visualization of how RAG differs from simple prompting.</blockquote><blockquote><em>Simple Prompt: [User Question] —&gt; [LLM] —&gt; [Answer]</em></blockquote><blockquote><em>RAG: [User Question] —&gt; [Retrieve Data] —&gt; [User Question + Data] —&gt; [LLM] —&gt; [Answer]</em></blockquote><p><strong>🤖 C. Agents (Multi-step Systems)</strong></p><p><strong>The Scenario:</strong> User says, “Book me a flight to Tokyo under $800 and email my boss that I’ll be out.”</p><p><strong>Real-Life Example:</strong> In this case, the LLM acts as a Manager. It uses “tools” to perform actions.</p><ol><li>Uses a <strong>Flight Tool</strong> to check prices.</li><li>Uses a <strong>Gmail Tool</strong> to draft an email.</li><li><strong>Evaluates</strong> the results and asks the user for final confirmation.</li></ol><p><strong>Why it’s risky:</strong> This approach is powerful but complex. If the Flight Tool returns an error, the “Agent” might get confused and, in a worst-case scenario, send your boss an email that says “Tokyo $800” by mistake.</p><h4>🎯 4. Prompting: Roleplaying for Better Results</h4><p><strong>Concept:</strong> Don’t just ask the LLM a question; define the “who” and “how.”</p><p><strong>❌ Bad:</strong> “Give me a travel itinerary for Paris.” (Result: Generic list of tourist traps).</p><p><strong>✅ Good:</strong> “You are a local Parisian tour guide who hates crowds. Give me a 3-day itinerary focusing on hidden bakeries and quiet parks. Format it as a table.”</p><p><strong>Real-Life Analogy:</strong> It’s the difference between asking a stranger “Where should I eat?” vs. asking a focused Food Critic, “Where is the best sourdough in East London?”</p><h4>⚠️ 5. Failure Modes: The “Confidence Trap”</h4><p><strong>Concept:</strong> The two main ways LLMs fail: Hallucinations and Instruction Drift.</p><p><strong>Real-Life Example (Hallucination):</strong> You ask your travel bot for a hotel with a gym in London. It confidently suggests “The Royal Palace Hotel” — except that hotel doesn’t exist. It just sounds like a very plausible name for a London hotel.</p><p><strong>Real-Life Example (Instruction Drift):</strong> You tell the bot “Answer only in French.” After five minutes of chatting, the bot gets “tired,” forgets your rule, and starts answering in English again.</p><p><strong>The Fix:</strong> Use Guardrails. This is like having a “bouncer” at the exit of your app, checking every single response before the user sees it, ensuring it’s factually accurate and meets your criteria.</p><h4>🎼 6. The New Way to Build: Intent over Syntax</h4><p><strong>Concept:</strong> You are now a System Designer.</p><p><strong>The Old Way:</strong> You wrote precise code to check if a user’s date was valid:</p><p>if (date &lt; today) { error }.</p><p><strong>The New Way:</strong> You describe the goal: “Ensure the user chooses a future date for their flight. If they don’t, explain why politely in a helpful tone.”</p><p><strong>The Lesson:</strong> This new paradigm means you are no longer just a “coder”; you are a Conductor of a very talented, very fast, but very distracted orchestra. The challenge is no longer writing the right command, but framing the right intent.</p><h3>🎯 Final Thought</h3><p>Building with LLMs isn’t about memorizing APIs.</p><p>It’s about understanding:</p><ul><li>When to <strong>trust the model</strong></li><li>When to <strong>ground it with data</strong></li><li>When to <strong>control it with systems</strong></li></ul><p>You are no longer just a developer.</p><p>You are a <strong>conductor</strong> of a fast, powerful, slightly unpredictable orchestra.</p><h3>Resources</h3><ul><li><a href="https://www.youtube.com/watch?v=7xTGNNLPyMI"><strong>Deep Dive into LLMs like ChatGPT</strong></a> by Andrej Karpathy . An essential, comprehensive technical introduction that covers everything from tokenization to the reinforcement learning processes that make modern AI feel so “magical.”</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c62c377a307b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Domain-Driven Design: Understanding Domains]]></title>
            <link>https://medium.com/@vijayaneraye/domain-driven-design-understanding-domains-97902138948a?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/97902138948a</guid>
            <category><![CDATA[subdomain]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[ddd]]></category>
            <category><![CDATA[domain-driven-development]]></category>
            <category><![CDATA[core-domain]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Sun, 13 Apr 2025 09:44:26 GMT</pubDate>
            <atom:updated>2025-04-13T09:44:26.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*ijIwDBG-eid_5a1hOm-zdg.jpeg" /></figure><p>Check out <a href="https://medium.com/@vijayaneraye/introduction-to-domain-driven-design-ddd-130bbc81cdd6"><strong>Part 1</strong></a> if you haven’t read it yet before continuing with this blog.</p><p>This blog will delve into the critical role of domain analysis in software development. We’ll demonstrate how a thorough understanding of the business domain leads to solutions that are both technically robust and strategically aligned with organizational goals</p><h3>Business Domain</h3><p>A business domain is simply the main industry or area where a company does its work.</p><p>Knowing a company’s domains means understanding:</p><ul><li><strong>What the company does:</strong> The different areas of business and how they operate.</li><li><strong>Why they do it:</strong> The company’s purpose and goals.</li><li><strong>How they do it:</strong> The strategies and processes they use.</li></ul><h4>Why do we need to know the company’s domain?</h4><p>From a software development perspective, understanding a company’s domain is crucial for several key reasons:</p><ul><li><strong>Effective Solutions:</strong> You can’t build a good solution without fully grasping the problem it’s meant to solve.</li><li><strong>Context is Key:</strong> To effectively understand a problem, it’s essential to grasp the business context in which it arises..</li><li><strong>Business Value:</strong> You must align the software with the company’s strategy to deliver the intended business value.</li></ul><p>A company can operate in multiple business domains.</p><p>Many large companies operate across different business domains, each with distinct markets, expertise, and operations:</p><h4>Amazon</h4><ul><li><strong>Retail Domain</strong>: Online marketplace, logistics, fulfillment</li><li><strong>Cloud Computing Domain</strong>: AWS infrastructure and services</li><li><strong>Entertainment Domain</strong>: Prime Video, music streaming</li><li><strong>Hardware Domain</strong>: Echo devices, Kindle</li></ul><h4>Uber</h4><ul><li><strong>Rideshare Domain</strong>: Transportation services, driver network</li><li><strong>Food Delivery Domain</strong>: Uber Eats restaurant partnerships</li><li><strong>Freight Domain</strong>: Commercial shipping and logistics</li></ul><h4>Google</h4><ul><li><strong>Search Domain</strong>: Web indexing and search algorithms</li><li><strong>Advertising Domain</strong>: Ad network and placement</li><li><strong>Cloud Domain</strong>: Enterprise computing services</li><li><strong>Hardware Domain</strong>: Pixel phones, Nest products</li></ul><h4>Apple</h4><ul><li><strong>Hardware Domain</strong>: iPhones, Macs, wearables</li><li><strong>Software Domain</strong>: iOS, macOS, apps</li><li><strong>Services Domain</strong>: Apple Music, iCloud, Apple Pay</li></ul><h4>Disney</h4><ul><li><strong>Entertainment Domain</strong>: Movies, TV production</li><li><strong>Theme Park Domain</strong>: Disney parks worldwide</li><li><strong>Streaming Domain</strong>: Disney+ Platform</li></ul><h4>Toyota</h4><ul><li><strong>Automotive Domain</strong>: Car manufacturing and sales</li><li><strong>Financial Services Domain</strong>: Loans and leasing</li><li><strong>Robotics Domain</strong>: Industrial automation</li></ul><h3>What Is a Subdomain?</h3><p>A <strong>business domain</strong> represents the <strong>main industry</strong> or <strong>service</strong> a company operates in. However, to function efficiently, the company must break down its operations into <strong>smaller, specialized areas</strong>, which are called <strong>subdomains</strong>.</p><p>These are the fine-grained, specialized areas within the business domain. They are the specific activities that a company must perform to succeed.</p><p>In the context of software development and DDD, understanding the subdomains allows for the creation of software that correctly models the real-world business.</p><h3>Types of Subdomains</h3><p>In <strong>Domain-Driven Design (DDD)</strong>, subdomains can be classified into three main types based on their importance and role within the business. These are:</p><ol><li><strong>Core Domain</strong></li><li><strong>Supporting Subdomain</strong></li><li><strong>Generic Subdomain</strong></li></ol><h4><em>Identifying Domain:</em></h4><blockquote><em>Ask: Does this feature provide a competitive advantage?</em></blockquote><blockquote><em>If yes, it’s a </em><strong><em>Core Domain.</em></strong></blockquote><blockquote><em>Ask: Is this feature necessary but not unique?</em></blockquote><blockquote><em>If yes, it’s a Supporting Subdomain.</em></blockquote><blockquote><em>Ask: Can we use a third-party tool for this?</em></blockquote><blockquote><em>If yes, it’s a Generic Subdomain.</em></blockquote><p>Let’s break each type down in detail, along with how to <strong>identify them</strong> using the questions you’ve provided:</p><h4><strong>1. Core Subdomain:</strong></h4><p>This is the most valuable and critical part of the business domain. It’s what gives the company its competitive edge.</p><p><strong>Identifying Question:</strong></p><blockquote><em>Does this feature provide a competitive advantage? </em><strong>If Yes:</strong> It’s a <strong>Core Domain</strong>.</blockquote><p><strong>Key Characteristics:</strong></p><ul><li>Directly impacts the company’s <strong>success</strong>.</li><li>Holds the <strong>most strategic importance</strong>.</li><li>It is often the <strong>focus</strong> of the company’s expertise and innovation.</li></ul><p><strong>Examples</strong>:</p><p>For <strong>Tesla</strong>, <strong>battery technology</strong> and <strong>electric vehicle design</strong> are the core domains because they give Tesla a competitive edge over other car manufacturers.</p><ul><li><strong>Amazon’s</strong> Recommendation Engine</li><li><strong>Airbnb’s </strong>Pricing Algorithm</li><li><strong>Uber’s</strong> Ride Matching System</li></ul><h4><strong>2. Supporting Subdomain:</strong></h4><p>The <strong>Supporting Subdomain</strong> provides <strong>the necessary functionality</strong> but does not offer a <strong>competitive advantage</strong>. It is important for the company’s operations but can be found in most businesses within the same industry. These subdomains enable the core domain to function but are <strong>not unique</strong>.</p><p><strong>Identifying Question:</strong></p><blockquote><em>Is this feature necessary but not unique? </em><strong><em>If Yes:</em></strong><em> It’s a </em><strong><em>Supporting Subdomain</em></strong><em>.</em></blockquote><p><strong>Key Characteristics:</strong></p><ul><li>Important for the company’s <strong>operations</strong>, but not what sets the business apart.</li><li>Can often be <strong>outsourced</strong> or <strong>standardized</strong>.</li><li>Provides <strong>support</strong> for the core domain.</li></ul><blockquote><strong>Core subdomains</strong> must be developed <strong>in-house</strong> because they represent the <strong>competitive advantage</strong> of the business. If a company were to buy or adopt a third-party solution for these subdomains, its competitors could also use the same solution, which would weaken the company’s unique position in the market. Therefore, core subdomains should be <strong>unique and tailored</strong> to the company’s specific needs and cannot be easily replicated by others.</blockquote><p><strong>Examples</strong>:</p><ul><li><strong>E-commerce:</strong> Shipping and inventory management.</li><li><strong>Healthcare:</strong> Appointment scheduling and patient record management.</li><li><strong>Any Company:</strong> Employee onboarding.</li></ul><h4><strong>3. Generic Subdomain:</strong></h4><p>The <strong>Generic Subdomain</strong> refers to features that are <strong>common</strong> across industries and do not provide any <strong>unique value</strong>. These subdomains can typically be <strong>outsourced</strong> or handled with <strong>third-party tools</strong>. They don’t need to be developed in-house as they are <strong>standard solutions</strong>.</p><p><strong>Identifying Question:</strong></p><blockquote><em>Can we use a third-party tool for this? </em><strong>If Yes:</strong> It’s a <strong>Generic Subdomain</strong>.</blockquote><p><strong>Key Characteristics:</strong></p><ul><li>Not specific to the company or industry.</li><li>Typically, it can be <strong>outsourced</strong> or handled by <strong>third-party solutions</strong>.</li><li>No strategic importance for differentiation</li></ul><p><strong>Example</strong>:</p><ul><li><strong>Payment Processing</strong> (e.g., using PayPal, Stripe, or any third-party provider)</li><li><strong>Authentication &amp; Authorization</strong> (e.g., using OAuth, SSO services)</li><li><strong>Email &amp; Notification Systems</strong> (e.g., Mailgun, Twilio)</li></ul><h3><strong>Understanding Domains: Practices</strong></h3><p>Here are some key practices to help you gain a deep understanding of the company’s domain:</p><h4><strong>1. Collaborative Domain Exploration:</strong></h4><ul><li><strong>Domain Expert Interviews:</strong> Conduct structured conversations.</li><li><strong>Workshops &amp; Brainstorming:</strong> Facilitate group sessions.</li><li><strong>Event Storming:</strong> Visualize domain events.</li></ul><h4><strong>2. Documenting Domain Knowledge:</strong></h4><ul><li><strong>Ubiquitous Language Glossary</strong>: Create a shared vocabulary.</li><li><strong>Domain Models</strong>: Build visual representations.</li><li><strong>Context Maps (DDD): </strong>Visualize bounded context relationships.</li><li><strong>Business Rules Documentation:</strong> Captures the company’s rules.</li></ul><h4><strong>3. Observing and Analyzing Processes:</strong></h4><ul><li><strong>Shadowing Domain Experts:</strong> Observe real-world tasks.</li><li><strong>Analyzing Existing Documents:</strong> Review manuals and reports.</li><li><strong>Analyzing Legacy Systems: </strong>Study existing systems.</li></ul><h4><strong>4. Continuous Learning &amp; Feedback:</strong></h4><ul><li>Iterative Exploration: Refine understanding over time.</li><li>Regular Feedback Loops: Validate models with experts.</li><li>Domain Expert Involvement: Include development experts.</li></ul><h4><strong>5. Utilizing Tools:</strong></h4><ul><li><strong>Modeling Tools:</strong> Create and maintain domain models.</li><li><strong>Collaboration Platforms: </strong>Facilitate communication.</li><li><strong>Knowledge Management Systems: </strong>Store and organize information.</li></ul><h4>References</h4><p><a href="https://learning.oreilly.com/library/view/learning-domain-driven-design/9781098100124/">Learning Domain-Driven Design</a> by <a href="https://learning.oreilly.com/search/?query=author%3A%22Vlad%20Khononov%22&amp;sort=relevance&amp;highlight=true">Vlad Khononov</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97902138948a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Domain-Driven Design (DDD)]]></title>
            <link>https://medium.com/@vijayaneraye/introduction-to-domain-driven-design-ddd-130bbc81cdd6?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/130bbc81cdd6</guid>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[domain-driven-development]]></category>
            <category><![CDATA[ddd]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Mon, 31 Mar 2025 11:02:47 GMT</pubDate>
            <atom:updated>2025-04-13T09:47:26.496Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*PqLsF0k87y2IceCV.jpg" /></figure><p>Recently, I delved into Domain-Driven Design (DDD), a methodology that has significantly influenced my approach to software development. Based on my readings and hands-on experience, I want to share my understanding of DDD and how it can transform how we build software.</p><p>I hope my perspective on DDD will provide some insights and inspire you to explore this methodology.</p><h4>What is Domain-Driven Design(DDD)?</h4><ul><li>Domain-Driven Design (DDD) is not a specific technology or not a framework but rather a set of principles and patterns.</li><li>Domain-Driven Design (DDD) is a way to develop software by understanding and modeling the business it supports.</li><li>DDD aims to make software that matches real-world business processes.</li><li>DDD emphasizes collaboration between developers and domain experts to build a deep understanding of the business domain.</li></ul><h4>Where is the DDD useful?</h4><ul><li>DDD is useful for complex business areas with detailed and changing rules.</li><li>It’s less helpful for basic applications or systems with more technical than business challenges.</li></ul><h4>Why DDD:</h4><ul><li><strong>Matches business needs</strong>: DDD connects software with business goals.By focusing on the core domain and its logic, developers can create solutions that truly address business needs.</li><li><strong>Handles complexity: </strong>DDD simplifies complicated business areas by dividing them into smaller, manageable parts (bounded contexts), making the system easier to understand, develop, and maintain.</li><li><strong>Boosts communication: </strong>DDD creates a common language to reduce misunderstandings. This reduces misunderstandings and ensures that the software accurately reflects the business requirements.</li><li><strong>Makes software easy to maintain: </strong>DDD designs software that fits the business, making changes easier.</li><li><strong>Complex Problem Solving:</strong> DDD highlights the most important parts of the business.</li></ul><p>The domain-driven design (DDD) methodology has two main parts: strategic design and tactical design.</p><h4>1. Strategic design:</h4><ul><li>Strategic design is about “what” to build and “where” to draw the lines.</li><li>Strategic design is about the “big picture.</li><li>It deals with the high-level architecture of the system.</li><li>It focuses on understanding the overall business domain, its complexities, and how to divide it into manageable parts.</li><li>It’s concerned with defining the boundaries of different parts of the system and how they interact.</li></ul><h4><strong>Key Concepts:</strong></h4><ul><li><strong>Core Domain:</strong> Supporting Subdomains and Generic Subdomains: Identifying the core, supporting, and generic subdomains of the business.</li><li><strong>Bounded Contexts:</strong> Defining explicit boundaries within which a particular domain model applies. This helps manage complexity by breaking down the domain into manageable parts.</li><li><strong>Context Maps:</strong> Visualizing the relationships and interactions between different bounded contexts. This ensures that interactions between different parts of the system are well-defined.</li><li><strong>Ubiquitous Language: </strong>A Ubiquitous Language is a shared vocabulary used by developers, domain experts, and stakeholders within a bounded context. It ensures that everyone uses the same terminology to avoid misunderstandings and inconsistencies.</li></ul><h4>2. Tactical design:</h4><ul><li>Tactical design is about “how” to build it within those lines.</li><li>Tactical Design focuses on the implementation details within those parts.</li><li>Tactical Design aims to implement the domain model effectively within the defined boundaries.</li><li>Tactical Design is about structuring the actual code to reflect the business domain.</li></ul><h4>Key Concepts:</h4><ul><li><strong>Entities:</strong> Objects with a unique identity that change over time.</li><li><strong>Value Objects:</strong> Value Objects do not have an identity and are defined only by their attributes. They are immutable and often used to group related data.</li><li><strong>Aggregates:</strong> An Aggregate is a cluster of entities and value objects that should be treated as a single unit</li><li><strong>Repositories: </strong>Mechanisms for persisting and retrieving domain objects.</li><li><strong>Domain Services:</strong> Some business logic doesn’t belong to a specific entity or value object. Domain Services contain such logic while keeping the domain model clean.</li><li><strong>Domain Events:</strong> A Domain Event represents something important in the business domain. Events help in decoupling different parts of the system.</li></ul><p>In the next part, we’ll examine strategic design, which is crucial for defining the boundaries and relationships within your domain.</p><p>To read the next section, <a href="https://medium.com/@vijayaneraye/domain-driven-design-understanding-domains-97902138948a">click here</a>.</p><h4>References</h4><p><a href="https://learning.oreilly.com/library/view/learning-domain-driven-design/9781098100124/">Learning Domain-Driven Design</a> by <a href="https://learning.oreilly.com/search/?query=author%3A%22Vlad%20Khononov%22&amp;sort=relevance&amp;highlight=true">Vlad Khononov</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=130bbc81cdd6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Important Features — Java 18, Java 19, Java 20,Java 21, Java 23 and Java 22]]></title>
            <link>https://medium.com/@vijayaneraye/important-features-java-18-java-19-java-20-java-21-java-23-and-java-22-742d1527da7b?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/742d1527da7b</guid>
            <category><![CDATA[java21]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Sun, 23 Mar 2025 12:06:15 GMT</pubDate>
            <atom:updated>2025-03-28T00:01:42.217Z</atom:updated>
            <content:encoded><![CDATA[<h3>Important Features — Java 18, Java 19, Java 20, Java 21, Java 22, and Java 23</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jwdaRuyYMjXjh_rZ.jpeg" /></figure><h4><strong>In this post, we’ll go over some </strong>important<strong> features that Java 19, Java 20, and Java 21 have added in recent years.</strong></h4><p>In my previous post, I listed all important features of the previous Java versions, if you’re interested, click this here</p><p><a href="https://medium.com/@vijayaneraye/important-features-java-9-java-10-java-11-java-12-java13-java-14-java-15-java-16-java-17-650420ee7337">Important Features — Java 9, Java 10, Java 11, Java 12, Java13, Java 14, Java 15, Java 16, Java 17</a></p><h4>Java 18</h4><h4>— UTF-8 by Default</h4><p>Before Java 18, the default charset varied depending on the operating system. The operating system determined the default character encoding which resulted in file reading/writing inconsistencies across platforms/</p><p>Before:</p><pre>//Befor java 18<br>import java.nio.charset.Charset;<br><br>public class CheckCharset {<br>    public static void main(String[] args) {<br>        System.out.println(Charset.defaultCharset()); // Different on Windows &amp; Linux<br>    }<br>}<br><br>output: Windows defaulted to Windows-1252<br><br>Linux/macOS often used UTF-8</pre><p>After:</p><p>From Java 18 onwards, <strong>UTF-8 is the default charset</strong>, ensuring consistency across platforms.</p><pre>import java.nio.charset.Charset;<br><br>public class CheckCharset {<br>    public static void main(String[] args) {<br>        System.out.println(Charset.defaultCharset()); // Always UTF-8<br>    }<br>}<br><br>Output: UTF-8</pre><h4>Java 19, Java 20:</h4><p>In Java 19, Java 20 was mostly concerned with improving and enhancing preview features from earlier iterations. As a result, there weren’t many entirely new, conventionally defined features. Rather, it enhanced and improved upon aspects that were previously in preview form.</p><h4>Java 21:</h4><p>Java 21 introduced several new features and enhancements, It includes several <strong>finalized</strong> features that were previously in preview in Java 17, 18, 19, and 20. significantly impacting Java development. Here are some of the key finalized features, with explanations and examples:</p><h4>— Record Patterns</h4><p>This feature enhances the ability to destructure record values. This is very useful when working with complex data structures.</p><p>Before:</p><p>Pattern matching with instanceof required explicit typecasting.</p><pre>public void print(Object o) {<br>    if (o instanceof Double) {<br>        Double d = (Double) o;<br>        System.out.println(&quot;double = &quot; + d);<br>    }<br>}</pre><pre>record Person(String name, int age) {}<br><br>public class RecordPatternExample {<br>    public static void main(String[] args) {<br>        Object obj = new Person(&quot;Alice&quot;, 25);<br>        if (obj instanceof Person p) { // Manual extraction<br>            System.out.println(&quot;Name: &quot; + p.name());<br>            System.out.println(&quot;Age: &quot; + p.age());<br>        }<br>    }<br>}</pre><p>After:</p><p>Record patterns allow for more concise and readable code.</p><pre>public void print(Object o) {<br>    if (o instanceof Double d) {<br>        System.out.println(&quot;double = &quot; + d);<br>    }<br>}</pre><pre>record Person(String name, int age) {}<br><br>public class RecordPatternExample {<br>    public static void main(String[] args) {<br>        Object obj = new Person(&quot;Alice&quot;, 25);<br>        if (obj instanceof Person(String name, int age)) { // Decomposing directly<br>            System.out.println(&quot;Name: &quot; + name);<br>            System.out.println(&quot;Age: &quot; + age);<br>        }<br>    }<br>}</pre><h4>— Pattern Matching for switch</h4><p>To enhance switch expressions and statements with pattern matching, allowing for more complex and concise data-oriented queries.</p><p>Before:</p><p>switch statements were limited to simple value comparisons. Complex logic requires lengthy if-else chains.</p><pre>Object obj = &quot;example&quot;;<br>String result;<br>if (obj instanceof String s) {<br>    if (s.length() &gt; 5) {<br>        result = s.toUpperCase();<br>    } else {<br>        result = s.toLowerCase();<br>    }<br>} else {<br>    result = &quot;other&quot;;<br>}</pre><p>After:</p><p>Pattern matching allows for more expressive switch statements, making code more readable and maintainable.</p><pre>Object obj = &quot;example&quot;;<br>String result = switch (obj) {<br>    case String s when s.length() &gt; 5 -&gt; s.toUpperCase();<br>    case String s -&gt; s.toLowerCase();<br>    default -&gt; &quot;other&quot;;<br>};</pre><h4>— Sequenced Collections:</h4><p>Introduce new interfaces representing collections with a defined encounter order</p><p>Before:</p><pre>List&lt;String&gt; list = new ArrayList&lt;&gt;(Arrays.asList(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;));<br>String first = list.get(0);<br>String last = list.get(list.size() - 1);//// Access by index possible<br><br>Set&lt;String&gt; set = new LinkedHashSet&lt;&gt;(Set.of(&quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;));<br>System.out.println(set.iterator().next()); // No direct access</pre><p>After:</p><pre><br>SequencedCollection&lt;String&gt; list = new ArrayList&lt;&gt;(List.of(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;));<br>System.out.println(list.getFirst()); // &quot;A&quot;<br>System.out.println(list.getLast());  // &quot;C&quot;<br><br>SequencedSet&lt;String&gt; set = new LinkedHashSet&lt;&gt;(Set.of(&quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;));<br>System.out.println(set.getFirst()); // &quot;X&quot;<br>System.out.println(set.getLast());  // &quot;Z&quot;</pre><h4>Java 22:</h4><h4>— Unnamed Variables and Patterns</h4><p>Enhance code readability when variable declarations or nested patterns are required but not used.</p><p>Before:</p><p>Developers had to declare variables even if they weren’t used, leading to potentially cluttered code.</p><pre>void process(Map&lt;String, Integer&gt; map) {<br>    map.forEach((key, value) -&gt; System.out.println(&quot;Key: &quot; + key));<br>}<br>//Here, the lambda parameter valueis declared but not utilized.​</pre><p>After:</p><p>The underscore character (_) can be used to denote unused variables or patterns.</p><pre>void process(Map&lt;String, Integer&gt; map) {<br>    map.forEach((key, _) -&gt; System.out.println(&quot;Key: &quot; + key));<br>}<br>//In this example the value of the map is not used, so it is declared as &quot;_&quot;.</pre><h4>Java 23</h4><p>Same as Java 19 and Java 20, Java 23 was mostly concerned with improving and enhancing preview features from earlier iterations</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=742d1527da7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of C Programming for Beginners- Operators in C (Part-IV)]]></title>
            <link>https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-operators-in-c-part-iv-2253cf7357e9?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/2253cf7357e9</guid>
            <category><![CDATA[c-programming-assignment]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[c-programming-language]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[c-programming-help]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Tue, 26 Dec 2023 14:47:56 GMT</pubDate>
            <atom:updated>2023-12-26T14:58:24.186Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*as6Mghi7WSoHmDZZ89ErjA.jpeg" /></figure><p>Operators are symbols in the C programming language that stand for operations that can be executed on one or more operands. These are the fundamental elements of C programming. We will learn about all of C’s built-in operations with in this post.</p><p>Before moving forward with Operators in C language, we recommend you to read the three parts of the preceding post if you haven’t already.</p><ol><li><a href="https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-1-9ccabb0c3e6c">C Programming language Introduction</a></li><li><a href="https://medium.com/p/49860adf104f">Variables in C Programming language</a></li><li><a href="https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-iii-4143b1b37691">Data Types in C Programming Language</a></li></ol><h3>Introduction to Operators in C Language</h3><ul><li>The C language supports a rich set of built-in operators.</li><li>An operator is a symbol that tells the compiler to perform a certain operation (arithmetic, comparison, etc.) using the values provided along with the operator.</li></ul><h3>Type of C Operators</h3><p>C operators fall into the following categories:</p><ol><li>Arithmetic operators</li><li>Relational operators</li><li>Logical operators</li><li>Bitwise operators</li><li>Assignment operators</li><li>Conditional operators</li><li>Special operators</li></ol><p>Before going into the details of each of these operator types, it is important to understand these categories of operators as well.</p><ul><li><strong>Unary</strong> operators : Unary operators operate on a single input (or single value)</li><li><strong>Binary</strong> operators: Binary operators operate on two input values</li><li><strong>Ternary</strong> operators : The <strong>Ternary</strong> operator (?:) operates on three input values</li></ul><p>Let’s explore each of these operator types individually, identifying if they are <strong>Ternary</strong>, <strong>Binary</strong>, or <strong>Unary</strong> operators with samples code.</p><h4>1. Arithmetic Operations in C</h4><p>The arithmetic operators in C language help a user perform the mathematical operations as well as the arithmetic operations in a program, such as subtraction (-), addition (+), division (/), multiplication (*), the remainder of division (%), decrement (–), increment (++).</p><p><strong>Binary Arithmetic Operators</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*Eed8EzebSlhnSjo_T6cI3w.png" /><figcaption>binary arithmetic operations</figcaption></figure><p><strong>Example:</strong></p><pre>#include &lt;stdio.h&gt;<br><br>int main() {<br>  int a = 10;<br>  int b = 5;<br><br>  // Addition<br>  int sum = a + b;<br><br>  // Subtraction<br>  int difference = a - b;<br><br>  // Multiplication<br>  int product = a * b;<br><br>  // Division<br>  int quotient = a / b;<br><br>  // Modulo<br>  int remainder = a % b;<br><br>  // Print the results<br>  printf(&quot;Sum: %d\n&quot;, sum);<br>  printf(&quot;Difference: %d\n&quot;, difference);<br>  printf(&quot;Product: %d\n&quot;, product);<br>  printf(&quot;Quotient: %d\n&quot;, quotient);<br>  printf(&quot;Remainder: %d\n&quot;, remainder);<br><br>  return 0;<br>}</pre><pre>Output:<br>  Sum: 15<br>  Difference: 5<br>  Product: 50<br>  Quotient: 2<br>  Remainder: 0</pre><p><strong>Unary Arithmetic Operators</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*uK1uMCUJHenn-pjrGY_uwQ.png" /><figcaption><strong>Unary Arithmetic Operators</strong></figcaption></figure><p><strong>Prefix and Postfix Increment/ Decrement Operators</strong></p><p><strong>Prefix</strong></p><p>— When we use the operator before the available variable in a program as a prefix, it is known as a prefix operator.</p><p>In a prefix <strong>increment</strong>(++) operator, the program first adds 1 and then assigns the resultant value to that variable.</p><p>While in a prefix <strong>decrement</strong>( — ) operator, the program first subtracts 1 and then assigns the resultant value to the variable. For example, ++a and — a</p><p>Example</p><pre>#include &lt;stdio.h&gt;<br><br>int main() {<br><br>   int a = 10, b = 20, c, d;<br><br>   /* <br>      Using prefix increment operator<br>   */<br>   printf(&quot;Incrementing value of a = %d \n&quot;, ++a);<br><br>   /* <br>      Using prefix decrement operator<br>   */<br>   printf(&quot;Decrementing value of b = %d \n&quot;, --b);<br><br>   return 0;<br><br>}</pre><pre>Output:<br>Incrementing value of a = 11 <br>Decrementing value of b = 19 </pre><p><strong>Postfix</strong></p><p>— When we use the operator after the available variable in a program as a postfix, it is known as a postfix operator.</p><p>In a postfix <strong>increment</strong> (++) operator, the program first assigns the value to the variable, then adds 1, and then assigns the resultant value.</p><p>While in a postfix <strong>decrement</strong>( — ) operator, the program first assigns the value to the variable, then subtracts 1, and then assigns the resultant value. For example, a++ and a — .</p><p>Example:</p><pre>#include &lt;stdio.h&gt;<br><br>int main() {<br><br>   int a = 10, b = 20, c, d;<br><br>   // first print value of a, then decrement a<br>   printf(&quot;Decrementing value of a = %d \n&quot;, a--);<br>   printf(&quot;Value of a = %d \n&quot;, a);<br><br>   // first print value of b, then increment b<br>   printf(&quot;Incrementing value of b = %d \n&quot;, b++);<br>   printf(&quot;Value of b = %d \n&quot;, b);<br><br>   return 0;<br><br>}</pre><pre>output:<br>Decrementing value of a = 10<br>Value of a = 9<br>Incrementing value of b = 20<br>Value of b = 21</pre><h4>2. Relational operators in C</h4><p>The relational operators in C are used to compare the values available for two given operands(inputs). All these operators are binary operators that return true or false values as the result of comparison</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*0TkCmTWyWd3ewtqoOnn2GQ.png" /><figcaption>Relational operators in C</figcaption></figure><p>Examples:</p><pre>#include &lt;stdio.h&gt;<br><br>int main() {<br>    int a = 5, b = 3;<br>    int examScore = 75;<br>    int passingScore = 60;<br>    <br>    if (a &gt; b) {<br>        printf(&quot;a is greater than b \n&quot;);<br>    } <br><br>    if (a &lt; b) { <br>        printf(&quot;a is not greater than b \n&quot;);<br>    }<br>    <br>   if (a == b) {<br>        printf(&quot;a is equal to b \n&quot;);<br>    }<br><br>    if (a != b) {<br>        printf(&quot;a is not equal to b \n&quot;);<br>    }<br><br>   if (examScore &gt;= passingScore) {<br>        printf(&quot;Congratulations! You have passed the exam.\n&quot;);<br>    } else {<br>        printf(&quot;Sorry, you have not passed the exam.\n&quot;);<br>    }<br>    <br>    return 0;<br>}</pre><pre>output:<br>a is greater than b <br>a is not equal to b <br>Congratulations! You have passed the exam.</pre><h4>3. Logical Operators</h4><p>Logical Operators in C are essential for making decisions based on multiple conditions. They allow us to combine and test these conditions to decide the flow of a program</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*YWAD8H2mGDj3yg5Xdash_w.png" /><figcaption>Logical Operators</figcaption></figure><ol><li>With the <strong>AND</strong> operator, only <strong>if both operands are true</strong>, the <strong>result is true</strong>.</li><li>With the <strong>OR</strong> operator, if a <strong>single operand is true</strong>, then the <strong>result will be true</strong>.</li><li>The <strong>NOT</strong> operator <strong>changes true to false</strong>, and <strong>false to true</strong>.</li></ol><p>Example:</p><pre>#include &lt;stdio.h&gt;<br><br>int main() {<br><br>   int a = 10;<br>   int b = 20;<br><br>  if (a == 10 &amp;&amp; b == 20) {<br>    printf(&quot;Both conditions are true.\n&quot;);<br>  }<br><br>  if (a == 10 || b == 30) {<br>    printf(&quot;At least one condition is true.\n&quot;);<br>  }<br>  <br>  if (!(a == 20)) {<br>    printf(&quot;The condition is false.\n&quot;);<br>  }<br>  <br>   return 0;<br><br>}</pre><pre>output:<br>Both conditions are true.<br>At least one condition is true.<br>The condition is false.</pre><h4>4. Bitwise Operators in C</h4><p>Bitwise operators are used to manipulate bits in various different ways. They are equivalent to how we use mathmatical operations like (+, -, /, *) among numbers, similarly we use bitwise operators like (|, &amp;, ^, &lt;&lt;, &gt;&gt;, ~) among bits.</p><p><strong>6 Bitwise operators in C</strong></p><p>There are 6 bitwise operators in C language. They are</p><ul><li>AND (&amp;)</li><li>OR (|)</li><li>XOR (^)</li><li>COMPLEMENT (~)</li><li><a href="https://www.scaler.com/topics/what-is-left-shift-operator-in-c/">Left Shift (&lt;&lt;)</a></li><li>Right Shift (&gt;&gt;)</li></ul><p><strong>Example:</strong></p><pre><br>#include &lt;stdio.h&gt;<br><br>main() {<br><br>   unsigned int a = 60; /* 60 = 0011 1100 */  <br>   unsigned int b = 13; /* 13 = 0000 1101 */<br>   int c = 0;           <br><br>   c = a &amp; b;       /* 12 = 0000 1100 */ <br>   printf(&quot;Line 1 - Value of c is %d\n&quot;, c );<br><br>   c = a | b;       /* 61 = 0011 1101 */<br>   printf(&quot;Line 2 - Value of c is %d\n&quot;, c );<br><br>   c = a ^ b;       /* 49 = 0011 0001 */<br>   printf(&quot;Line 3 - Value of c is %d\n&quot;, c );<br><br>   c = ~a;          /*-61 = 1100 0011 */<br>   printf(&quot;Line 4 - Value of c is %d\n&quot;, c );<br><br>   c = a &lt;&lt; 2;     /* 240 = 1111 0000 */<br>   printf(&quot;Line 5 - Value of c is %d\n&quot;, c );<br><br>   c = a &gt;&gt; 2;     /* 15 = 0000 1111 */<br>   printf(&quot;Line 6 - Value of c is %d\n&quot;, c );<br>}</pre><pre>output:<br>  Line 1 - Value of c is 12<br>  Line 2 - Value of c is 61<br>  Line 3 - Value of c is 49<br>  Line 4 - Value of c is -61<br>  Line 5 - Value of c is 240<br>  Line 6 - Value of c is 15</pre><h4>5. Assignment Operators in C</h4><p>We use the assignment operators in c for assigning any value to the given variable.</p><p>In C, there are 11 assignment operators :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*fxbqSbfzPIu5kFdHBfCoAQ.png" /><figcaption>Assignment Operators in C</figcaption></figure><p>Example:</p><pre>// C program to demonstrate<br>// working of Assignment operators<br><br>#include &lt;stdio.h&gt;<br><br>int main()<br>{<br><br> // Assigning value 10 to a<br> // using &quot;=&quot; operator<br> int a = 10;<br> printf(&quot;Value of a is %d\n&quot;, a);<br><br> // Assigning value by adding 10 to a<br> // using &quot;+=&quot; operator<br> a += 10;<br> printf(&quot;Value of a is %d\n&quot;, a);<br><br> // Assigning value by subtracting 10 from a<br> // using &quot;-=&quot; operator<br> a -= 10;<br> printf(&quot;Value of a is %d\n&quot;, a);<br><br> // Assigning value by multiplying 10 to a<br> // using &quot;*=&quot; operator<br> a *= 10;<br> printf(&quot;Value of a is %d\n&quot;, a);<br><br> // Assigning value by dividing 10 from a<br> // using &quot;/=&quot; operator<br> a /= 10;<br> printf(&quot;Value of a is %d\n&quot;, a);<br><br> return 0;<br>}</pre><pre>Output:<br>Value of a is 10<br>Value of a is 20<br>Value of a is 10<br>Value of a is 100<br>Value of a is 10</pre><h4>6. Conditional Operators (or Ternary Operator)</h4><p>The conditional operator is the only ternary operator in C++.</p><p>The <strong>basic syntax</strong> for using ternary operator is:</p><pre>(Expression1)? Expression2 : Expression3;</pre><p>Here is how it works:</p><ul><li>The question mark ? in the syntax represents the if part.</li><li>The first expression (expression 1) returns either <strong>true</strong> or <strong>false</strong>, based on which it is decided whether (expression 2) will be executed or (expression 3)</li><li>If (expression 1) returns <strong>true</strong> then the (expression 2) is executed.</li><li>If (expression 1) returns <strong>false</strong> then the expression on the right side of : i.e (expression 3) is execute</li></ul><pre>#include &lt;stdio.h&gt;<br><br>int main() {<br><br>   int a = 20, b = 20, result;<br><br>   /* Using ternary operator<br>      - If a == b then store a+b in result<br>      - otherwise store a-b in result<br>   */<br>   result = (a==b)?(a+b):(a-b);<br><br>   printf(&quot;result = %d&quot;,result);<br><br>   return 0;<br><br>}</pre><pre>output:<br>result = 40</pre><h4>7. Other C Operators</h4><p>Apart from arithmetic, relational, logical, assignment, etc. operators, C language uses some other operators such as:</p><ol><li>sizeof operator</li><li>&amp; operator</li><li>* operator</li><li>The . (dot) and -&gt; (arrow) operators</li><li>[] operator, etc.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kYLb3p_JKcgrqKksfV6w3A.png" /><figcaption>Other C Operators</figcaption></figure><p><strong>Example of Other C Operators</strong></p><pre>// C Program to demonstrate the use of Misc operators <br>#include &lt;stdio.h&gt; <br><br>int main() <br>{ <br> // integer variable <br> int num = 10; <br> int* add_of_num = # <br><br> printf(&quot;sizeof(num) = %d bytes\n&quot;, sizeof(num)); <br> printf(&quot;&amp;num = %p\n&quot;, &amp;num); <br> printf(&quot;*add_of_num = %d\n&quot;, *add_of_num); <br> printf(&quot;(10 &lt; 5) ? 10 : 20 = %d\n&quot;, (10 &lt; 5) ? 10 : 20); <br> printf(&quot;(float)num = %f\n&quot;, (float)num); <br><br> return 0; <br>}</pre><pre>Output<br><br>sizeof(num) = 4 bytes<br>&amp;num = 0x7ffe2b7bdf8c<br>*add_of_num = 10<br>(10 &lt; 5) ? 10 : 20 = 20<br>(float)num = 10.000000<br></pre><h3>Conclusion</h3><p>In this article, the points we learned about the operator are as follows:</p><ul><li>Different types of operation in C.</li><li>There are six types of operators, Arithmetic Operators, Relational Operators, Logical Operators, Bitwise Operators, Assignment Operators, and Miscellaneous Operators.</li><li>Operators can also be of type Unary, Binary, and Ternary according to the number of operand/value they are using.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2253cf7357e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of C Programming for Beginners- Data types in C (Part-III)]]></title>
            <link>https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-iii-4143b1b37691?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/4143b1b37691</guid>
            <category><![CDATA[c-programming-help]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[c-programming-language]]></category>
            <category><![CDATA[c-programming-assignment]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Tue, 26 Dec 2023 12:27:47 GMT</pubDate>
            <atom:updated>2023-12-27T11:16:46.466Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*as6Mghi7WSoHmDZZ89ErjA.jpeg" /></figure><p>This tutorial is meant for beginners. You get an overview of the basic concepts of data types in C programming language</p><p>Before moving on to this section, please read the two parts of the preceding post if you haven’t already.</p><ol><li><a href="https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-1-9ccabb0c3e6c">C Programming language Introduction</a></li><li><a href="https://medium.com/p/49860adf104f">Variables in C Programming language</a></li></ol><p>The C programming language is a strongly <strong>statically typed language.</strong></p><p>In <strong>statically typed languages,</strong> you need to explicitly declare your variables to be of a certain data type. That way the compiler knows during compilation time if the variable is able to perform the actions it was set out and requested to do.</p><h3>Computer memory in brief (bits vs. bytes):</h3><ul><li>All data in a computer is stored in memory as a number. Bits are stored in computer memory using electronic circuits that representing the binary values 0 and 1.</li><li>Bits and Bytes are both units of computer memory.</li><li>A bit is the smallest unit of memory, while a byte is larger.</li><li>A bit is short for<strong><em> binary digit.</em></strong></li><li>1 byte = 8 bits</li></ul><h3>What are Data Types in C Language?</h3><p>In C programming language, data types are used to define the<strong><em> type of data </em></strong>that a variable can hold as each variable in C needs to declare what data type it represents.</p><p>The following data type groups are supported in C:</p><ol><li>Primitive data types ( Basic Data types Or Built in or Fundamental data type)</li><li>User-defined data types</li><li>Derived data types</li></ol><h4>1. Primitive Types:</h4><ul><li>These data types are built-in or predefined data types and can be used directly by the user to declare variables.</li><li>These data types are mostly integer, floating point and char. (integers, doubles, floating-point,char etc.)</li><li>Four main types of primary/basic data types are:<br> a. Integer<br> b. Float<br> c. Char<br> d. Void</li><li>These are further classified short, long, signed and unsigned data types in C.</li><li><strong>SHORT AND LONG : </strong>These are used to define the amount of memory space that the compiler will allocate. In case of short int, it is typically 2 bytes and in long int, it is 4 bytes.</li><li><strong>SIGNED AND UNSIGNED: </strong>This also deals with memory allocation but in a different way. In case of signed int, it takes into account both negative and positive numbers. But in unsigned int, we can only represent positive numbers.</li><li><strong>LONG AND LONG DOUBLE: </strong>These are mostly used with decimal numbers. By using these prefixes, we can increase the range of values represented in float. Float is of 4 bytes, double is of 8 bytes and long double is of 10 bytes.</li><li>Here is a list of all the primary data types:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*aNRZ4xwPh2I6AfvUmir3zg.png" /></figure><ul><li><strong>Examples</strong></li></ul><pre>#include &lt;stdio.h&gt;<br>int main() {<br>   char c = &#39;a&#39; ;<br>   int num = 10;<br>   float f = 1.20;<br>   float f1 = 1;<br>   double d = 3.2325467;  <br>   printf(&quot;%c&quot;,c); <br>   printf(&quot;%d&quot;,num);<br>   printf(&quot;%f&quot;,f);<br>   printf(&quot;%f&quot;,f1);<br>   printf(&quot;%lf&quot;,d);<br>   return 0;<br>}</pre><pre>output:<br>a <br>10 <br>1.200000 <br>1.000000<br>3.232547 </pre><ul><li><strong>Examples of data type declaration with warning</strong></li></ul><pre>#include &lt;stdio.h&gt;<br>int main() {<br>   int num = 10.1; // compilation warning implicit conversion from &#39;double&#39; to &#39;int&#39; changes value from 10.2 to 10<br>   float f = 1;<br>   printf(&quot;value of f %d \n&quot;, f); // compilation warning format specifies type &#39;int&#39; but the argument has type &#39;float&#39; <br>   return 0;<br>}</pre><h4>VOID data type</h4><p>It is a special type known as empty data type that is used to state that a given variable does not have any type. This is mainly used in defining functions where we do not want to return any value.</p><h4>2. User-defined data types:</h4><p>These data types are defined by the user as per their convenience. If a user feels a need of having a data type which is not predefined in C library, then they make their own..</p><ol><li><strong>Structure</strong>:- To declare a structure variable, use the struct keyword. It stores different data types. A way to combine data of different types.</li></ol><p>2. <strong>Enum</strong>:- To define enums, use the enum keyword. It consists of integer values.</p><p>3. <strong>Union</strong>:- Union is like Structure. But union uses less memory. It stores a package of different types of data.</p><h4>3. Derived Data Types in C:</h4><p>The derived data types are those data types that are created by combining primitive data types and other derived data types.</p><p><strong>There are three derived data types available in C. They are as follows:</strong></p><ol><li>Function</li><li>String</li><li>Array</li><li>Pointer</li><li><strong>ARRAY: </strong>Array in C is a fixed-size collection of similar data items stored in contiguous memory locations. An array is capable of storing the collection of data of primitive, derived, and user-defined data types. <strong>Syntax:</strong></li></ol><pre>data_type array_name [size];</pre><p><strong>Example</strong></p><pre>// C program to illustrate derived data type - Array <br>#include &lt;stdio.h&gt; <br><br>int main() <br>{ <br> // declaring the size of the array <br> int N = 3; <br><br> // declaring array of type int of size N <br> int arrI[] = { 18, 36, 54 }; <br> for (int i = 0; i &lt; N; i++) <br>  printf(&quot;%d &quot;, arrI[i]); <br><br> printf(&quot;\n&quot;); <br><br> // declaring array of type double of size N <br> double arrD[] = { 3.14, 6.28, 9.42 }; <br> for (int i = 0; i &lt; N; i++) <br>  printf(&quot;%lf &quot;, arrD[i]); <br><br> return 0; <br>}</pre><p><strong>2. STRING: </strong>String is an array of characters. The difference between a normal character array and a string is that string contains ‘\0’ value at the end, indicating that this is the end of the string, while a simple character array does not need to have this.</p><p>‘\0’ is a special character, which is known as the NULL character and it is used to indicate the termination of a string.</p><pre>#include &lt;stdio.h&gt;<br>int main() {<br>   char str1[6] = {&#39;H&#39;, &#39;e&#39;, &#39;l&#39;, &#39;l&#39;, &#39;o&#39;, &#39;\0&#39;};\<br>   char str2[] = &quot;Hello&quot;;<br>   printf(&quot;Say: %s\n&quot;, str1 );<br>   printf(&quot;Say: %s\n&quot;, str2 );<br>   return 0;<br>}</pre><pre>Output:<br>Say: Hello<br>Say: Hello</pre><p>3. <strong>Pointer</strong>: A pointer is a special type of data type. It is unique because, unlike other data types, it does not store normal values in variables. Instead, a pointer variable stores the memory address of a specific location in the computer’s memory.</p><p><strong>Syntax:</strong></p><pre>data_type * ptr_name;</pre><p>where,</p><ul><li><strong>data_type:</strong> type of data that a pointer is pointing to.</li><li><strong>ptr_name: </strong>name of the pointer.</li><li><strong>*: </strong>dereferencing operator.</li></ul><p><strong>Example</strong>:</p><pre>// C program to illustrate derived datatype - pointers <br>#include &lt;stdio.h&gt; <br><br>int main() <br>{ <br> int var = 20; <br><br> // declare pointer variable <br> int* myPtr; <br><br> // note that data type of pointer and variable must be same <br><br> // assign the address of a variable to a pointer <br> myPtr = &amp;var; <br><br> // printing myPtr to show value stored in myPtr which is <br> // address of var <br> printf(&quot;Value at myPtr = %p \n&quot;, myPtr); <br><br> // printing var variable directly <br> printf(&quot;Value at var = %d \n&quot;, var); <br><br> // using dereferencing operator to get the value myPtr <br> // is pointing at <br> printf(&quot;Value at *myPtr = %d \n&quot;, *myPtr); <br><br> return 0; <br>}</pre><p><strong>Output</strong></p><pre>Value at myPtr = 0x7ffd0850df9c <br>Value at var = 20 <br>Value at *myPtr = 20</pre><p>4. <strong>Function: </strong>Functions in C or in any programming language refers to a set of instructions that, when executed in a given order, performs a specific task. The task could be like, finding maximum element, sorting the elements, reversing the elements etc.</p><p><strong>Function Declaration</strong></p><pre>return_type function_name(data_type param1Name, data_type param2Name, ...);</pre><p>Let us consider a scenario where you want to calculate the multiplication of two numbers</p><pre>// C program to illustrate derived data type - function <br>#include &lt;stdio.h&gt; <br><br>int multiply(int param1, int param2) <br>{ <br> // return statement which return type int <br> return (param1 * param2); <br>} <br><br>int main() <br>{ <br> // declaring parameters to be passed to the function <br> int param1 = 5, param2 = 3; <br><br> // calling the function and storing the return value in <br> // result <br> int result = multiply(param1, param2); <br><br> // printing the result to the console <br> printf(&quot;%d&quot;, result); <br> return 0; <br>}</pre><pre>output:<br>15</pre><p>There is a main function present in every C program, all the other functions are declared there</p><p><strong>Components of a Function in C</strong></p><ul><li><strong><em>Return Type</em></strong>: Specifies the type of the value that the function will return after its execution.</li><li><strong><em>Function Name</em>: </strong>It is a unique name that identifies a function. Using this unique name, a function is called from various parts of a program.</li><li><strong><em>Function Body</em>: </strong>A function’s body consists of the statements that define what the function actually does. All the operations including the return of the result are done inside the body of a function.</li><li><strong><em>Parameters</em>: </strong>Parameters are the input values passed to the function by the caller. A function can have none or multiple parameters.</li><li><strong><em>Return Statement</em>:</strong> A function returns a value depending on its return type.</li></ul><h3>Conclusion:</h3><p>In this article, we learnt:</p><ol><li>Based on the data type,</li><li>Different ranges and sizes for each data type.</li><li>Different types of data types in brief</li></ol><p>Next Part : <a href="https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-operators-in-c-part-iv-2253cf7357e9">Operators in C Programming Language</a></p><p>Thanks for reading and happy reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4143b1b37691" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of C Programming for Beginners(Part-II)]]></title>
            <link>https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-ii-49860adf104f?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/49860adf104f</guid>
            <category><![CDATA[c-programming-help]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[c-programming-assignment]]></category>
            <category><![CDATA[c-programming-language]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Mon, 25 Dec 2023 20:47:38 GMT</pubDate>
            <atom:updated>2023-12-27T11:15:17.516Z</atom:updated>
            <content:encoded><![CDATA[<h3>Basics of C Programming for Beginners — Variables in C (Part-II)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*as6Mghi7WSoHmDZZ89ErjA.jpeg" /></figure><p>This tutorial is meant for beginners.In this tutorial , We attempt to understand the variables in the C programming language</p><p>Before moving on to this section, please read the first part of the preceding post if you haven’t already.</p><p><a href="https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-1-9ccabb0c3e6c">Basics of C Programming for Beginners(Part-1)</a></p><h3>What Are Variables in C?</h3><ul><li>Variables are containers for storing data values, like numbers and characters.</li><li>In other words, variable is nothing but a name given to a storage area</li><li>Variables hold a value that can be modified and reused many times during the program execution.</li><li>In the C programming language, variables must be declared before they can be used. This tells the compiler how to work with the variable and tells the linker how much space needs to be allocated for it.</li></ul><h4>Variable Declarations/(Creating) Variables</h4><ul><li>To declare a variable, you need to provide its type and an identifier (name).</li><li><strong>Syntax:</strong></li></ul><pre>   type identifier1, identifier2, … identifiern;</pre><ul><li><strong>Examples:</strong></li></ul><pre>#include &lt;stdio.h&gt; <br>int a ;<br>int b ;<br>int sum;</pre><h4>Variable Declarations with Definitions</h4><ul><li>There are situations when you’ll want to make sure a variable has a starting value before using it. This may conveniently be completed as part of the declaration of the variable. The basic format for defining and declaring a variable in one go is as follows:</li><li><strong>Syntax</strong></li></ul><pre>  type variableName = value;</pre><ul><li><strong>Example</strong></li></ul><pre>int a = 10, b=20,c=30;</pre><h4>What is the difference between initializing and declaring a variable?</h4><ul><li>Declaring a variable means we define a name for the variable and specify its type .</li><li><strong>Example</strong></li></ul><pre>int name, age;</pre><ul><li>When we do assign the variable a value later, there is no need to specify the data type again.</li><li><strong>Example:</strong></li></ul><pre>#include &lt;stdio.h&gt;<br>// declaring variables<br>int a ;<br>int b ;<br>int c;<br>int main(){<br>// assigning value here<br>  a = 10;<br>  b = 20;<br>  c = 30;<br>  printf(&quot;value of variable a: %d \n&quot;,a);<br>  printf(&quot;value of variable b: %d \n&quot;,b);<br>  printf(&quot;value of variable c: %d \n&quot;,c);<br>return 0;<br>}</pre><ul><li>Declare a variable and assign it a value in same line, this is called initialising the variable.</li><li><strong>Examples</strong>:</li></ul><pre>int a = 10, b=20,c=30;</pre><ul><li>In summary:</li></ul><pre>int age; // declaration, create a variable called n capable of holding integer values<br>int age = 27; // initialisation, creating a variable called n and assigning a value, storing a number in that variable</pre><h3>Rules for naming variables in C</h3><ul><li>A variable name can contain letters (uppercase or lowercase), numbers, or an underscore.</li><li>Variable names must begin either with a letter or an underscore, for example age and _age are valid.</li><li>Reserved keywords cannot be used as a variable name in C programming.</li><li>Variable names are case sensitive, for example age is different from Age.</li><li>No white spaces are allowed within the variable name.</li><li>Variables should be declared with their data type. Variable names without data type will generate errors.</li><li><strong>Example of valid variable names:</strong></li></ul><pre>int a = 2; <br>int sum;<br>float _ab;<br>int b20;</pre><ul><li><strong>Example of in-valid variable names:</strong></li></ul><pre>int 20a; //invalid name because variable name start with number<br>floar x y; // invalid name because there is space between x and y<br>int goto; // invalid name banecause goto is keyword in c<br>b = 2 //is an invalid variable.</pre><h3>Types of Variables in C :</h3><ul><li>Local variables</li><li>Global variables</li><li>Static variables</li><li>External variables</li><li>Automatic variables</li></ul><h4>Local Variables:</h4><ul><li>The variable that is declared inside function or inside block is called a local variable.</li><li>The scope of Local variables is within the defined function only.</li><li>You cannot use a local variable outside the function (in which it is declared).</li><li><strong>Examples</strong>:</li></ul><pre>#include &lt;stdio.h&gt; <br><br>void personInformation() <br>{ <br>    // Local Variables of the function <br>    int age = 26; <br>    float height = 5.8; <br><br>    printf(&quot;age is %d \n&quot;, age); <br>    printf(&quot;height is %f&quot;, height); <br>} <br><br>int main() <br>{ <br>    personInformation(); <br>    return 0; <br>}</pre><ul><li><strong>Output</strong></li></ul><pre>age is 26 <br>height is 5.800000%   </pre><ul><li><strong>Local Scope of Variables in C — Nested Blocks</strong></li></ul><pre>#include &lt;stdio.h&gt;<br><br>int main() <br>{<br>  int localVariableForMain = 7;<br>  //inner block can access the local variable<br>    {<br>        localVariableForMain = localVariableForMain +10;<br>        printf(&quot;localVariableForMain is %d&quot;,localVariableForMain);<br>    }<br>    <br>    return 0;<br>}</pre><p>The inner block is able to access the value of localVariableForMain that’s declared in the outer block, and modify it by adding 10 to it.</p><ul><li><strong>Output</strong></li></ul><pre>localVariableForMain is 17                                                                                                                                                                                                         </pre><ul><li><strong>Local Scope of Variables in C — Nested Blocks</strong></li></ul><pre>#include &lt;stdio.h&gt;<br><br>int main() <br>{<br>    int my_num = 7;<br>    {<br>        int new_innter_block_num = 10;<br>    } <br>    printf(&quot;new_num is %d&quot;,new_innter_block_num); // compilation error, This is because the variable new_innter_block_num is declared in the inner block and its scope is limited to the inner block<br>    return 0;<br>}</pre><ul><li><strong>Output</strong>:</li></ul><pre>error: use of undeclared identifier &#39;new_innter_block_num&#39;<br>    printf(&quot;new_num is %d&quot;,new_innter_block_num); // compilation error, This is because the variable new_innter_block_num is declared in the inner block and its scope is limited to the inner block<br>                           ^<br>1 error generated.</pre><ul><li><strong>Local Scope of Variables in C — Different Blocks</strong></li></ul><pre>#include &lt;stdio.h&gt;<br><br>int main()<br>{<br>    int my_num = 7;<br>    printf(&quot;%d&quot;,my_num);<br>    my_func();<br>    return 0;<br>}<br><br>void my_func()<br>{<br>    printf(&quot;%d&quot;,my_num); // compilation error  this is because my_num variable is declared in main() function and my_num is obnly accessible inside main() method<br>}</pre><ul><li><strong>Output</strong></li></ul><pre>error: use of undeclared identifier &#39;my_num&#39;<br>    printf(&quot;%d&quot;,my_num); // compilation error  this is because my_num variable is declared in main() function and my_num is obnly accessible inside main() method</pre><h4>Global variable:</h4><ul><li>The scope of the global variable is the entire program.</li><li>They are not defined inside any function and can be used in any function.</li><li><strong>Examples</strong></li></ul><pre>#include &lt;stdio.h&gt; <br><br>// Declaring global variable<br>int globaleNum = 23; <br><br>void function1() <br>{ <br>    // Function using global variable a<br>    printf(&quot;The number is %d \n&quot;, globaleNum); <br>} <br><br>void function2() <br>{ <br>    // Function using global variable a<br>    printf(&quot;The number is %d \n&quot;, globaleNum); <br>} <br><br>int main() <br>{ <br>    // Calling functions<br>    function1(); <br>    function2(); <br><br>    return 0; <br>}</pre><pre>output:<br>The number is 23 <br>The number is 23 </pre><h4>Static Variable:</h4><ul><li>The static variable is defined using the static keyword.</li><li>The value of a static variable is initialized only once at the time of program loading and it retains its value until the program terminates.</li><li>Its scope depends on the area of its declaration. If a static variable is defined within a function, it is a local variable. If declared outside the function, its scope is global.</li><li><strong>Syntax</strong></li></ul><pre>static data_type variable_name;</pre><ul><li><strong>Examples</strong></li></ul><pre>static int count;</pre><ul><li><strong>Local Scope Static Variable in C</strong></li></ul><pre>#include &lt;stdio.h&gt;<br><br>void countCalls(void);<br><br>int main()<br>{<br>   countCalls();<br>   countCalls();<br>   countCalls();<br><br>   return 0;<br>}<br><br>void countCalls(void)<br>{<br>   static int count = 0;   // static variable<br><br>   count++;<br>   printf(&quot;Function has been called %d times\n&quot;, count);<br>}</pre><pre>Output:<br>Function has been called 1 times<br>Function has been called 2 times<br>Function has been called 3 times</pre><ul><li><strong>Global Scope Static Variable in C</strong></li></ul><pre>#include &lt;stdio.h&gt;<br><br>static int count = 0;   // global static variable<br><br>void countCalls(void);<br><br>int main()<br>{<br>   countCalls();<br>   countCalls();<br>   countCalls();<br><br>   return 0;<br>}<br><br>void countCalls(void)<br>{<br>   count++;<br>   printf(&quot;Function has been called %d times\n&quot;, count);<br>}</pre><pre>Output:<br>Function has been called 1 times<br>Function has been called 2 times<br>Function has been called 3 times</pre><h4>External Variable</h4><ul><li>The external variables use the extern keyword before the variable definition.</li><li>This enhances the variable visibility, and the variable can be used in different C files. It is a global variable. It is not necessary to initialize the variable at the time of its declaration. Its lifetime is the entire program.</li><li><strong>Syntax:</strong></li></ul><pre>extern data_type variable_name;</pre><p><strong>Example:</strong></p><pre>extern int a; </pre><h4>Constant Variable</h4><ul><li>The constant variables are special variables in C whose value does not change throughout the program after initialization.</li><li>It is a read-only variable in C.</li><li>Initializing a constant variable at the time of variable declaration is mandatory.</li><li>It uses the “const” keyword before its definition.</li><li><strong>Syntax:</strong></li></ul><pre>const data_type variable_name = initial_value;</pre><p><strong>Example:</strong></p><pre>const int a = 10;</pre><h3>Conclusion</h3><p>This article explains all the types of variables used in C programming. We understand the range and lifespan of variables in C as well.</p><p>We’ll discuss about the different Data types available in the C programming language in the next section.</p><p>Next Part : <a href="https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-iii-4143b1b37691">Date Types in C Programming Language</a></p><p>Thanks for reading and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49860adf104f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of C Programming for Beginners — Introduction(Part-I )]]></title>
            <link>https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-1-9ccabb0c3e6c?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ccabb0c3e6c</guid>
            <category><![CDATA[c-program]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[c-programming-help]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Mon, 25 Dec 2023 18:13:38 GMT</pubDate>
            <atom:updated>2023-12-27T10:12:18.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*as6Mghi7WSoHmDZZ89ErjA.jpeg" /></figure><h3>Overview</h3><p>This tutorial is meant for beginners. You get an overview of the basic concepts of the C programming language</p><p>Much of the inspiration for this tutorial comes from online resources.</p><h3>Table of Contents</h3><ol><li>Introduction of programming languages</li><li>Introduction of C</li><li>Advantages of C Language</li><li>C Basic Commands:</li><li>Simple C program(Hello World program)</li><li>Steps to execute C program</li><li>How C source code gets transformed into binary code</li><li>Debugging and testing</li><li>Errors in C</li><li>Conclusion</li></ol><h3>1. Introduction of programming languages</h3><p>Programmers, often known as developers, use programming languages as a way of communication with computers. It is a series of instructions used to carry out a certain task written in any language (C, C++, Java, Python, etc.).</p><p>Two types of programming languages</p><ol><li>Low Level Languages</li><li>High Level Languages</li></ol><p><strong>1. Low Level Languages:</strong></p><p>Low level languages are used to write programs that relate to the specific architecture and hardware of a particular type of computer.<br>They are closer to the native language of a computer (binary), making them harder for programmers to understand.<br>Low Level Languages are used to developing code for specialist hardware<br> Examples of low level language:<br> — <strong>Machine Code (machine level language) : </strong>In machine level language, computer only understand digital numbers i.e. in the form of 0 and 1. So, instruction given to the computer is in the form binary digit<br>Disadvantage<br>a. difficult to implement<br>b. difficult to understand<br>c. machine dependent (not portable)<br> — <strong>Assembly Language : </strong>Modified version of machine level language<br>This language contains few recognizable human words but plenty of mnemonic code. word like ADD, SUM, MOV etc.<br>Still Used for developing code for specialist hardware, such as device drivers. Translator used here is assembler to translate into machine level<br> Advantage<br> a. Easy to understand</p><p><strong>2. High level language:</strong><br>When we think about computer programmers, we are probably thinking about people who write programming which is in high-level programming languages. High level languages are written in a form that is close to our human language<br>- These languages are machine independent, means it is portable <br>- High level languages are not understood by the machine. So it need to translate by the translator into machine level<br>- Examples include: C, C++, Java, Pascal, Python, Visual Basic.<br> <strong>Advantages</strong><br> Easier to modify as it uses English like statements<br> Easier/faster to write code as it uses English like statements<br> Easier to debug during development due to English like statements<br> Portable code — not designed to run on just one type of machine</p><h3>2. Introduction of C</h3><ul><li>C is mid-level programming language (C is considered as a middle-level language because it supports the feature of both low-level and high-level languages)</li><li>C is procedural language (A procedure is known as a function, method, routine, subroutine, etc. A procedural language specifies a series of steps for the program to solve the problem.<br> A procedural language breaks the program into functions, data structures, etc.)</li><li>C as a structured programming language (Structure means to break a program into parts or blocks so that it may be easy to understand.)</li><li>Developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Lab in 1972</li><li>C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows</li><li>The UNIX OS was totally written in C</li></ul><h3><strong>Advantages of C Language :</strong></h3><ul><li><strong>Simple:</strong> easy to learn , offer structural approach to solve problems</li><li><strong>Portable</strong>: C programs can be written on one platform and can be executed in the same way on another operating system. C is a machine-independent language.</li><li><strong>Structured programming language:</strong> C provides different functions that enable us to break the code into small parts, that is why C programs are easy to understand and modify. Functions also offer<br> code reusability.</li><li><strong>Fast and Efficient</strong>: The compilation and execution time of the C language is also fast.</li></ul><h3>C Basic Commands:</h3><ul><li><strong>#include &lt;stdio.h&gt;</strong> : It is a preprocessor command which consists of a standard input output header file(stdio.h) before compiling a C program.</li><li><strong>int main()</strong> : The main function from where execution of any C program starts.</li><li><strong>{ </strong>: Indicates the beginning of the main function.</li><li><strong>/*_some_comments_*/</strong> : Any content inside “/* */” will not be used for compilation and execution.</li><li><strong>printf</strong>: The output is printed to the console screen using this C</li><li><strong>Getch()</strong>: This function is being used to wait for the user’s input.</li><li><strong>return</strong> : This C function returns 0 after terminating the C programme or main function.</li><li><strong>}</strong> : The function or method block is closed with these curly braces.</li><li><strong>Scanf</strong>: The user data is taken from the usual console terminal window using this C function.</li><li><strong>//</strong> : These are called single line comments,</li></ul><h3>Simple C program(Hello World program)</h3><pre>#include &lt;stdio.h&gt;<br><br>int main (void)<br><br>{<br>    printf(&quot;\n Hello World \n&quot;);<br>    return 0;<br>}</pre><ul><li>Make sure that you save the file you created with a `.c` extension, or it won’t be a valid C file.</li><li><strong>Header Files in C : </strong><br>- Header files are external libraries.<br>- By adding header files to your code, you get additional functionality that you can use in your programs without having to write the code from scratch.<br>- <strong>#include</strong> is a preprocessor command that tells the C compiler to include a file.<br>- The <strong>stdio.h</strong> header file stands for standard input-output.It contains function definitions for input and output operations, such as functions for gathering user data and printing data to the console<br>Specifically, it provides functions such as printf() and scanf().</li><li><strong>What is the main() function in C: </strong><br>- <strong>“ </strong><em>int main(void) { …} </em>’’ is the main function and starting point of every C program. <br>- It is the first thing that is called when the program is executed. <br>The <em>int</em> keyword in “int main(void) { .. }” indicates the return value of the main() function.<br>- <strong>void</strong> keyword inside the main() function indicates that the function receives no arguments. This is optional, you can also write ‘int main()’ instead of ‘int main(void)’<br>- Anything inside the curly braces, {}, is considered the body of the function</li><li><strong>What Are Comments </strong>:<br>- In C programming, comments are lines of text that get ignored by the compiler.<br>- Writing comments is a way to provide additional information and describe the logic, purpose, and functionality of your code.<br>- Comments are also helpful for debugging and troubleshooting.<br>- <strong>Single-line comments</strong> :<br>- Here is the syntax for creating a single-line comment in <br><em> “// I am a single-line comment” </em><br>- Any text written after the forward slashes and on the same line gets ignored by the compiler.<br>- <strong>Multi-line comments</strong><br>- As the name suggests, they span multiple lines.<br>- Multi-line comments start with a forward slash, /, followed by an asterisk, *, and end with an asterisk, followed by a forward slash.<br>- Here is the syntax for creating a multi-line comment in C: <br> <em>/* This is<br> a multi-line<br> comment<br> */</em><br>- Comments are also helpful for debugging and troubleshooting.</li><li><strong>What is the printf() function in C: </strong><br>- Inside the function’s body, the line printf(“Hello, World!\n”); prints the text Hello, World! to the console (this text is also known as a string).</li><li><strong>What is semicolon ‘;’ in C </strong>:<br>- The semicolon, ;, terminates the statement. All statements need to end with a semicolon in C, as it identifies the end of the statement.<br>- You can think of a semicolon similar to how a full stop/period ends a sentence.</li></ul><h3>Steps to execute C program</h3><ul><li><strong>Step 1: Creating a C Source File: </strong>We need to first create a C program using an editor (TextEditor, eclipse, Visual Studio, Notepad etc) and save the file as filename.c</li><li><strong>Step 2: Compiling using GCC compiler :</strong>We use the following command in the terminal for compiling our filename.c source file<br> “<em>$ gcc filename.c –o filename”</em><br>The option -o is used to specify the output file name. If we do not use this option, then an output file with the name <strong><em>a.out</em></strong> is generated.</li><li><strong>Step 3: Executing the program</strong><br> After compilation executable is generated and we run the generated executable using the below command.<br> “$ <em>./filename</em>”</li></ul><h3>How C source code gets transformed into binary code</h3><ul><li>Any code you write in the C programming language is called source code.</li><li>Your computer doesn’t understand any of the C statements you have written,so this source code needs to be translated into a different format(Machine code) that the computer can understand</li><li>The compiler will read the program and translate it into machine language-code (also referred to as object code). and make your program suitable for execution.</li><li>The C program goes through the following phases during compilation:<br> 1. Preprocess<br> 2. Compiler<br> 3. Assembler<br> 4. Linker<br> <br> 1. <strong>Preprocess:</strong><br>- This is the first phase through which source code is passed. <br>- In a C system, a preprocessor program executes automatically before the compiler’s translation phase begins.<br>- The C preprocessor obeys special commands called preprocessor directives, which indicate that certain manipulations are to be performed on the program before compilation.<br>- The preprocessor scans through the source code to find preprocessor directives, which are any lines that start with a # symbol, such as #include , Macros.<br> — This phase includes:<br> — Removal of Comments<br> — Expansion of Macros<br> — Expansion of the included files.<br> — Conditional compilation<br> — For example, when the preprocessor finds the line #include , the #include tells the preprocessor to include all the code from the stdio.h header file.<br> — So, it replaces the #include line with the actual contents of the stdio.h file.<br> — The output of this phase is a modified version of the source code.<br> <br> 2. <strong>Compiler </strong><br>- The next step is to compile sourcecode and produce an; intermediate compiled output file This file is in assembly-level instructions.<br>- If there are any errors, compilation will fail, and you will need to fix the errors to continue.<br> <br> 3.<strong> Assembling</strong><br>- The next step is the assembly phase, where the assembler converts the generated assembly code statements into machine code instructions.<br>- The output of this phase is an object file, which contains the machine code instructions.<br> <br>4.<strong> Linking</strong><br>- The next phase is called linking. C programs typically contain references to functions defined elsewhere, such as in the standard libraries or in the private libraries of groups of programmers<br> working on a particular project.<br>- Linker does some extra work also, it adds some extra code to our program which is required when the program starts and ends. For example, there is a code that is required for setting up the <br> environment like passing command line arguments.</li></ul><h3>Debugging and testing</h3><ul><li>We want to test and debug our program to ensure it is working correctly.</li><li>For a simple program like this, we might manually run it and verify that the output is correct.</li><li>For more complex programs, we might use debugging tools like gdb or automated testing frameworks to help identify and fix issues.</li></ul><h3>Errors in C</h3><p>An error in the C programming language is a problem that can occur in a program and prevent it from compiling or from working as expected</p><p>If an error appears in a program, the program can do one of the following three things: <br> — The code will not compile, <br> — The program will stop working during execution, <br> — The program will generate incorrect output.</p><p>There are five different types of errors in C.<br> — Syntax Error<br> — Run Time Error<br> — Logical Error<br> — Semantic Error<br> — Linker Error</p><ol><li><strong>Syntax Error:</strong><br>- When a programmer writes code that does not follow the C syntax rules, it leads to the creation of syntax errors.<br>- Syntax errors are sometimes also called compilation errors because they are always detected by the compiler. Generally, these errors can be easily identified and rectified by programmers.<br> a. The most commonly occurring syntax errors in C language are:<br> b. Missing semi-colon (;)<br> c. When there are typos<br> d. Missing keywords or variables<br> e. Mismatched parentheses and brackets<br> f. Incorrect data types used for operations in a program, etc.<br> g. Using undeclared variables</li></ol><p><strong>Example Of Syntax Error In C</strong></p><p>1.</p><pre>#include &lt;stdio.h&gt;<br>     void main() {<br>         var = 5;    // we did not declare the data type of variable<br>         printf(&quot;The variable is: %d&quot;, var);<br>     }</pre><pre>output:<br>     error: &#39;var&#39; undeclared (first use in this function)</pre><p>2.</p><pre> #include &lt;stdio.h&gt;<br>  void main() {<br>        for (int i = 0;) {  // incorrect syntax of the for loop <br>           printf(&quot;Scaler Academy&quot;);<br>        }<br>      }</pre><pre>output:<br>      error: expected expression before &#39;)&#39; token</pre><p>3.</p><pre>#include &lt;stdio.h&gt;<br>  int main() {<br>   printf(&quot;Hello Unstop&quot;) //  missing semicolone &#39;;&#39; <br>   return 0;<br><br> }</pre><pre>Output error:<br><br>        6 | printf(&quot;Hello Unstop&quot;)<br>        | ^<br>        | ;<br>        7 |<br>        8 | return 0;</pre><p><strong>2. Run Time Error:</strong><br>- Errors that occur during the execution (or running) of a program are called RunTime Errors<br>- The most common causes of these errors are- coding mistakes, memory corruption, or incorrect system configuration.<br>- Runtime errors can be a little tricky to identify because the compiler can not detect these errors. They can only be identified once the program is running.<br>- Runtime errors can occur because of various reasons. Some of the reasons are: <br> — <strong>Mistakes in the Code</strong>: Let us say during the execution of a while loop, the programmer forgets to enter a break statement. This will lead the program to run infinite times, hence<br> resulting in a run time error.<br> — <strong>Memory Leaks</strong>: If a programmer creates an array in the heap but forgets to delete the array’s data, the program might start leaking memory, resulting in a run time error.<br> — <strong>Mathematically Incorrect Operations</strong>: Dividing a number by zero, or calculating the square root of -1 will also result in a run time error.<br> —<strong> Undefined Variables</strong>: If a programmer forgets to define a variable in the code, the program will generate a run time error.</p><p><strong>Examples of Run Time Error:</strong></p><p>1.</p><pre> #include &lt;stdio.h&gt;<br>   int main() {<br>       int a = 10, b = 0;<br>       int result = a/b;<br>       printf(&quot;Result is: %d \n&quot;;, result);<br>       return 0;<br>    }</pre><pre> Output error:<br>    <br>    9 | printf(&quot;Result is: %d \n&quot;;, result); // Print out the value of &#39;result&#39; variable<br>    | ~ ^<br>    | )<br>    9 | printf(&quot;Result is: %d \n&quot;;, result); // Print out the value of &#39;result&#39; variable<br>    | ~^<br>    | |<br>    | int</pre><p><strong>Explanation</strong>:<br> The error in this code is that a division by zero is attempted, which cannot be done. This causes a run-time error that results in the program crashing</p><p><strong>The correct code is:</strong></p><pre>#include &lt;stdio.h&gt;<br>  int main() {<br>       int a = 10, b = 0;<br>       int result = a/b;<br>       printf(&quot;Result is: %d \n&quot;;, result);<br>       return 0;<br>    }</pre><pre>Output:<br>    Result is: 1</pre><p>3. <strong>Logical Error :</strong><br>A logical error in C is an error that occurs when a program produces an incorrect output as a result of incorrect logic or incorrect input.</p><p><strong>Example Of Logical Error In C:</strong></p><pre>#include &lt;stdio.h&gt;<br>int main() {<br>     int x = 25;<br>     int y = 45;<br>     printf(&quot;The sum of x and y : %d&quot;,x*y);<br>     return 0;<br> }</pre><pre>Output error:<br>         The sum of x and y: 1125</pre><p><strong>Explanation</strong>:<br> The error in the code is that it incorrectly calculates the sum of x and y, instead of multiplying them</p><p><strong>The correct code is:</strong></p><pre>#include &lt;stdio.h&gt;<br>int main() {<br>     int x = 25;<br>     int y = 45;<br>     printf(&quot;The sum of x and y : %d&quot;,x+y);<br>     return 0;<br> }</pre><pre>Output error:<br>         The sum of x and y: 70</pre><p>4. <strong>Semantic Error:</strong><br> — Errors that occur because the compiler is unable to understand the written code are called Semantic Errors<br> — A semantic error will be generated if the code makes no sense to the compiler, even though it is syntactically correct.<br> — Semantic errors are different from syntax errors, as syntax errors signify that the structure of a program is incorrect without considering its meaning. On the other hand, semantic<br> errors signify the incorrect implementation of a program by considering the meaning of the program.<br> — The most commonly occurring semantic errors are: use of un-initialized variables, type compatibility, and array index out of bounds.</p><p><strong>Example Of Semantic Error In C</strong></p><pre>#include &lt;stdio.h&gt;<br>    int main() {<br>        int a, b, c;<br>         a * b = c;<br>         // This will generate a semantic error<br>        return 0;<br>     }</pre><pre>Output error: <br>    SemanticError.c:6:11: error: expression is not assignable<br>           a * b = c;</pre><p><strong>5. Linker Error :</strong><br> — Linker is a program that takes the object files generated by the compiler and combines them into a single executable file. <br> — Linker errors are the errors encountered when the executable file of the code can not be generated even though the code gets compiled successfully. <br> — This error is generated when a different object file is unable to link with the main object file. We can run into a linked error if we have imported an incorrect header file in the<br> code, we have a wrong function declaration, etc.</p><p><strong>Example Of Linker Error In C</strong></p><pre>#include &lt;stdio.h&gt;<br>  int Main() { <br>        int var = 10;<br>        printf(&quot;%d&quot;, var);<br>        return 0;<br>  }</pre><pre>Output:<br>   undefined reference to `main&#39;</pre><p><strong>Explanation</strong>:<br> In the above code, as we wrote Main() instead of main(), the program generated a linker error. This happens because every file in the C language must have a main() function. As in the<br> above program, we did not have a main() function, the program was unable to run the code, and we got an error. This is one of the most common type of linker error.<br> <br><strong> The correct code is:</strong></p><pre>#include &lt;stdio.h&gt;<br>  int Main() { <br>        int var = 10;<br>        printf(&quot;%d&quot;, var);<br>        return 0;<br>  }</pre><h3>Conclusion</h3><p>The introduction to the C programming language has been concluded! <br>I hope this helped you understand some of the foundational concepts you’ll need to begin building simple C programs.</p><p>We’ll discuss about variables in the C programming language in the next section.</p><p>Next Part : <a href="https://medium.com/@vijayaneraye/basics-of-c-programming-for-beginners-part-ii-49860adf104f">Variables in C (Part-II)</a></p><p>Thanks for reading and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ccabb0c3e6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Important Features — Java 9, Java 10, Java 11, Java 12, Java13, Java 14, Java 15, Java 16,, Java 17]]></title>
            <link>https://medium.com/@vijayaneraye/important-features-java-9-java-10-java-11-java-12-java13-java-14-java-15-java-16-java-17-650420ee7337?source=rss-5f4cb3f190ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/650420ee7337</guid>
            <category><![CDATA[java-14]]></category>
            <category><![CDATA[java11]]></category>
            <category><![CDATA[java9]]></category>
            <category><![CDATA[java17]]></category>
            <category><![CDATA[java10]]></category>
            <dc:creator><![CDATA[Vijay Aneraye]]></dc:creator>
            <pubDate>Sat, 05 Feb 2022 09:13:40 GMT</pubDate>
            <atom:updated>2025-03-27T23:59:29.855Z</atom:updated>
            <content:encoded><![CDATA[<h3>Important Features — Java 9, Java 10, Java 11, Java 12, Java13, Java 14, Java 15, Java 16, Java 17</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7yJofEGWqOuaHEKJZgHctQ.jpeg" /><figcaption>New Feature in java9-to Java17</figcaption></figure><h3>In this article, we will go through some of the most interesting features introduced in Java in the last few years.</h3><p>In this article we are not going to cover all features introduced in Java in the last few years, instead, We are going to see some of the important features introduced in the last few years.</p><h3>Java 9:</h3><h4>- Factory methods for collections(like List, Map, Set and Map.Entry) :</h4><p>Many times in your Java program, you have to create a collection (e.g., a List or Set) with some elements. That leads to repetitive coding where you instantiate the collection, followed by several ‘add’ calls. With Java 9, several so-called collection factory methods have been added.</p><p>A collection factory method in Java is a static method that provides a simple way of initializing an <strong>immutable</strong> Collection&lt;E&gt;.</p><p><strong>Being immutable, no elements can be added to, removed from, or modified inside the </strong><strong>Collection&lt;E&gt; after it is initialized.</strong></p><blockquote>List and Set interfaces have <strong>“of()”</strong> methods to create an empty or no-empty Immutable List or Set objects as shown below:</blockquote><p><strong>Example</strong></p><p>Empty List example:</p><pre>List immutableEmptyList = List.of();</pre><p>Non-Empty List example:</p><pre>List immutableList = List.of(&quot;Abc&quot;, &quot;Def&quot;, &quot;Ghi&quot;);</pre><p>Empty Map Example:</p><pre> Map emptyImmutableMap = Map.of()<br>emptyImmutableMap ==&gt; {}</pre><p>Non-Empty Map Example:</p><pre>Map nonemptyImmutableMap = Map.of(1, &quot;one&quot;, 2, &quot;two&quot;, 3, &quot;three&quot;)<br>nonemptyImmutableMap ==&gt; {2=two, 3=three, 1=one}</pre><h4>- Private Interface Methods</h4><p>From Java 9, we can create private methods inside an interface that help to <strong>share</strong> common code between <strong>non-abstract</strong> methods.</p><p>Example</p><pre>public interface Person{<br>  private Long createID(){<br>    // Implementation goes here.<br>  }<br>  private static void displayDetails(){<br>    // Implementation goes here.<br>  }<br>}</pre><h3>Java 10:</h3><h4>- Local variable type inference:</h4><p>Type inference is a technique used by statically typed languages, where the types of variables may be inferred from context by the compiler.</p><blockquote>In JDK 10 and later, you can declare local variables with non-null initializers with the <strong>var</strong> identifier, which can help you write code that’s easier to read.</blockquote><p><strong>Note: that this feature is available only for local variables with the initializer.</strong></p><p><strong>Examples</strong>:</p><pre>// Declaration of a local variable in java 10 using LVTI<br>class A {<br>public static void main(String a[])<br>{<br>   var list = new ArrayList&lt;String&gt;();  // infers ArrayList&lt;String&gt;<br>   var stream = list.stream();          // infers Stream&lt;String&gt;<br>   // Declaration of a local variable in java 10 using LVTI  <br>   var x = &quot;Hi there&quot;;<br>   // Declaring index variables in for loops using LVTI in Java<br>   for (var x = 0; x &lt; 3; x++) {<br>     System.out.println(x);<br>    }<br>   System.out.println(x)<br>}<br>}</pre><p>This enhancement helps in reducing the boilerplate code; for example:</p><pre>Map&lt;Integer, String&gt; map = new HashMap&lt;&gt;();</pre><p>This can now be rewritten as:</p><pre>var idToNameMap = new HashMap&lt;Integer, String&gt;();</pre><p>This also helps to focus on the variable name rather than on the variable type.</p><p><strong>Illegal Use of var:</strong></p><ol><li><em>“var” </em>won’t work without the initializer and not with Null :</li></ol><pre>var name; // error: cannot use &#39;var&#39; on variable without initialize<br>var emptyList = null; //error</pre><p>2. “var” cannot be used with lambda express and array list because lambda expression and array list need an explicit target type</p><pre>var expression = (String s) -&gt; s.length() &gt; 10; // error: lambda expression needs an explicit target-type<br><br>var arrayList = { 1, 2, 3 }; // error: array initializer needs an explicit target-type</pre><p>3. Other Error cases</p><pre>class A {<br>//Not permitted in class fields(non-local variables)<br>public var = &quot;hello&quot;; // error: &#39;var&#39; is not allowed here<br>//Not allowed as parameter for any methods<br>void show(var a) Error: <br>{<br>}<br>//Error: Not permitted in method return type<br>public var show() {<br>   return 1;<br>}<br>}</pre><h3>Java 11:</h3><h4>- New utility methods in the String class</h4><p>Java 11 adds a few <a href="https://www.baeldung.com/java-11-string-api">new methods</a> to the <em>String</em> class: <em>isBlank</em>, <em>lines</em>, <em>strip</em>, <em>stripLeading</em>, <em>stripTrailing,</em> and <em>repeat</em>.</p><ul><li><strong>isBlank():</strong> This is a boolean method. It just returns true when a string is empty and vice-versa.</li></ul><pre>Example<br>class Example { <br>  String str1 = &quot;&quot;;<br>  System.out.println(str1.isBlank());<br>}<br><br>Output: True</pre><ul><li><strong>lines(): </strong>This method returns a stream of strings, which is a collection of all substrings split by lines.</li></ul><pre>Example<br>class Example { <br>  String str = &quot;Hi\nHello\nNamaste&quot;;<br>  System.out.println(str.lines().collect(Collectors.toList()));<br>}<br><br>Output:<br>Hi<br>Hello<br>Namaste</pre><ul><li><strong>repeat(n):</strong> The result is the concatenated string of the original string repeated the number of times in the argument.</li></ul><pre>//Example<br>class Example { <br>  String str = &quot;1&quot;.repeat(5);<br>  System.out.println(str);   <br>}<br><br>Output:<br>11111</pre><ul><li><strong>strip():</strong> It is used to remove the white spaces which are in-front and back of the string.strip() is “Unicode-aware” evolution of trim(). When trim() was introduced, Unicode wasn’t evolved. Now, the new strip() removes all kinds of whitespaces leading and trailing(check the method Character.isWhitespace(c) to know if a Unicode is whitespace or not)</li><li><strong>stripTrailing():</strong> It is used to remove the white-space which is in the back of the string</li><li><strong>stripLeading():</strong> It is used to remove the white space which is in front of the string</li></ul><pre>Examples:<br>public class HelloWorld {<br> public static void main(String[] args)<br> {<br>    System.out.println(&quot;   hi  &quot;.strip());  <br>    System.out.println(&quot;   hi  &quot;.stripLeading());<br>    System.out.println(&quot;   hi  &quot;.stripTrailing()); <br>}<br>}<br>Output:<br>&quot;hi&quot;<br>&quot;hi  &quot;<br>&quot;   hi&quot;</pre><h4>- New File Methods</h4><p>Using this readString<strong> and <em>writeString</em> static methods from the <em>Files </em>class</strong>, Java 11 aims to reduce a lot of boilerplate code which makes it much easier to read and write files.</p><pre>public class FileReadWriteTest{<br>@Test                                 <br>void readFileAndWriteFileTest() throws IOException {   <br>                                  <br>Path filePath = Files.writeString(Files.createTempFile(tempDir, &quot;demo&quot;, &quot;.txt&quot;), &quot;Sample text&quot;);<br>                                     <br>String fileContent = Files.readString(filePath);                                     assertThat(fileContent).isEqualTo(&quot;Sample text&quot;);                                 }<br>}</pre><h4>- The Not Predicate Method</h4><p>A static <a href="https://www.baeldung.com/java-negate-predicate-method-reference"><em>not</em> method</a> has been added to the <em>Predicate </em>interface. We can use it to negate an existing predicate, much like the <em>negate </em>method:</p><pre>List&lt;String&gt; sampleList = Arrays.asList(&quot;Java&quot;, &quot;\n \n&quot;, &quot;Kotlin&quot;, &quot; &quot;);<br>List withoutBlanks = sampleList.stream()<br>  .filter(Predicate.not(String::isBlank))<br>  .collect(Collectors.toList());<br>assertThat(withoutBlanks).containsExactly(&quot;Java&quot;, &quot;Kotlin&quot;);</pre><h3>Java 12:</h3><h4><strong>- Changes in Switch expressions</strong>:</h4><p>Before Java 12, switch was a statement only. Now, though, you can also have switch expressions. For example, take a look at this code that processes various user events:</p><p><strong>Switch expressions</strong> will now be used as a statement as well as expressions. This makes code simplification and pattern matching possible for the switch.</p><p>Now, the new Arrow syntax for the switch is introduced as</p><pre>case X -&gt; {}</pre><p>Firstly, let’s look at the old syntax:</p><pre>DayOfWeek dayOfWeek = LocalDate.now().getDayOfWeek();<br>String typeOfDay = &quot;&quot;;<br>switch (dayOfWeek) {<br>    case MONDAY:<br>    case TUESDAY:<br>    case WEDNESDAY:<br>    case THURSDAY:<br>    case FRIDAY:<br>        typeOfDay = &quot;Working Day&quot;;<br>        break;<br>    case SATURDAY:<br>    case SUNDAY:<br>        typeOfDay = &quot;Day Off&quot;;<br>}</pre><p>And now, let’s see the same logic with switch expressions:</p><pre>typeOfDay = switch (dayOfWeek) {<br> case MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY -&gt; &quot;Working Day&quot;;<br> case SATURDAY, SUNDAY -&gt; &quot;Day Off&quot;;<br>};</pre><p><strong>Note:</strong> how the switch now returns a value</p><h3>Java 14:</h3><h4>- Helpful NullPointerExceptions</h4><p>Previously, the stack trace for a <em>NullPointerException</em> didn’t have much of a story to tell except that some value was null at a given line in a given file.</p><p>Though useful, this information only suggested a line to debug instead of painting the whole picture for a developer to understand just by looking at the log.</p><p>For example, consider this simple snippet:</p><pre>int[] arr = null;<br>arr[0] = 1;</pre><p>Earlier, on running this code, the log would say:</p><pre>Exception in thread &quot;main&quot; java.lang.NullPointerException<br>at com.baeldung.MyClass.main(MyClass.java:27)</pre><p>But now, given the same scenario, the log might say:</p><pre>java.lang.NullPointerException: Cannot store to int array because &quot;a&quot; is null</pre><p>As we can see, now we know precisely which variable caused the exception.</p><h4>- Pattern Matching for <a href="https://www.journaldev.com/17136/instanceof-java">instanceof</a> :</h4><p>Java developer makes good use of instanceof conditions throughout the code. Specifically, an instanceof conditional check is generally followed by a typecasting.</p><p>Java 14, gets rid of this verbosity by making conditional extraction a lot more concise.</p><p><strong>Before Java 14:</strong></p><pre>if (obj instanceof Journaldev) {<br>   Journaldev jd = (Journaldev) obj;<br>   System.out.println(jd.getAuthor());<br>}</pre><p><strong>Java 14 Onwards:</strong></p><pre>if (obj instanceof Journaldev jd) {     <br>  System.out.println(jd.getAuthor());<br>}</pre><h3>Java 15:</h3><h4>- Text Blocks</h4><p>Text blocks are finally a standard feature in Java 15. A text block is a multi-line string literal.</p><p>While using text blocks, we do not need to provide explicit line terminators, string concatenations, and delimiters otherwise used for writing the normal string literals.</p><p><strong>Text blocks start with a <em>“””</em> (three double-quote marks) followed by optional whitespaces and a newline.</strong> The most simple example looks like this:</p><pre>String example = &quot;&quot;&quot;<br>   Example text<br>&quot;&quot;&quot;;<br>String json = &quot;&quot;&quot;<br>  {<br>   &quot;name&quot;: &quot;abc&quot;,<br>   &quot;age&quot;:2<br>  },<br>  {<br>   &quot;name&quot;: &quot;xyz&quot;,<br>   &quot;age&quot;:23<br>  }<br> &quot;&quot;&quot;;<br>String dbSchema =   &quot;&quot;&quot;<br>   CREATE TABLE &#39;TEST&#39;.&#39;EMPLOYEE&#39;(<br>        &#39;ID&#39; INT NOT NULL DEFAULT 0 ,<br>        &#39;FIRST_NAME&#39; VARCHAR(100) NOT NULL ,<br>        &#39;LAST_NAME&#39; VARCHAR(100) NULL ,<br>        &#39;STAT_CD&#39; TINYINT NOT NULL DEFAULT 0);<br>&quot;&quot;&quot;;</pre><h3>Java 16:</h3><h4>- Record type</h4><p>A record is a data class that stores pure data. The idea behind introducing records is to quickly create simple and concise classes devoid of boilerplate code in the model POJOs.</p><pre>public record PersonRecord(String name, int age){}<br> <br>PersonRecord personRecord = new Personrecord(&quot;Abc&quot;,1)<br>System.out.println(personRecord.age())</pre><p>The important difference between class and record is that a record aims to eliminate all the boilerplate code needed to set and get the data from the instance. Records transfer this responsibility to the Java compiler which generates the constructor, field getters, hashCode(), and equals() as well as toString() methods.</p><h4>- Add Stream.toList Method</h4><p>The aim is to reduce the boilerplate with some commonly used <em>Stream</em> collectors, such as <em>Collectors.toList</em> and <em>Collectors.toSet</em>:</p><pre>List&lt;String&gt; integersAsString = Arrays.asList(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;);<br>//Old Way<br>List&lt;Integer&gt; ints = integersAsString.stream().map(Integer::parseInt).collect(Collectors.<br>toList());<br>//From java16 onwords<br>List&lt;Integer&gt; intsEquivalent = integersAsString.stream().map(Integer::parseInt).toList();</pre><h3>Java 17:</h3><h4><strong>- Sealed Classes and Sealed Interfaces:</strong></h4><p>Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them.</p><p><strong>Syntax:</strong></p><pre>public abstract sealed class ClassName<br>permits Class1, Class2, Class3 {...}</pre><p>Note: Only final, sealed, or non-sealed classes can extend class</p><p>Example:</p><pre>class sealed abstract Write permits FileWrite {//declaration}<br>class final FileWrite extends Write {} //compile<br>class sealed abstract IOWrite extends Write permits DBWrite{}//compile<br>class CDWrite extends Write {} //*error, only  final,sealed or non-sealed class can extend sealclass<br>interface sealed Drive permits HDDrive{}<br>  <br>class non-sealed HDDrive implements Drive {}</pre><p>These are some of the important Java features that were introduced in different Java releases.</p><p>Click this link to see the main features of Java 18 and later versions.</p><p><a href="https://medium.com/@vijayaneraye/important-features-java-18-java-19-java-20-java-21-java-23-and-java-22-742d1527da7b">Important Features — Java 18, Java 19, Java 20, Java 21, Java 22 and Java 23</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=650420ee7337" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>