.OnlineGuruji: Prog In C Lang

.OnlineGuruji

Provides E-Notes,Video Tutorials And Download Links For Students In hindi

*********************************************************

*********************************************************
********************************************************************************

Breaking

Ramchandicollege Saraipali

Technology Jobs

OnlineGuru Blog मे आपका स्वागत है ब्लॉग से संबन्धित जानकारी के लिए संपर्क करें मो ॰ नम ।-9826026747(सपन कुमार दास) अपने विषय से संबन्धित अपडेट प्राप्त करने के लिए ब्लॉग पे दिये गए Bell Icon को press करें कम्प्युटर,Science,English Grammer से संबन्धित विषय की अधिक जानकारी के लिए हमारे ब्लॉग अथवा यू ट्यूब चैनल को सब्क्राइब करे ..
Showing posts with label Prog In C Lang. Show all posts
Showing posts with label Prog In C Lang. Show all posts

Friday, September 27, 2024

September 27, 2024

Write A program to calculate thr compound Interest in c language

 

#include <stdio.h>

#include <conio.h>

#include <math.h>

 Void main() 

{

    float principal, rate, time, compoundInterest;

  clrscr();

  printf("Enter principal amount: ");

    scanf("%f", &principal);

    printf("Enter rate of interest: ");

    scanf("%f", &rate);

    printf("Enter time period (in years): ");

    scanf("%f", &time);

    // Calculate compound interest

    compoundInterest = principal * pow(1 + (rate / 100), time) - principal;

    printf("Compound Interest = %.2lf\n", compoundInterest);

getch();

    }

Output:--

Enter principal amount: 1000

Enter rate of interest: 2

Enter time period (in years): 3

Compound Interest = 61.21

This C program calculates compound interest using the following formula:

Compound Interest = Principal * (1 + (Rate / 100))^Time - Principal

Here's a breakdown of the code:

  1. Include necessary headers:

    • stdio.h for input/output operations.
    • math.h for the pow function to calculate the power.
  2. Declare variables:

    • principal: Stores the principal amount.
    • rate: Stores the rate of interest.
    • time: Stores the time period in years.
    • compoundInterest: Stores the calculated compound interest.
  3. Get user input:

    • Prompt the user to enter the principal amount, rate of interest, and time period.
    • Use scanf to read the values from the user.
  4. Calculate compound interest:

    • Use the formula compoundInterest = principal * pow(1 + (rate / 100), time) - principal to calculate the compound interest.
    • The pow function is used to calculate the power of the expression (1 + (rate / 100)).
  5. Print the result:

    • Print the calculated compound interest using printf.
  6. Return 0:

    • Indicate successful program execution.

Tuesday, August 27, 2024

August 27, 2024

What is Programming Language

 


What is Programming Language

A programming language is a formal language designed to communicate instructions to a computer or computing device to perform specific tasks. Programming languages provide a structured way for programmers to write code that can be understood and executed by computers, enabling the creation of software applications, websites, and other digital systems.

एक programming language एक formal language है जिसे किसी कंप्यूटर या कंप्यूटिंग डिवाइस से specific tasks  करने के लिए instructions (निर्देशों) को communicate करने के लिए डिज़ाइन किया गया है। programming language प्रोग्रामर को code लिखने के लिए एक structured way प्रदान करती हैं जिसे कंप्यूटर समझ कर और execute करता हैं, programming language का उपयोग सॉफ्टवेयर एप्लिकेशन, वेबसाइट्स और अन्य डिजिटल सिस्टम का designed करने के लिए किया  जाता है।

C programming language

 

C प्रोग्रामिंग भाषा का नाम "C" इसलिए रखा गया क्योंकि इसे पहले की प्रोग्रामिंग भाषा "B" का उत्तराधिकारी के रूप में डिजाइन किया गया था। "C" अक्षर का चुनाव यह दर्शाने के लिए किया गया था कि यह B के बाद का अगला "Generation" है, यह नामकरण परंपरा(Nominition Process) कंप्यूटर विज्ञान में आम है, जहां new Edition   या related Languages अक्सर इस पैटर्न का पालन करती हैं।

A procedural programming language is a type of programming language that follows a step-by-step sequence of instructions, where the program is structured around procedures or subroutines that perform individual tasks. Procedural languages focus on how a computation is to be done, rather than what the desired outcome should be, making the code more explicit and easier to understand for tasks that can be broken down into a series of steps

procedural programming language प्रोग्रामिंग भाषा का एक प्रकार  है जो instructions को  step-by-step sequence के साथ पालन करती है, procedural programming language मे program  procedures या subroutines मे devide रहता है जो  एक individual tasks को perform करते हैं। Procedural languages computation पर आधारित language है जो एक श्रृंखला में विभाजित होता है  और  इस बात पर ध्यान केंद्रित करता  हैं कि प्रोग्राम मे computation कैसे किया जाना  चाहिए, ना कि इसके कि desired outcome/result  क्या होना चाहिए, इसमे कोड अधिक स्पष्ट होता है और कार्यों को  समझने में आसान होता है |

Monday, December 19, 2022

December 19, 2022

Difference Between Recursion and Iteration

 


1.रिकर्सन को एक फ़ंक्शन के रूप में परिभाषित किया जा सकता है जिसे बार-बार call जाता है

1.जब एक लूप बार-बार set of instruction  को तब तक execute  करता है जब तक
 condition false na  हो जाए
2. Recurtion एक प्रक्रिया है जो हमेशा एक फ़ंक्शन पर लागू होती है
2.Iteration  set of instruction  पर लागू होती है जिसे हम बार-बार execute 
 करना चाहते हैं और लूप करते हैं
3. Recurtion  slow execute  करता है
3. Iteration  fast execute  करता है
4.रिकर्सन ने size of code को कम करता है 
4. Iteration  size of code को long  करता है 
5. एक conditional statement रिकर्सन की termination  का फैसला करता है
5.loop counter variable  Iteration  statement  की termination  का 
निर्णय करता है
December 19, 2022

Recursion






C language में, Recursion एक प्रक्रिया है जिसमें एक function अपने आप को बार-बार call करता है. इस function को recursive function कहते हैं. इस प्रकार की function call को recursive calls कहा जाता है.

Recursive functions बहुत सारीं mathematical problems को solve करने में बहुत उपयोगी होती है जैसे किएक number के factorial को calculate करना, fibonacci series को जनरेट करना आदि.

Advantage of Recursion in Hindi – रिकर्शन के लाभ

1.    यह अनावश्यक function call को कम करता है.

2.    इसके द्वारा हम problems को आसानी से solve कर सकते है क्योंकि iterative solution बहुत बड़ा और complex (कठिन) होता है.

3.    यह हमारे code को elegant (सुंदर) बना देता है.

Disadvantage of Recursion in Hindi

1.    Recursion का प्रयोग करके बनाये गये program को समझना और debug करना मुश्किल होता है.

2.    इसके लिए हमें ज्यादा memory space की आवश्यकता होती है.

3.    इसमें program को execute करने में ज्यादा समय लगता है.

 Types of Recursion in C in Hindi – रिकर्शन के प्रकार

इसके प्रकार निम्नलिखित हैं:-

1:- Tail Recursion  – यदि एक recursive function खुद को call करता है और यह recursive call, फंक्शन का अंतिम statement है तो इसे tail रिकर्शन कहते हैं. इस recursive call के बाद फंक्शन कुछ भी perform नहीं करता है.

2:- single recursion – इस प्रकार के रिकर्शन में केवल एक recursive call होती है.

3:- Multiple recursion – इस प्रकार के रिकर्शन में बहुत सारीं recursive calls होती हैं.

4:- indirect recursion – यह रिकर्शन तब घटित होता है जब एक function दूसरे function को call करता है जिसके कारण उसे original function को call करना पड़ता है.

Recursion का syntax –

इसका basic syntax नीचे दिया गया है:-

void recurse()

 

{

 

 

recurse();

 

 

 }

 int main()

{

 

 recurse();

 

}


Recursion:-The functuion call itself is known as recursive function and the process is known as recursion

1 Write a program to calculate the factorial of given number using recursive function

 

#include<stdio.h>

#include<conio.h>

int fact(int n)

{

 int f;

 if (n==1)

 {

  return(1);

 

 }

 else

 {

  f=n*fact(n-1);

 }

 return(f);

}

 void main()

{

        int num=1;

        int ans=fact(num);

        printf("%d",ans);

 getch();

}

2.Write a program to calculate the su of n natural number using recursive function

#include<stdio.h>

#include<conio.h>

int sum(int n)

{

 int s;

 if (n==1)

 {

  return(1);

 

 }

 else

 {

  f=n+sum(n-1);

 }

 return(f);

}

 void main()

{

        int num=1;

        int ans=sum(num);

        printf("%d",ans);

 getch();

}