<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Deepak Chhitarka</title>
    <description>The latest articles on DEV Community by Deepak Chhitarka (@dchhitarka).</description>
    <link>https://dev.to/dchhitarka</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F116672%2F5045a10f-5475-4a69-a5e6-d77898879608.png</url>
      <title>DEV Community: Deepak Chhitarka</title>
      <link>https://dev.to/dchhitarka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dchhitarka"/>
    <language>en</language>
    <item>
      <title>Programming in Python - Introduction</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Sun, 12 May 2024 11:47:10 +0000</pubDate>
      <link>https://dev.to/dchhitarka/programming-in-python-introduction-16k6</link>
      <guid>https://dev.to/dchhitarka/programming-in-python-introduction-16k6</guid>
      <description>&lt;p&gt;Python is one of the most loved and used programming languages. It is known for its simplicity, readability, beginner-friendly, lower learning curve as well as vast use cases. Python is mostly used in backend development, machine learning, artificial intelligence, and game development.&lt;/p&gt;

&lt;p&gt;Python is a high-level, interpreted programming language. It was created by Guido van Rossum and first released in 1991. Python's design philosophy emphasizes code readability with its notable use of significant whitespace. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming.&lt;/p&gt;

&lt;p&gt;Python has gained immense popularity across various domains due to several reasons:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ease of Learning: Python's syntax is clear and easy to understand, making it an ideal choice for beginners. Its simplicity reduces the time required to develop, debug, and maintain code.  

Versatility: Python supports a wide range of applications, including web development, data analysis, artificial intelligence, scientific computing, automation, and more. Its extensive standard library and third-party modules simplify development across diverse domains.  

Community and Ecosystem: Python has a vibrant and supportive community. It boasts an extensive ecosystem of libraries, frameworks, and tools contributed by developers worldwide, enhancing productivity and accelerating development.  

Cross-Platform Compatibility: Python runs on various platforms, including Windows, macOS, and Linux, ensuring seamless portability of code across different environments.  

Scalability: Python's scalability allows it to be used for small scripts to large-scale enterprise applications. It powers some of the world's most popular websites and applications.  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this &lt;a href="https://codeunlock.in/admin/posts/programming-in-python-introduction"&gt;Programming in Python&lt;/a&gt; series, I will try to cover as much as possible about Python from the basic beginner level to all the way to advance concepts, from writing simple program to error handling, from OOPs to Concurrency &amp;amp; Multithreading, from webscrapping to asynchronous programming.&lt;/p&gt;

&lt;p&gt;I will also try to cover some of the popular frameworks and libraries in python such as django, flask, pandas, numpy etc.&lt;/p&gt;

&lt;p&gt;In the next post, I will write about how to install python and get started with writing python code and getting your hands dirty.&lt;/p&gt;

&lt;p&gt;Stay tuned!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Top 5 text editors for developers</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Sun, 04 Sep 2022 07:01:22 +0000</pubDate>
      <link>https://dev.to/dchhitarka/top-5-text-editors-for-developers-29c0</link>
      <guid>https://dev.to/dchhitarka/top-5-text-editors-for-developers-29c0</guid>
      <description>&lt;p&gt;A text editor might sound like a not so important tool for everyone, but for many it is one of the most important and useful application.&lt;/p&gt;

&lt;p&gt;Text Editor, as it's name implies, is a tool to write and edit any kind of text, be it your code, essay, homework, task list, etc. &lt;/p&gt;

&lt;p&gt;Developers use text editors to write their code and therefore these are also called code editors by some. Any kind of plain text can be edited in these application.&lt;/p&gt;

&lt;p&gt;Now a days, text editors are getting over powered and more powers can be added by injecting plugins into them.&lt;/p&gt;

&lt;p&gt;So, now comes the question - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which text editor to use? &lt;strong&gt;or&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt; What are the most used text editors?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When it comes to a popular applications, one can find huge amount of options in the market which can be quite overwhelming for beginners. &lt;/p&gt;

&lt;p&gt;And for something as useful and important as text editor, one can imagine the number of such applications available. &lt;/p&gt;

&lt;p&gt;In this article, I will be listing few of the most used and popular text editors available for use.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;VS Code&lt;/li&gt;
&lt;li&gt;Sublime Text&lt;/li&gt;
&lt;li&gt;Atom&lt;/li&gt;
&lt;li&gt;Notepad++&lt;/li&gt;
&lt;li&gt;Vim&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  1. VS Code
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.thenewstack.io%2Fmedia%2F2021%2F10%2F4f0ac3e0-visual_studio_code.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.thenewstack.io%2Fmedia%2F2021%2F10%2F4f0ac3e0-visual_studio_code.png"&gt;&lt;/a&gt;&lt;br&gt;
VS Code is one of the best, if not the best, code editor available currently which can be used on almost all kinds of platforms, be it &lt;strong&gt;Linux&lt;/strong&gt;, &lt;strong&gt;Windows&lt;/strong&gt;, &lt;strong&gt;macOS&lt;/strong&gt;,  &lt;strong&gt;web browsers&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;It is &lt;strong&gt;free&lt;/strong&gt; and &lt;strong&gt;open source&lt;/strong&gt; and has huge community support and was developed by the tech giant, &lt;strong&gt;Microsoft&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VS Code is a lightweight but powerful source code editor&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;It supports almost all kinds of programming languages. So you can write your code in language you want. If it is missing any feature that you want, then there most probably is an extension available which does exactly what you want as it has a huge community of developers who publishes new extensions every day. It is the one stop solution for all your needs.&lt;/p&gt;

&lt;p&gt;VS Code can be downloaded from it's official website &lt;a href="https://code.visualstudio.com" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Sublime Text
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2Fd%2Fd2%2FSublime_Text_3_logo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2Fd%2Fd2%2FSublime_Text_3_logo.png"&gt;&lt;/a&gt;&lt;br&gt;
Sublime Text Editor is one of the most widely used text editor. It offers a free version for testing, but all continual users are required to pay $99 to keep it active. &lt;/p&gt;

&lt;p&gt;Sublime Text is a multi-platform text editor that supports a number of helpful commands to improve efficiency. You can use them to find code within files in seconds. In addition, this text editor automatically generates an index of all functions and methods. That helps you to work with the shortcuts and modify them for locating bits of code while editing.&lt;/p&gt;

&lt;p&gt;It's main advantage is that it is very lightweight (low resource usage), so it can be used on your older systems with very small RAM and older CPUs. &lt;/p&gt;

&lt;p&gt;It's free version has all the features you need from a text editor. &lt;br&gt;
It is available for all major Operating Systems such as &lt;strong&gt;Windows&lt;/strong&gt;, &lt;strong&gt;Linux&lt;/strong&gt;, and &lt;strong&gt;macOS&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;You can download and try &lt;strong&gt;Sublime Text Editor&lt;/strong&gt; from &lt;a href="https://www.sublimetext.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Atom
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcQHjpJTym0XM3Ax9a0rZLCAF4Lsyk3oRfXvYQ%26usqp%3DCAU" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcQHjpJTym0XM3Ax9a0rZLCAF4Lsyk3oRfXvYQ%26usqp%3DCAU"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Atom&lt;/strong&gt; is a free and open source text editor developed by &lt;strong&gt;Github&lt;/strong&gt;. It is one of the most popular and widely used text editor which can be downloaded and used for free on all kinds of Operating Systems such as &lt;strong&gt;Windows&lt;/strong&gt;, &lt;strong&gt;Linux&lt;/strong&gt;, and &lt;strong&gt;macOS&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;It has a large community of developers which means it gets consistent updates and new themes and packages.&lt;br&gt;
It has collaborative editing and creation can be possible in real-time. It also includes multiple panes for comparing &amp;amp; editing code side by side&lt;/p&gt;

&lt;p&gt;Since this editor was designed exclusively with web technologies like HTML, JavaScript, and CSS. That's why over a short time period, it becomes the developer's first choice as they feel comfortable working with Atom.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Github&lt;/strong&gt; has announced that &lt;strong&gt;Atom and all repositories under Atom will be archived on December 15, 2022&lt;/strong&gt;. That means it will not be supported by Github anymore. But given the huge community it has, I doubt Atom will die that soon.&lt;/p&gt;

&lt;p&gt;You can download Atom from &lt;a href="https://atom.io/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Notepad++
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcRBYhsLA9hO4YEOx1V-DBtlIxvtoj3ip2zrkrsPRO8U%26s" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcRBYhsLA9hO4YEOx1V-DBtlIxvtoj3ip2zrkrsPRO8U%26s"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://notepad-plus-plus.org/" rel="noopener noreferrer"&gt;Notepad++&lt;/a&gt; is a free and open-source source code editor and is a favorite of many programmers like me. The uncluttered experience and additional features make it an ideal choice for source code editing.&lt;/p&gt;

&lt;p&gt;The only problem is that it is available exclusively for &lt;strong&gt;Windows&lt;/strong&gt; user. So, if you want to use it in other OS such as &lt;strong&gt;linux&lt;/strong&gt;, then there are some workarounds which can be used to install Notepad++ on them.&lt;/p&gt;

&lt;p&gt;It has all major features such as code highlighting, code auto completion, File Tree view, supports for all major programming languages, etc.&lt;/p&gt;

&lt;p&gt;Notepad++ can be downloaded from &lt;a href="https://notepad-plus-plus.org/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Vim
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.vim.org%2Fimages%2Fvim_header.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.vim.org%2Fimages%2Fvim_header.gif"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.vim.org/" rel="noopener noreferrer"&gt;Vim&lt;/a&gt; text editor is a stable, reliable editor that integrates with many popular tools with support for Windows, Linux, and Mac. &lt;/p&gt;

&lt;p&gt;It’s designed for use both from a command-line interface (CLI) and as a standalone application in a graphical user interface (GUI).&lt;/p&gt;

&lt;p&gt;Vim was first released in 1991, so it serves the developers for the last twenty years. It's also one of the oldest text editors available on the market. Still, developers are releasing new scripts and updates for this text editor.&lt;/p&gt;

&lt;p&gt;It has 12 different editing modes such as a visual mode that highlights the area of text, a command-line mode, and an easy mode. Here, you'll get a large number of plugin extensions available to add additional functionality.&lt;/p&gt;

&lt;p&gt;Vim is not for beginners as it has steep learning curve but it is one of the most powerful text editor. It can be seen by the fact that even though it was released some 20 years ago and many new text editors have released in these years, Vim is still one of the widely used text editor with a large community of developers supporting it.&lt;/p&gt;

&lt;p&gt;Vim can be downloaded from &lt;a href="https://www.vim.org/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are tons of powerful text editors available which I haven't covered here. So, this list is not the only list you will find. You can share your favourite text editor in the comments.&lt;/p&gt;

&lt;p&gt;Read the original article and other such interesting articles &lt;a href="https://codeunlock.in/posts/top-5-text-editors-for-developers" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>texteditors</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Linux Mint 21 Vanessa released - New features and changes</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Sat, 27 Aug 2022 07:19:50 +0000</pubDate>
      <link>https://dev.to/dchhitarka/linux-mint-21-vanessa-released-new-features-and-changes-5cki</link>
      <guid>https://dev.to/dchhitarka/linux-mint-21-vanessa-released-new-features-and-changes-5cki</guid>
      <description>&lt;p&gt;Linux mint version &lt;strong&gt;21&lt;/strong&gt; code named &lt;strong&gt;Vanessa&lt;/strong&gt; was released recently based on &lt;strong&gt;Ubuntu 22.04&lt;/strong&gt; which is a long term support release and will be supported until &lt;strong&gt;2027&lt;/strong&gt;.  It comes with updated software and brings refinements and many new features to make your desktop experience more comfortable. Let us take a look at some of the major changes and updates.&lt;/p&gt;

&lt;h4&gt;
  
  
  Blueman replaces Blueberry
&lt;/h4&gt;

&lt;p&gt;In Linux Mint 21 Blueman replaces Blueberry.&lt;br&gt;
Blueman is desktop-agnostic similar to Blueberry and integrates well in all environments. &lt;/p&gt;

&lt;p&gt;Blueberry depended on gnome-bluetooth, which was developed exclusively for GNOME. In contrast, Blueman relies on the standard Bluez stack which works everywhere and can even be used or queried from the command line. &lt;/p&gt;

&lt;p&gt;Blueman's UI was polished for mint and looks much better than before. Blueman also received support for many symbolic icons which gives it a much more refined look and integrates it with other mint's applications. &lt;/p&gt;

&lt;p&gt;It has many features out of the box which you might find missing from Blueberry. The Blueman manager and tray icon provide many features that weren't available in Blueberry and a lot more information which can be used to monitor your connection or troubleshoot Bluetooth issues.&lt;/p&gt;

&lt;p&gt;Out of the box Blueman features better connectivity, especially when it comes to headsets and audio profiles.&lt;/p&gt;

&lt;p&gt;Blueman and Bluez are actively developed by the open source community and used in many environments.&lt;/p&gt;

&lt;h4&gt;
  
  
  Thumbnailers
&lt;/h4&gt;

&lt;p&gt;Earlier Linux Mint's file explorer, &lt;strong&gt;Nemo File Explorer&lt;/strong&gt;, lacked support for some file types. To address it a new Xapp project called &lt;strong&gt;xapp-thumbnailers&lt;/strong&gt; was started and is now featured in Linux Mint 21.&lt;/p&gt;

&lt;p&gt;The project brings support for the following mimetypes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  AppImage&lt;/li&gt;
&lt;li&gt;  ePub&lt;/li&gt;
&lt;li&gt;  MP3 (album cover)&lt;/li&gt;
&lt;li&gt;  RAW pictures (most formats)&lt;/li&gt;
&lt;li&gt;  Webp&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Sticky Notes
&lt;/h4&gt;

&lt;p&gt;Sticky notes is an application which we all have used at least once. It is a handy and useful tool which helps in remembering things, taking notes and sticking them to the desktop.&lt;/p&gt;

&lt;p&gt;The Sticky Notes application now has the ability to duplicate notes. When Sticky Notes is told to pick different colors for newly created notes it no longer picks them randomly, but cycles through the color set to maximize the probability of each note having a different color.&lt;/p&gt;

&lt;p&gt;Some other changes are - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The systray icon was restyled.&lt;/li&gt;
&lt;li&gt;New notes are positioned relative to their parent.&lt;/li&gt;
&lt;li&gt;Clicking the tray icon creates a new note if none are present.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Cinnamon 5.4
&lt;/h4&gt;

&lt;p&gt;Linux Mint 21 features a new version of cinnamon, &lt;strong&gt;Cinnamon 5.4&lt;/strong&gt;, which has many new exciting changes and improvements. The most noticeable and biggest change among them is the Mutter rebase.&lt;/p&gt;

&lt;h5&gt;
  
  
  Mutter Rebase
&lt;/h5&gt;

&lt;p&gt;Muffin is the windows manager used by cinnamon. It is now based on Mutter 3.36 and its codebase is much closer to upstream than before.&lt;/p&gt;

&lt;p&gt;Muffin was forked from Mutter 3.2, and the plan wasn't to develop a different window manager but simply to make Cinnamon compatible with all distributions of Linux by guaranteeing it had the same manager everywhere, no matter what version of Mutter was shipped. &lt;/p&gt;

&lt;p&gt;Long story short, the Muffin codebase became very different from Mutter and, so this release brings them closer to each other once again.&lt;/p&gt;

&lt;h5&gt;
  
  
  Other Improvements
&lt;/h5&gt;

&lt;p&gt;Along with bug fixes Cinnamon 5.4 also features the following improvements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The CJS interpreter, which was previously based on GJS 1.66.2, was rebased on GJS 1.70.&lt;/li&gt;
&lt;li&gt;  The settings daemon features improved MPRIS support.&lt;/li&gt;
&lt;li&gt;  Right-clicking an application in the main menu, shows a context menu. If the application provides commands, these commands are now added to this menu.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Some other noticeable changes includes
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Process Monitor was added to Linux Mint to detect automated updates and automated system snapshots running in the background.&lt;/li&gt;
&lt;li&gt;Timeshift is now maintained as an XApp and its translations are done on Launchpad.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To read more about Linux Mint 21, check out Linux Mint's official blog &lt;a href="https://www.linuxmint.com/rel_vanessa_cinnamon_whatsnew.php"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Read the original article &lt;a href="https://codeunlock.in/posts/linux-mint-21-vanessa-released-new-features-and-changes"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you tried out Linux Mint 21 yet? Share your thoughts in the comments below. &lt;/p&gt;

</description>
      <category>linux</category>
      <category>opensource</category>
      <category>release</category>
      <category>new</category>
    </item>
    <item>
      <title>Introduction to Programming - Compiler and Interpreter</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Sun, 08 May 2022 09:45:08 +0000</pubDate>
      <link>https://dev.to/dchhitarka/introduction-to-programming-compiler-and-interpreter-23a4</link>
      <guid>https://dev.to/dchhitarka/introduction-to-programming-compiler-and-interpreter-23a4</guid>
      <description>&lt;p&gt;We have talked about what is programming, and we have also talked about different programming paradigms and some of the languages which follow those paradigms. Now, let us talk about how these programs are executed by the computer.&lt;/p&gt;

&lt;p&gt;In the article &lt;a href="%5Bhttps://codeunlock.in/posts/introduction-to-programming-what-is-programming%5D(https://codeunlock.in/posts/introduction-to-programming-what-is-programming)"&gt;&lt;strong&gt;Introduction to programming — What is programming?&lt;/strong&gt;&lt;/a&gt;, I briefly explained that Programming languages are used to write code which is then translated into machine-level code which is understood by the computer. This translation is done with the help of tools such as &lt;strong&gt;compilers&lt;/strong&gt; or &lt;strong&gt;interpreters&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Some languages use compilers while others use interprets for this task. Based on this, languages are often termed as &lt;strong&gt;compiled language&lt;/strong&gt; and &lt;strong&gt;interpreted language&lt;/strong&gt;. Let us discuss these both in detail.&lt;/p&gt;

&lt;h3&gt;
  
  
  COMPILER
&lt;/h3&gt;

&lt;p&gt;A compiler is a translator that takes a high-level programming language such as &lt;strong&gt;Java&lt;/strong&gt; as input and produces an output of low-level language (like an assembly or machine language).&lt;/p&gt;

&lt;p&gt;It is basically a computer program used to transform codes written in a programming language into machine code (human-readable code to a binary 0 and 1 bits language for a computer processor to understand).&lt;/p&gt;

&lt;p&gt;The computer then processes the machine code for performing the corresponding tasks.&lt;/p&gt;

&lt;p&gt;The compiler takes the whole code, checks all types of errors, limits, and ranges, and compiles it into machine code which is then executed by the computer. If any changes are made to the code, then the whole code needs to be re-compiled only then will the changes reflect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The time required by the compiler to compile the code is called &lt;strong&gt;compile-time&lt;/strong&gt; where as the time used while executing the code is termed as &lt;strong&gt;run-time&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;In case of compiled languages, &lt;strong&gt;compile-time&lt;/strong&gt; is relative longer while the &lt;strong&gt;run-time&lt;/strong&gt; is shorter as the code is already translated into machine-level code and the computer just need to run that code.&lt;/p&gt;

&lt;p&gt;Compiler stores the translated machine code and execute it every time the code is run. So, it requires more memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Java&lt;/strong&gt;, &lt;strong&gt;C++&lt;/strong&gt;, &lt;strong&gt;C#&lt;/strong&gt;, &lt;strong&gt;Go&lt;/strong&gt; etc., are some of the most widely used high-level programming languages using compiler for translation of their code to machine level code.&lt;/p&gt;

&lt;p&gt;Compiled languages often termed as statically typed programming languages as Compilers are very difficult to implement because they can’t predict anything that happens during the turn time.&lt;/p&gt;

&lt;h3&gt;
  
  
  INTERPRETER
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Interpreter&lt;/strong&gt; is a program that functions for the translation of a programming language into a comprehensible one. It is a computer program used for converting high-level program statements into machine codes. It includes pre-compiled code, source code, and scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interpreter&lt;/strong&gt; is similar to &lt;strong&gt;compiler&lt;/strong&gt; as it also translates high-level programming languages into machine code but the difference is that unlike compiler, interpreter reads the code &lt;strong&gt;line by line&lt;/strong&gt;, check for any error in that line and then convert that line or statement to machine code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interpreter&lt;/strong&gt; does not store the machine level code, so it takes &lt;strong&gt;less memory&lt;/strong&gt; but since the code is not stored, it is generated every time the code is run.&lt;/p&gt;

&lt;p&gt;Also, since code is not compiled, it has no compile-time, but it’s run-time is very large compared to compiler as every time it converts the high-level programming language code into machine level code line by line or statement by statement.&lt;/p&gt;

&lt;p&gt;We will not be able to find all the errors in our code at a time, as the interpreter will stop interpreting the code at the line where it finds any error. Until that error is not fixed, it will not move past that line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt;, &lt;strong&gt;PHP&lt;/strong&gt;, &lt;strong&gt;JavaScript&lt;/strong&gt;, &lt;strong&gt;Ruby&lt;/strong&gt; etc., are some of the most widely used high-level programming languages using interpreter for translation of their code to machine level code.&lt;/p&gt;

&lt;p&gt;These languages are often called as dynamically typed languages as they support &lt;strong&gt;Dynamic Typing&lt;/strong&gt; as interpreter executes code line by line, so at run time, it dynamically determines the type of variables used.&lt;/p&gt;

&lt;p&gt;One major advantage of interpreter is that you can run just a single line of code and see it’s output where as in case of compiler you need to first compile the whole code and then run it.&lt;/p&gt;

&lt;p&gt;If you liked the article, then please give it a thumb-up.&lt;/p&gt;

&lt;p&gt;Read other articles of the series &lt;a href="https://codeunlock.in/tags/intro-to-programming"&gt;&lt;strong&gt;Introduction to programming&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>introtoprogramming</category>
      <category>beginners</category>
      <category>compilers</category>
      <category>interpreters</category>
    </item>
    <item>
      <title>Sieve of Eratosthenes - Program to find all prime numbers smaller than a given number</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Sun, 17 Apr 2022 12:05:40 +0000</pubDate>
      <link>https://dev.to/dchhitarka/sieve-of-eratosthenes-program-to-find-all-prime-numbers-smaller-than-a-given-number-3a3a</link>
      <guid>https://dev.to/dchhitarka/sieve-of-eratosthenes-program-to-find-all-prime-numbers-smaller-than-a-given-number-3a3a</guid>
      <description>&lt;p&gt;&lt;strong&gt;Sieve of Eratosthenes&lt;/strong&gt; is a very old algorithm to find all the prime numbers up to a given limit. For example, we can find all the prime numbers up to, say 101, using this algorithm in a very efficient manner.&lt;/p&gt;

&lt;p&gt;It does so by iteratively marking as composite the multiples of each prime, starting with the first prime number, 2. The multiples of a given prime are generated as a sequence of numbers starting from that prime, with constant difference between them that is equal to that prime.&lt;/p&gt;

&lt;p&gt;Instead of checking every number as prime(brute force approach), we would work on the groups. First, we will create a vector of boolean values where all values are &lt;strong&gt;true&lt;/strong&gt;. The rest of the work is going to be on this vector only.&lt;/p&gt;

&lt;p&gt;The length of the vector is equal to the limit up to which we find all prime numbers, say &lt;strong&gt;N&lt;/strong&gt;. Now, in that vector, assign all the even index starting from 3 as &lt;strong&gt;false&lt;/strong&gt; as all even numbers except 2 are non primes.  &lt;/p&gt;

&lt;p&gt;Now, for all odd numbers, mark their multiples as &lt;strong&gt;false&lt;/strong&gt; as well as they are non prime as well. &lt;/p&gt;

&lt;p&gt;Now mark 0th and 1st index as &lt;strong&gt;false&lt;/strong&gt; as well.&lt;/p&gt;

&lt;p&gt;All other indexes set to &lt;strong&gt;true&lt;/strong&gt; are the prime numbers upto &lt;strong&gt;N&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;sieveOfEratosthenes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Create a boolean array of length n+1 for all numbers from 0 to n&lt;/span&gt;
    &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isPrime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="c1"&gt;// Set all the elements to true in the isPrime array&lt;/span&gt;
    &lt;span class="n"&gt;memset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isPrime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isPrime&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// If isPrime[p] is true, then it is a prime&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isPrime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Update all multiples&lt;/span&gt;
            &lt;span class="c1"&gt;// of p greater than or&lt;/span&gt;
            &lt;span class="c1"&gt;// equal to the square of it&lt;/span&gt;
            &lt;span class="c1"&gt;// numbers which are multiple&lt;/span&gt;
            &lt;span class="c1"&gt;// of p and are less than p^2&lt;/span&gt;
            &lt;span class="c1"&gt;// are already been marked.&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;isPrime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isPrime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
            &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Driver Code&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Prime numbers smaller "&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" than or equal to "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;sieveOfEratosthenes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Time complexity of classic Sieve of Eratosthenes algoeithm is &lt;strong&gt;O(N log (log N))&lt;/strong&gt;.  Many variations of this algorithm can also be found with even better time complexities.&lt;/p&gt;

&lt;p&gt;Read the original article &lt;a href="https://codeunlock.in/posts/how-to-find-all-prime-numbers-smaller-than-a-given-number-sieve-of-eratosthenes"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Read more such articles &lt;a href="https://codeunlock.in/"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mathematics</category>
      <category>programming</category>
      <category>cpp</category>
    </item>
    <item>
      <title>How to find GCD of two or more numbers?</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Fri, 01 Apr 2022 15:34:19 +0000</pubDate>
      <link>https://dev.to/dchhitarka/how-to-find-gcd-of-two-or-more-numbers-ibi</link>
      <guid>https://dev.to/dchhitarka/how-to-find-gcd-of-two-or-more-numbers-ibi</guid>
      <description>&lt;p&gt;Programming in general does not require knowledge of advanced maths concepts, but having basic mathematics knowledge is always helpful especially in the case of Competitive Programming (CP). &lt;/p&gt;

&lt;p&gt;It does not hurt to learn some concepts and tricks which might come handy. One such concept is finding &lt;strong&gt;Greatest Common Divisor (GCD)&lt;/strong&gt; of two or more numbers. It might not be used directly, it can still give you a basic idea of how to solve mathematical problems using programming. &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;In mathematics, the greatest common divisor (GCD), also called the greatest common factor of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers. For two integers x, y, the greatest common divisor of x and y is denoted gcd(x,y). For example, gcd(8,12) is 4 as 4 is the greatest positive number which divides both 8 and 12.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Applications of GCD
&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The GCD is used for a number of applications both simple and complex. In fact, you've likely implicitly calculated GCDs without recognizing it when simplifying fractions: reducing a fraction is a matter of dividing both the numerator and denominator by their GCD.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The GCD is also used in the extended Euclidean algorithm to compute modular inverses, which are of extreme importance in encryption schemes such as RSA. Hence it is an important tool in cryptography.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;I will be using C++ to write a program to find GCD of 2 or more numbers. As always, there are multiple ways to solve this problem and I will be discussing about 2 or 3 of them.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  1. GCD Using for loop and if Statement
&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This method can be considered as a Brute Force approach, as we iterate over all the numbers starting from 1 till the smallest of the numbers whose GCD we have to find out. Then for each of these numbers, we check if it completely divides all the numbers. If yes, then we call it gcd and move on to next number and repeat the process as we need the greatest number which divides them all completely.&lt;/p&gt;




&lt;p&gt;NOTE: The below code is for 2 numbers only. It can be generalised for n numbers as well by dividing each number with all the numbers instead of just 2 of them or by calling the gcd function again and again with the gcd of first 2 numbers and the next number and repeat this process.&lt;/p&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="c1"&gt;// Checks if i is factor of both integers&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;gcd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"Enter two integers: &lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cin&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"G.C.D of "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" and "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" is "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  2. GCD Using while loop and if Statement
&lt;/h3&gt;

&lt;p&gt; &lt;br&gt;
This is a better way to find the GCD. In this method, smaller integer is subtracted from the larger integer, and the result is assigned to the variable holding larger integer. This process is continued until n1 and n2 are equal.&lt;br&gt;
 &lt;/p&gt;



&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: The below code is for 2 numbers only. It can be generalised for n numbers as well by calling the gcd function again and again with the gcd of first 2 numbers and the next number and repeat this process.&lt;/p&gt;




&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
            &lt;span class="n"&gt;n2&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"Enter two integers: &lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cin&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"G.C.D of "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" and "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" is "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  3. GCD Using Euclidean Algorithm
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Euclidean algorithm&lt;/strong&gt; is one of the most efficient algorithm used for calculating gcd of 2 or more numbers. We use the modulo operation in this approach i.e. divide the larger number by smaller number and take the remainder. Now, the larger number is swapped by the smaller number and the smaller number is swapped by the remainder and we repeat the whole process until the remainder is not 0. &lt;/p&gt;

&lt;p&gt;For more than 2 numbers, we can first find gcd of 2 numbers and then use the gcd along with next number find this pair's gcd and keep repeating until all the numbers are used. We can also use recursion to solve this problem.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;gcd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;n2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"Enter two integers: &lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cin&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gcd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"G.C.D of "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;n1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" and "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" is "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Share your thoughts in the comments below and if you liked the article, then give it a thumbs up.&lt;/p&gt;

&lt;p&gt;You can check out my blog &lt;a href="https://codeunlock.in/"&gt;https://codeunlock.in/&lt;/a&gt; to read other such articles.&lt;/p&gt;

</description>
      <category>gcd</category>
      <category>programming</category>
      <category>mathematics</category>
    </item>
    <item>
      <title>Introduction to Programming - What is Programming Paradigm?</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Sun, 27 Mar 2022 18:56:15 +0000</pubDate>
      <link>https://dev.to/dchhitarka/introduction-to-programming-what-is-programming-paradigm-3le1</link>
      <guid>https://dev.to/dchhitarka/introduction-to-programming-what-is-programming-paradigm-3le1</guid>
      <description>&lt;p&gt;First of all, let us understand what is Paradigm? Paradigm, in simpler terms, can be referred to as a pattern or model or a blueprint. It is a distinct set of concepts or patterns, including theories, research methods, postulates, and standards for what constitutes legitimate contributions to a field.&lt;/p&gt;

&lt;p&gt;So Programming Paradigm can be inferred as a model for programming. How programs and in general programming languages should be written, what patterns they should follow, and how these languages work. A programming paradigm is a style, or “way,” of programming.&lt;/p&gt;

&lt;p&gt;There are so many such paradigms out there, but I will be talking about some of the most widely used and followed paradigms. I hope you understand the meaning of "Programming Paradigm".&lt;/p&gt;

&lt;p&gt;Programming languages are based on a certain paradigm, a set of rules which needs to be followed while working with that language. &lt;/p&gt;

&lt;p&gt;Programming Paradigms can be generally divided into 2 main kinds, Imperative, and Declarative Programming Paradigm. These 2 can be further divided into different kinds of paradigms in use today.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. IMPERATIVE PROGRAMMING
&lt;/h2&gt;

&lt;p&gt;It is one of the oldest programming paradigms and is based on Von Neumann's architecture. &lt;br&gt;
Its name comes from the Latin imperare meaning “command” or instructions. It works as closely as possible with the system and thus has a close relation to machine architecture.&lt;/p&gt;

&lt;p&gt;It works by changing the program state through assignment statements. It performs step by step tasks by changing state. Older languages like Pascal and C, as well as all assembly languages are based on it.&lt;/p&gt;

&lt;h4&gt;
  
  
  1a. PROCEDURAL PROGRAMMING
&lt;/h4&gt;

&lt;p&gt;The procedural programming paradigm extends the imperative approach with the possibility of dividing algorithms into more manageable sections. This paradigm emphasizes procedure in terms of the underlying machine model. There is no difference between the procedural and imperative approaches. &lt;/p&gt;

&lt;p&gt;It has the ability to reuse the code and it was a boon at that time when it was in use because of its reusability.&lt;br&gt;
Depending on the programming language, these are referred to as sub-programs, routines, or functions. &lt;/p&gt;

&lt;p&gt;The purpose of this division is to make the programming code clearer and to prevent unnecessary code repetitions. C is an example of procedural programming language.&lt;/p&gt;

&lt;h4&gt;
  
  
  1b. OBJECT ORIENTED PROGRAMMING
&lt;/h4&gt;

&lt;p&gt;Object Oriented Programming paradigm is one of the most popular and widely used paradigms. Most of today's high-level languages support object oriented programming or are object oriented programming (OOP) languages. Examples are Java, C++, Python, etc.&lt;/p&gt;

&lt;p&gt;It is based on classes and objects which are meant for communication. The smallest and basic entity is an object and all kinds of computation are performed on the objects only. More emphasis is on data rather procedure. &lt;/p&gt;

&lt;p&gt;It can handle almost all kinds of real life problems which are today in the scenario.&lt;/p&gt;

&lt;h4&gt;
  
  
  1c. STRUCTURED PROGRAMMING
&lt;/h4&gt;

&lt;p&gt;The structured programming method is a simplified form of imperative programming. The crucial difference from the basic principle is that instead of absolute jump commands (instructions that lead to processing continuing at another point instead of the next command), this software programming paradigm makes use of control loops and structures.&lt;/p&gt;

&lt;p&gt;An example is the use of “do...while”, which executes an instruction automatically for as long as a particular condition is true (at least once).&lt;/p&gt;

&lt;h2&gt;
  
  
  2. DECLARATIVE PROGRAMMING
&lt;/h2&gt;

&lt;p&gt;Declarative Programming is divided as Logic, Functional, Data. In computer science, the term declarative programming is a style of building programs that express the logic of a computation without talking about its control flow.&lt;/p&gt;

&lt;p&gt;The fundamental principle of declarative programming is that it describes the desired result. The focus is on what needs to be done rather than how it should be done emphasizing what the code is doing. &lt;/p&gt;

&lt;p&gt;This is the only difference between imperative (how to do) and declarative (what to do) programming paradigms.&lt;/p&gt;

&lt;h4&gt;
  
  
  2a. LOGIC PROGRAMMING
&lt;/h4&gt;

&lt;p&gt;Logic programming, also known as predicate programming, is based on mathematical logic. Instead of a sequence of instructions, it contains a set of principles, which can be understood as a collection of facts and assumptions.&lt;/p&gt;

&lt;p&gt;It can be termed as an abstract model of computation. It would solve logical problems like puzzles, series, etc. &lt;/p&gt;

&lt;p&gt;In logic programming we have a knowledge base that we know before and along with the question and knowledge base which is given to the machine, it produces results. Prolog is a logic programming language.&lt;/p&gt;

&lt;h4&gt;
  
  
  2b. FUNCTIONAL PROGRAMMING
&lt;/h4&gt;

&lt;p&gt;Functions exist in every higher-level programming language. However, the functional approach in software development deals with functions in a very particular way. &lt;/p&gt;

&lt;p&gt;The functional programming paradigms have their roots in mathematics and it is language independent. The key principle of this paradigm is the execution of a series of mathematical functions.&lt;/p&gt;

&lt;p&gt;A functionally programmed program is made up of a string of function calls, where each program section can be understood as a function. In functional programming, the functions can take on different forms. &lt;/p&gt;

&lt;p&gt;For example, they can be linked to one another like data or be used in the form of parameters. In addition, they can subsequently be used as function results.&lt;/p&gt;

&lt;h4&gt;
  
  
  2c. DATA DRIVEN PROGRAMMING
&lt;/h4&gt;

&lt;p&gt;As the name suggests, this paradigm is driven by data i.e. it revolves around data. Data is the main component of this paradigm. Program statements are defined by data rather than hard-coding a series of steps.&lt;/p&gt;

&lt;p&gt;Several programming languages are developed mostly for database applications such as SQL.&lt;/p&gt;

&lt;p&gt;This was the second article of the series #intro-to-programming. Please share your thoughts about the article.&lt;/p&gt;

&lt;p&gt;If you liked the article, then please give it a 👍&lt;/p&gt;

&lt;p&gt;You can check out my blog &lt;a href="https://codeunlock.in/"&gt;https://codeunlock.in/&lt;/a&gt; to find my other articles.&lt;/p&gt;

</description>
      <category>introtoprogramming</category>
      <category>begineer</category>
      <category>programmingparadigm</category>
    </item>
    <item>
      <title>Introduction to Programming — What is Programming?</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Fri, 25 Mar 2022 03:21:22 +0000</pubDate>
      <link>https://dev.to/dchhitarka/introduction-to-programming-what-is-programming-fg5</link>
      <guid>https://dev.to/dchhitarka/introduction-to-programming-what-is-programming-fg5</guid>
      <description>&lt;p&gt;When beginners starts programming, they often tend to directly start learning about the programming languages and technology stacks instead of first understanding what is programming. Even though it does not have a such a huge impact but it does help to better the foundation of programming.&lt;/p&gt;

&lt;p&gt;In this Introduction to Programming series, I will first of all explain what is programming, followed by programming languages. I will try to cover 10 to 15 most used programming languages in the upcoming articles so that everyone can get an understanding of different languages and see what fits them the best.&lt;/p&gt;

&lt;p&gt;What is Programming?&lt;/p&gt;

&lt;p&gt;Programming is an art. It is a way to talk to computers. Computers does not understand human language. So, to talk with them, to instruct them to do something programming is used. It is the process of creating a set of instructions for a computer to work on.&lt;/p&gt;

&lt;p&gt;We can find a lot of different definitions of programming online. The definition does not matter. What's important is to understand the meaning behind it.&lt;/p&gt;

&lt;p&gt;The word programming refers to writing programs, which are the instructions the computer performs. Softwares, Mobile Applications, Desktop Applications, Games all are programs which instructs the computer to perform certain tasks.&lt;/p&gt;

&lt;p&gt;The process of writing these programs is programming. And writing these programs is the job of programmers and we use programming languages to write these programs.&lt;/p&gt;

&lt;p&gt;Programming, Programming, Programming&lt;/p&gt;

&lt;p&gt;It is everywhere.&lt;/p&gt;

&lt;p&gt;Just like we human communicate with each other using languages like Hindi, English, Spanish, etc, we use computer programming languages such as C, C++, Python, Java, PHP, JavaScript, etc., to communicate with computers. And the process of communicating with computer is programming.&lt;/p&gt;

&lt;p&gt;Programming is step by step instructing the computer to perform an action. Computer are way faster and efficient than human beings but they do not understand human language. So, programming is used to bridge the communication gap and help us solve our problems.&lt;/p&gt;

&lt;p&gt;Programming Languages&lt;/p&gt;

&lt;p&gt;Computers only understands 0s and 1s. Earlier, we used to manually type 0s and 1s to instruct the computer to perform certain tasks. It was tedious, error prone and very difficult as well as time consuming.&lt;/p&gt;

&lt;p&gt;To solve this issue, programming languages were created. Even though computer still only understands the binary codes(0s and 1s) but we can write the programs in programming languages and then convert them into machine code or byte code which the computer understand.&lt;/p&gt;

&lt;p&gt;Programming languages have come a long way since the late 1950s when the first programming language was created. Now, there are 100s of different programming language for different tasks and fields but their main motive is still the same i.e. instruct the computer to perform certain tasks.&lt;/p&gt;

&lt;p&gt;Some of the most widely used programming languages are:&lt;br&gt;
• C&lt;br&gt;
• C++&lt;br&gt;
• Python&lt;br&gt;
• Java&lt;br&gt;
• JavaScipt&lt;br&gt;
• C#&lt;br&gt;
• PHP&lt;/p&gt;

&lt;p&gt;In the next article, I will be explaining about the different programming paradigms and the respective programming languages based on that paradigm. Stay tuned!&lt;/p&gt;

&lt;p&gt;Read the original and other similar articles at &lt;a href="https://codeunlock.in"&gt;https://codeunlock.in&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>introduction</category>
      <category>foundation</category>
      <category>begineer</category>
    </item>
    <item>
      <title>How to count number of digits in a number?</title>
      <dc:creator>Deepak Chhitarka</dc:creator>
      <pubDate>Wed, 15 Sep 2021 03:59:51 +0000</pubDate>
      <link>https://dev.to/dchhitarka/how-to-count-number-of-digits-in-a-number-5op</link>
      <guid>https://dev.to/dchhitarka/how-to-count-number-of-digits-in-a-number-5op</guid>
      <description>&lt;p&gt;Counting number of digits in a number is one of the most common and first problem one encounters while doing competitive programming. No language has built in functionality to perform this task, so programmers have to manually find it out and yet many new programmers does not know how to find the number of digits in an integer.&lt;/p&gt;

&lt;p&gt;It is considered a fundamental problem and is one of the first problem taught if you are doing a DSA course as this can be handy in multiple of questions that you must be aware of how to find the number of digits quickly. It covers maths fundamentals as well as programming basics and is a nice first step if you are new to competitive programming as it can be challenging for beginners.&lt;/p&gt;

&lt;p&gt;I will be using C++ code to demonstrate how to count number of digits in a number as C++ is the preferred language when it comes to competitive programming. &lt;/p&gt;

&lt;p&gt;I will be covering 4 different approaches to solve this problem&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Iterative Solution
&lt;/h3&gt;

&lt;p&gt;In this, we have a count variable and we loop over the number while incrementing the count variable. In each iteration, we divide the number by 10 and update the number with the quotient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
        &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
        &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"Enter the number: "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cin&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Recursive Solution -
&lt;/h3&gt;

&lt;p&gt;This solution is somewhat similar to the iterative solution we just discussed. In this, the base condition is when the number becomes less than 10. We just increment the count and return it. In our function, we pass 2 parameters, the number and the count variable. Each function returns it's count parameter + 1. In this way we can find the no of digits in the number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"Enter the number: "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cin&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Log Based Solution -
&lt;/h3&gt;

&lt;p&gt;This solution is pure mathematical solution. We can calculate the number of digits by just taking the log of that number with base 10 + 1 on the condition that the number is greater than 0. We can use a ternary operator to check.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"Enter the number: "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cin&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Convert to string and find it's length -
&lt;/h3&gt;

&lt;p&gt;This solution is the simplest one in my opinion as we just convert the number into string and then find the length of the string and return it. Almost all programming languages have built-in methods to find string's length and also convert integer to string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"Enter the number: "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cin&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;numOfDigits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is my first time writing blogs, so I would love to hear your feedback. You can find the original and other articles on &lt;a href="https://codeunlock.in/"&gt;https://codeunlock.in/&lt;/a&gt;&lt;/p&gt;

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