Basic and Important C Programs महत्वपूर्ण एवं सामान्य सी प्रोग्राम (Sequential Structure Programs)
Sequential structure programs are the simplest programs in C language where statements are executed one after another in sequence. These programs help beginners understand variables, operators, input-output functions, formulas, and basic program logic.
Sequential structure programs C language के सबसे सरल programs होते हैं जिनमें statements क्रमवार execute होते हैं। ये programs विद्यार्थियों को variables, operators, input-output functions, formulas तथा basic programming logic समझने में सहायता करते हैं।
1. C Program to Calculate Simple Interest1. Simple Interest निकालने का C Program
#include<stdio.h>int main(){float p,r,t,si;printf("Enter Principal, Rate and Time:\n");scanf("%f%f%f",&p,&r,&t);si = p*r*t/100;printf("Simple Interest = %.2f",si);return 0;}
Output:
Enter Principal, Rate and Time:100052Simple Interest = 100.00
2. C Program to Find ASCII Value of a Character2. Character का ASCII Value ज्ञात करने का Program
#include<stdio.h>int main(){char ch;printf("Enter any character: ");scanf("%c",&ch);printf("ASCII Value = %d",ch);return 0;}
Output:
Enter any character: AASCII Value = 65
3. C Program to Find Area of Triangle using Heron’s Formula3. Heron’s Formula से Triangle का Area निकालने का Program
#include<stdio.h>#include<math.h>int main(){float a,b,c,s,area;printf("Enter three sides of triangle:\n");scanf("%f%f%f",&a,&b,&c);s = (a+b+c)/2;area = sqrt(s*(s-a)*(s-b)*(s-c));printf("Area of Triangle = %.2f",area);return 0;}
Output:
Enter three sides of triangle:345Area of Triangle = 6.00
4. C Program for Addition, Subtraction, Multiplication and Division4. Addition, Subtraction, Multiplication एवं Division का Program
#include<stdio.h>int main(){int a,b;printf("Enter two numbers:\n");scanf("%d%d",&a,&b);printf("Addition = %d\n",a+b);printf("Subtraction = %d\n",a-b);printf("Multiplication = %d\n",a*b);printf("Division = %d\n",a/b);return 0;}
Output:
Enter two numbers:2010Addition = 30Subtraction = 10Multiplication = 200Division = 2
5. C Program to Find Area and Circumference of Circle5. Circle का Area एवं Circumference निकालने का Program
#include<stdio.h>int main(){float r,area,circumference;printf("Enter radius of circle: ");scanf("%f",&r);area = 3.14*r*r;circumference = 2*3.14*r;printf("Area = %.2f\n",area);printf("Circumference = %.2f",circumference);return 0;}
Output:
Enter radius of circle: 7Area = 153.86Circumference = 43.96
6. C Program to Swap Two Variables without Third Variable6. Third Variable के बिना Variables Swap करने का Program
#include<stdio.h>int main(){int a,b;printf("Enter two numbers:\n");scanf("%d%d",&a,&b);a = a+b;b = a-b;a = a-b;printf("After Swapping:\n");printf("a = %d\nb = %d",a,b);return 0;}
Output:
Enter two numbers:1020After Swapping:a = 20b = 10
7. C Program to Swap Two Variables using Third Variable7. Third Variable का उपयोग करके Variables Swap करने का Program
#include<stdio.h>int main(){int a,b,temp;printf("Enter two numbers:\n");scanf("%d%d",&a,&b);temp = a;a = b;b = temp;printf("After Swapping:\n");printf("a = %d\nb = %d",a,b);return 0;}
Output:
Enter two numbers:1525After Swapping:a = 25b = 15
8. C Program to Find Square, Cube and Square Root8. Square, Cube एवं Square Root निकालने का Program
#include<stdio.h>#include<math.h>int main(){float n;printf("Enter any number: ");scanf("%f",&n);printf("Square = %.2f\n",n*n);printf("Cube = %.2f\n",n*n*n);printf("Square Root = %.2f",sqrt(n));return 0;}
Output:
Enter any number: 9Square = 81.00Cube = 729.00Square Root = 3.00
9. C Program to Calculate Gross Salary9. Gross Salary निकालने का Program
#include<stdio.h>int main(){float basic,hra,da,gross;printf("Enter Basic Salary: ");scanf("%f",&basic);hra = basic*20/100;da = basic*80/100;gross = basic + hra + da;printf("Gross Salary = %.2f",gross);return 0;}
Output:
Enter Basic Salary: 10000Gross Salary = 20000.00
10. C Program to Convert Celsius into Fahrenheit10. Celsius को Fahrenheit में Convert करने का Program
#include<stdio.h>int main(){float c,f;printf("Enter temperature in Celsius: ");scanf("%f",&c);f = (9*c/5)+32;printf("Temperature in Fahrenheit = %.2f",f);return 0;}
Output:
Enter temperature in Celsius: 37Temperature in Fahrenheit = 98.60
11. C Program to Calculate Percentage of Five Subjects11. पाँच विषयों का Percentage निकालने का Program
#include<stdio.h>int main(){float a,b,c,d,e,total,per;printf("Enter marks of five subjects:\n");scanf("%f%f%f%f%f",&a,&b,&c,&d,&e);total = a+b+c+d+e;per = total/5;printf("Total Marks = %.2f\n",total);printf("Percentage = %.2f",per);return 0;}
Output:
Enter marks of five subjects:8075908570Total Marks = 400.00Percentage = 80.00
12. C Program to Find Area of Rectangle12. Rectangle का Area निकालने का Program
#include<stdio.h>int main(){float l,b,area;printf("Enter length and breadth:\n");scanf("%f%f",&l,&b);area = l*b;printf("Area of Rectangle = %.2f",area);return 0;}
Output:
Enter length and breadth:105Area of Rectangle = 50.00
13. C Program to Find Area of Square13. Square का Area निकालने का Program
#include<stdio.h>int main(){float side,area;printf("Enter side of square: ");scanf("%f",&side);area = side*side;printf("Area of Square = %.2f",area);return 0;}
Output:
Enter side of square: 6Area of Square = 36.00
14. C Program to Convert Days into Years, Months and Days14. Days को Years, Months और Days में Convert करने का Program
#include<stdio.h>int main(){int days,years,months,remaining;printf("Enter total days: ");scanf("%d",&days);years = days/365;remaining = days%365;months = remaining/30;remaining = remaining%30;printf("Years = %d\n",years);printf("Months = %d\n",months);printf("Days = %d",remaining);return 0;}
Output:
Enter total days: 500Years = 1Months = 4Days = 15
15. C Program to Find Average of Three Numbers15. तीन संख्याओं का Average निकालने का Program
#include<stdio.h>int main(){float a,b,c,avg;printf("Enter three numbers:\n");scanf("%f%f%f",&a,&b,&c);avg = (a+b+c)/3;printf("Average = %.2f",avg);return 0;}
Output:
Enter three numbers:102030Average = 20.00
Sequential structure programs are the foundation of C programming. These programs help beginners understand input-output operations, variables, formulas, arithmetic operations, and program execution flow. Mastering these basic programs builds a strong base for learning advanced programming concepts such as conditional statements, loops, arrays, functions, pointers, and data structures.
Sequential structure programs C programming की नींव हैं। ये programs विद्यार्थियों को input-output operations, variables, formulas, arithmetic operations तथा program execution flow समझने में सहायता करते हैं। इन basic programs में mastery प्राप्त करने से आगे के advanced topics जैसे conditional statements, loops, arrays, functions, pointers तथा data structures सीखना आसान हो जाता है।
Next Topic:
Previous Topic:
Comments
Post a Comment