{"id":12493,"date":"2023-02-03T07:17:38","date_gmt":"2023-02-03T07:17:38","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=12493"},"modified":"2023-04-28T12:47:09","modified_gmt":"2023-04-28T12:47:09","slug":"basic-c-programs-examples","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/","title":{"rendered":"20 Simple C Programs for Beginners"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg\" alt=\"\" \/><\/p>\n<p>Many interviews generally include questions about C programs. These programs can be used to handle files, arrays, strings, pointers, linked lists, and other fundamental data types.<\/p>\n<h2>About C Programming Language<\/h2>\n<p>Dennis Ritchie developed the general-purpose computer language C at Bell Laboratories in 1972. Despite being an ancient language, it is quite popular.<br \/>\nSince the UNIX operating system was created using C, the two are closely related.<\/p>\n<h2>List of Basic C Programs.<\/h2>\n<ol>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-calculate-percentage-of-5-subjects\/\" title=\"Calculate the Percentage of 5 Subjects\"><strong>Calculate the Percentage of 5 Subjects<\/strong><\/a><br \/>\nIt is simple to calculate the percentage of five subjects, all you need to do is add all of the marks and multiply that total by 100. Then divide that by the total number of marks a student is permitted to receive. You will ultimately receive the results as a percentage of the 5 subjects.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>50 20 30 40 80<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Enter marks of five subjects:\nTotal marks = 220.00\nAverage marks = 44.00\nPercentage = 44.00<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-convert-infix-to-postfix\/\" title=\"**Convert infix to postfix**\"><strong>Convert infix to postfix<\/strong><\/a><br \/>\nAny operation may be written as an infix, prefix, or postfix, in this C language tutorial, we&#8217;ll see how to do this. Two approaches have been covered: the array-based stack approach and the struct-based stack approach.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>((p+(q*r))-s)<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>pqr*+s-<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/odd-even-program-in-c\/\" title=\"**Odd Even Program**\"><strong>Odd Even Program<\/strong><\/a><br \/>\nA number is taken into consideration even though it may be split by two equally. The remainder that is not precisely divisible by 2 is known as an odd number. Simply expressed, odd numbers adopt the form n = 2k+1, whereas even numbers take the form n = 2k. Each integer will be made up of either even or odd integers. <\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>10<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Even<\/code><\/pre>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>15<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Odd<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-find-area-of-circle\/\" title=\"**Find area of a circle**\"><strong>Find area of a circle<\/strong><\/a><br \/>\nEveryone knows the basics of mathematics,<br \/>\nFor finding the area of a circle, we can get this by performing some<\/p>\n<pre><code>Area = Pie * Radius * Radius<\/code><\/pre>\n<p>Where the value of pie = 3.14 and the radius will be given by the user.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>10<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>The radius of the circle is 10\nThe area of a given circle is 314.000000<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-convert-celsius-to-fahrenheit\/\" title=\"**Convert Celsius to Fahrenheit**\"><strong>Convert Celsius to Fahrenheit<\/strong><\/a><br \/>\nIn the realm of programming, we may easily convert between celsius and fahrenheit by carrying out a few simple mathematical operations.<br \/>\nThe formula to change from celsius to fahrenheit is shown below.<\/p>\n<p><strong>Formula<\/strong><\/p>\n<pre><code>Fahrenheit Temperature = (1.8 * celsius) + 32;<\/code><\/pre>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>40<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>104<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-add-two-numbers\/\" title=\"**Add two numbers**\"><strong>Add two numbers<\/strong><\/a><br \/>\nIn the C programming language, the phrase &quot;sum of two integers&quot; refers to adding two integer values and printing the addition of two integer values and the printing of the result. To combine two numbers, all we need to do is utilize the &quot;+&quot; operator. In the link above, we have also explained several techniques.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>10 20<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>30<\/code><\/pre>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>20 20<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>40<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/binary-search-program-in-c\/\" title=\"**Binary Search program in C**\"><strong>Binary Search program in C<\/strong><\/a><br \/>\nIn the C programming language, a sorted array may be searched using a technique called binary search by continually halving the search interval. In order to reduce the time complexity to O, binary search makes use of the fact that the array is sorted (LogN).<br \/>\nThis approach always searches the center of an array for the element.<br \/>\nThere are two ways to create a binary search program in C:<\/p>\n<ul>\n<li>Iterative Method <\/li>\n<li>Recursive Method<\/li>\n<\/ul>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>[11, 14, 25, 30, 40, 45]<\/code><\/pre>\n<p>40<br \/>\n<strong>Output:<\/strong><\/p>\n<pre><code>Element is present at position 4<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/priority-scheduling-program-in-c\/\" title=\"**Priority Scheduling program in C**\"><strong>Priority Scheduling program in C<\/strong><\/a><br \/>\nThe algorithms prioritize the processes that must be carried out and schedule them accordingly. A higher-priority process will receive CPU priority first, and this will continue until all of the processes are finished. Due to the process&#8217; greater priority, the Priority Scheduling Algorithm is in charge of transferring it from the ready queue to the work queue.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>{{1, 10, 2}, {2, 5, 0}, {3, 8, 1}}<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Order in which processes get executed \n1 3 2<\/code><\/pre>\n<p>Processes      Burst time     Waiting time     Turn around time<br \/>\n1                10                 0                      10<br \/>\n3                 8                 10                     18<br \/>\n2                 5                 18                     23<\/p>\n<p><strong>Average waiting time<\/strong> = 9.33333<br \/>\n<strong>Average turn around time<\/strong> = 17<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-find-roots-of-quadratic-equation\/\" title=\"**Find roots of quadratic equation**\"><strong>Find roots of quadratic equation<\/strong><\/a><br \/>\nA quadratic has the formula y = ax^2 + bx + c, where a, b, and c are all integers and a must be 0. An illustration of a quadratic equation is 3&#215;2 + 3x + 1.<br \/>\nLet&#8217;s talk about what a quadratic equation&#8217;s roots are and how to get them from the equation.<br \/>\nThe discriminant of a quadratic equation is the expression b2 &#8211; 4ac. It describes the roots&#8217; character.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>a = 2.4 b = 4 c = 506<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>root1 = -0.87+1.30i and root2 = -0.87-1.30i<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-convert-binary-number-to-decimal-number\/\" title=\"**Convert binary numbers to decimal number**\"><strong>Convert binary numbers to decimal number<\/strong><\/a><br \/>\nIn order to convert a binary number to a decimal number, we must multiply each digit of the binary number starting at 0 by powers of 2 and then sum the results to obtain the decimal number.<\/p>\n<p><strong>Input:<\/strong><br \/>\n111<br \/>\n<strong>Output:<\/strong><\/p>\n<pre><code>7<\/code><\/pre>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>0101<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>5<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-sort-an-array-in-ascending-order\/\" title=\"**Ascending order program in C language**\"><strong>Ascending order program in C language<\/strong><\/a><br \/>\nDifferent kinds of reasoning can be used to sort things. For the sake of simplicity, we shall employ a tried-and-true technique. We choose a certain element from an array, compare it to other elements, and then place it appropriately to sort the array.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>Arr[50, 20, 100, 25, 36]<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>20 25 36 50 100<\/code><\/pre>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>Arr[5, 8, 2, 1, 6]<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>1 2 5 6 8<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/sjf-scheduling-program-in-c\/\" title=\"**SJF Scheduling program in C**\"><strong>SJF Scheduling program in C<\/strong><\/a><br \/>\nOne of the CPU scheduling strategies is to select the shortest jobs first. It is an algorithm whose burst time-dependent procedure. In other words, a process with a lower burst time executes first. The shortest job next (SJN) is another name for the shortest job first (SJF). For instance, we have four processes, P1, P2, P3, and P4, with burst times of 5, 7, 6, and 2. Process P4 will now be run first since it has a shorter burst period. Processes P1, P3, and P2 will then be carried out in that order.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>enter the no of processes: 2\nthe arrival time for process P1: 10\nthe burst time for process P1: 5\nthe arrival time for process P2: 6\nthe burst time for process P2 : 3\nP[10]   |   -22765  |   -32764<\/code><\/pre>\n<p><strong>average waiting time<\/strong> = -16382.000000<br \/>\n<strong>average turnaround time<\/strong> = -11382.500000<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/menu-driven-program-for-all-operations-on-doubly-linked-list-in-c\/\" title=\"**Menu Driven program for all operations on the doubly linked list in C.**\"><strong>Menu Driven program for all operations on the doubly linked list in C.<\/strong><\/a><br \/>\nIn the menu-driven program in C, the user is given a variety of options, and some functionality is available based on these choices. These programs are used to give users the desired functions and a straightforward yet effective user interface.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>    1 To see list\n    2 For insertion at starting\n    3 For insertion at end\n    4 For insertion at any position\n    5 For deletion of first element\n    6 For deletion of last element\n    7 For deletion of element at any position\n    8 To exit\n\nEnter Choice :\n2\n\nEnter number to be inserted: 4\n\n        1 To see list\n        2 For insertion at starting\n        3 For insertion at end\n        4 For insertion at any position\n        5 For deletion of first element\n        6 For deletion of last element\n        7 For deletion of element at any position\n        8 To exit\n\nEnter Choice :\n3\n\nEnter number to be inserted: 11\n\n        1 To see list\n        2 For insertion at starting\n        3 For insertion at end\n        4 For insertion at any position\n        5 For deletion of first element\n        6 For deletion of last element\n        7 For deletion of element at any position\n        8 To exit\n\nEnter Choice :\n3\n\nEnter number to be inserted: 9\n\n        1 To see list\n        2 For insertion at starting\n        3 For insertion at end\n        4 For insertion at any position\n        5 For deletion of first element\n        6 For deletion of last element\n        7 For deletion of element at any position\n        8 To exit\n\nEnter Choice:\n1\nData = 4\nData = 11\nData = 9<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/fcfs-scheduling-program-in-c\/\" title=\"**FCFS Scheduling program in C**\"><strong>FCFS Scheduling program in C<\/strong><\/a><br \/>\nThe CPU assigns work using a non-preemptive scheduling mechanism called First Come First Serve. According to the request that was made initially, as the name implies, the tasks are given the highest priority.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Processes  Burst time  Waiting time  Turn around time\n 1                   10                    0                         10\n 2                    5                     10                       15\n 3                    8                      15                       23<\/code><\/pre>\n<p><strong>Average waiting time<\/strong> = 8.33333<br \/>\n<strong>Average turnaround time<\/strong> = 16<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-swap-two-numbers\/\" title=\"**Swap two Numbers**\"><strong>Swap two Numbers<\/strong><\/a><br \/>\nWhen two numbers are changed, two variables&#8217; values are also changed. Think about the variables var1 and var2 you have. Var1 is valued at 20, whereas Var2 is valued at 40. As a result, after swapping, var1 and var2 will have values of 40 and 20, respectively.<br \/>\nWe have discussed different methods such as:<\/p>\n<ol>\n<li>Swapping Two Numbers Using a Third Variable<\/li>\n<li>Swapping Two Numbers Using Without Using Third Variable<\/li>\n<li>Swapping Function in C<\/li>\n<li>Swap two numbers using pointers in C<\/li>\n<li>Swap Two Numbers Using Bitwise XOR<\/li>\n<\/ol>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>a = 20 b = 40<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>a = 40 b = 20<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/compound-interest-program-in-c\/\" title=\"**Compound Interest Program**\"><strong>Compound Interest Program<\/strong><\/a><br \/>\nTo calculate the amount of interest given by:<br \/>\nAmount of interest = P(1+R\/100)t<br \/>\nP = Principal amount<br \/>\nR = Rate of interest<br \/>\nT = The Time span<br \/>\nCompound Interest = Amount \u2013 P<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>Principal (amount): 1200\n                    Time: 2\n                    Rate: 5.4<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Compound Interest = 133.099243<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/radix-sort-program-in-c\/\" title=\"**Radix Sort Program**\"><strong>Radix Sort Program<\/strong><\/a><br \/>\nEach digit is sorted in the Radix sort algorithm from least to greatest significance. In base 10, radix sort would first sort by the digits in the place of one, then by the digits in the place of ten, and so on. Radix sort uses counting sort as a subroutine to order the data in each digit position.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>312  42  635  11  8  783  954  777 <\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>8  11  42  312  635  777  783  954 <\/code><\/pre>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>50 40 30 10 96 100<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>10 30 40 50 96 100<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-for-performing-bubble-sort-on-linked-list\/\" title=\"**Bubble sort on Linked List**\"><strong>Bubble sort on Linked List<\/strong><\/a><br \/>\nThe bubble sort&#8217;s fundamental principle is to compare each member of an array individually until they are sorted in ascending order, a process known as bubble busting. Instead of shifting the entire array when an element has to be moved, the impacted element is just moved.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>Linked list before sorting\n8 -> 2 -> 4 -> 1 -> 5<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Linked list after sorting\n1 -> 2 -> 4 -> 5 -> 8<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/round-robin-scheduling-program-in-c\/\" title=\"**Round-Robin Scheduling**\"><strong>Round-Robin Scheduling<\/strong><\/a><br \/>\nWith round-robin scheduling, each job receives an equal amount of CPU time. In its most basic form, jobs are placed in a circular queue, where they are moved to the back of the queue when their allotted CPU time runs out and to the front when a new task is added.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Total number of processes in the system: 4\nEnter the Arrival and Burst time of the Process[1]\n Enter Arrival time:    0\n Enter Burst time:  5\n Enter the Arrival and Burst time of the Process[2]\n Enter Arrival time:    1\n Enter Burst time:  4\n Enter the Arrival and Burst time of the Process[3]\n Enter Arrival time:    2\n Enter Burst time:  2\n Enter the Arrival and Burst time of the Process[4]\n Enter Arrival time:    4\n Enter Burst time:  1\n Enter the Time Quantum for the process:    2<\/code><\/pre>\n<\/li>\n<li>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-reverse-a-number\/\" title=\"**Reverse a Number**\"><strong>Reverse a Number<\/strong><\/a><br \/>\nUsing the modulo division (%) function, find the final digit of the provided integer, and then save the result in the last digit variable, for example, last digit=number%10. Reversed is equal to reversed times 10 plus the final digit, therefore reversed is reversed times 10 plus the last digit. Like numbered\/10, multiply the number by 10.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<pre><code>6789<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>9876<\/code><\/pre>\n<\/li>\n<\/ol>\n<p><strong>Conclusion<\/strong><br \/>\nThis blog covers all the basic C Programs. You can just brush up on your basic concepts through this article. We hope this article will help you to enhance your knowledge.<\/p>\n<p><strong>You May Also Like to Read<\/strong><\/p>\n<p><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/dfs-program-in-c\/\" title=\"DFS Program in C\">DFS Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/bfs-program-in-c\/\" title=\"BFS Program in C\">BFS Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/singly-linked-list-program-in-c\/\" title=\"Singly Linked List Program in C\">Singly Linked List Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/structure-of-c-program-with-example\/\" title=\"Structure of C Program with Example\">Structure of C Program with Example<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/selection-sort-program-in-c\/\" title=\"Selection Sort Program in C\">Selection Sort Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/calculator-program-in-c-language\/\" title=\"Calculator Program in C Language\">Calculator Program in C Language<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-for-merge-sort-for-linked-lists\/\" title=\"C Program For Merge Sort For Linked Lists\">C Program For Merge Sort For Linked Lists<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/insertion-sort-program-in-c\/\" title=\"Insertion Sort Program in C\">Insertion Sort Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/selection-sort-implementation-program-in-c\/\" title=\"How to Implement Selection Sort in C?\">How to Implement Selection Sort in C?<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-for-matrix-addition\/\" title=\"C Program for Matrix Addition\">C Program for Matrix Addition<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-to-reverse-a-linked-list\/\" title=\"C program to Reverse a Linked List\">C program to Reverse a Linked List<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/star-program-in-c\/\" title=\"Star Program in C\">Star Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/doubly-linked-list-program-in-c\/\" title=\"Doubly Linked List Program in C\">Doubly Linked List Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/simple-interest-program-in-c\/\" title=\"Simple Interest Program in C\">Simple Interest Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/bit-stuffing-program-in-c\/\" title=\"Bit Stuffing Program in C\">Bit Stuffing Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/perfect-number-program-in-c\/\" title=\"Perfect Number Program in C\">Perfect Number Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/while-loop-program-in-c\/\" title=\"While Loop Program in C\">While Loop Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/graphics-program-in-c\/\" title=\"Graphics Program in C\">Graphics Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/hello-world-program-in-c\/\" title=\"Hello World Program in C\">Hello World Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/what-is-the-program-of-armstrong-number-in-c\/\" title=\"C Program for Armstrong Number\">C Program for Armstrong Number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/matrix-multiplication-program-in-c\/\" title=\"Matrix Multiplication Program in C\">Matrix Multiplication Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/linear-search-program-in-c\/\" title=\"Linear Search Program in C\">Linear Search Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/switch-case-program-in-c\/\" title=\"Switch Case Program in C\">Switch Case Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-convert-decimal-numbers-to-binary-numbers\/\" title=\"C Program to Convert Decimal Numbers to Binary Numbers\">C Program to Convert Decimal Numbers to Binary Numbers<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/pascal-triangle-program-in-c\/\" title=\"Pascal Triangle Program in C\">Pascal Triangle Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/how-to-write-string-programs-in-c\/\" title=\"How to write string programs in C\">How to write string programs in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/leap-year-program-in-c\/\" title=\"Leap Year Program in C\">Leap Year Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/program-to-find-largest-of-three-numbers\/\" title=\"Program to Find Largest of 3 Numbers\">Program to Find Largest of 3 Numbers<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/area-of-rectangle-program-in-c\/\" title=\"Area of Rectangle Program in C\">Area of Rectangle Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/area-of-triangle-program-in-c\/\" title=\"Area of Triangle Program in C\">Area of Triangle Program in C<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/string-program-in-c\/\" title=\"String Program in C\">String Program in C<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many interviews generally include questions about C programs. These programs can be used to handle files, arrays, strings, pointers, linked lists, and other fundamental data types. About C Programming Language Dennis Ritchie developed the general-purpose computer language C at Bell Laboratories in 1972. Despite being an ancient language, it is quite popular. Since the UNIX [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-12493","post","type-post","status-publish","format-standard","hentry","category-c-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>20 Simple C Programs for Beginners - PrepBytes<\/title>\n<meta name=\"description\" content=\"Check C programming examples with their code related to arrays, string, pointer, linked list and data types.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"20 Simple C Programs for Beginners - PrepBytes\" \/>\n<meta property=\"og:description\" content=\"Check C programming examples with their code related to arrays, string, pointer, linked list and data types.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-03T07:17:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-28T12:47:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"20 Simple C Programs for Beginners\",\"datePublished\":\"2023-02-03T07:17:38+00:00\",\"dateModified\":\"2023-04-28T12:47:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/\"},\"wordCount\":1479,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg\",\"articleSection\":[\"C Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/\",\"name\":\"20 Simple C Programs for Beginners - PrepBytes\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg\",\"datePublished\":\"2023-02-03T07:17:38+00:00\",\"dateModified\":\"2023-04-28T12:47:09+00:00\",\"description\":\"Check C programming examples with their code related to arrays, string, pointer, linked list and data types.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C Programming\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/c-programming\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"20 Simple C Programs for Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"20 Simple C Programs for Beginners - PrepBytes","description":"Check C programming examples with their code related to arrays, string, pointer, linked list and data types.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/","og_locale":"en_US","og_type":"article","og_title":"20 Simple C Programs for Beginners - PrepBytes","og_description":"Check C programming examples with their code related to arrays, string, pointer, linked list and data types.","og_url":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2023-02-03T07:17:38+00:00","article_modified_time":"2023-04-28T12:47:09+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"20 Simple C Programs for Beginners","datePublished":"2023-02-03T07:17:38+00:00","dateModified":"2023-04-28T12:47:09+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/"},"wordCount":1479,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg","articleSection":["C Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/","url":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/","name":"20 Simple C Programs for Beginners - PrepBytes","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg","datePublished":"2023-02-03T07:17:38+00:00","dateModified":"2023-04-28T12:47:09+00:00","description":"Check C programming examples with their code related to arrays, string, pointer, linked list and data types.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675407617704-C%20Programs.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/basic-c-programs-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"C Programming","item":"https:\/\/prepbytes.com\/blog\/category\/c-programming\/"},{"@type":"ListItem","position":3,"name":"20 Simple C Programs for Beginners"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/12493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=12493"}],"version-history":[{"count":6,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/12493\/revisions"}],"predecessor-version":[{"id":16072,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/12493\/revisions\/16072"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=12493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=12493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=12493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}