.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, November 28, 2025

November 28, 2025

Call by Value & Call by Reference in C in Hindi

 

Call by Value & Call by Reference in C in Hindi

C प्रोग्रामिंग लैंग्वेज में, function को दो तरीकों से से call किया जा सकता है. पहला call by value और दूसरा call by reference.


Call By Value in C in Hindi

  • Call by Value मेथड में, actual parameters की value को फंक्शन के formal parameters में copy किया जाता है.

  • दूसरे शब्दों में कहें तो, “इसमें variable की value का प्रयोग function call में प्रयोग किया जाता है.”

  • Call by value मेथड में, हम formal parameters के द्वारा actual parameter की value को बदल नहीं सकते.

  • इसमें, actual और formal parameters अलग-अलग memory location में स्टोर रहते हैं.

  • actual parameter एक ऐसा argument है जिसे function call में प्रयोग किया जाता है जबकि formal parameter एक ऐसा argument है जिसे function definition में प्रयोग किया जाता है.

इसका Example –

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

#include<stdio.h>
#include<conio.h>

void swap(int x, int y)
{
 int temp;
 temp = x;
 x = y;
 y = temp;
}

void main() 
{  
 int x = 50, y = 70;  
 clrscr();  
 swap(x, y);  // passing value to function
 printf("\nValue of x: %d",x);
 printf("\nValue of y: %d",y);
 getch();  
}  

इसका आउटपुट 

Value of x: 50
Value of y: 70

Call By Reference in C in Hindi

  • Call by reference में, एक argument के address को formal parameters में copy किया जाता है.

  • दूसरे शब्दों में कहें तो, “इसमें variable के address को actual parameter की तरह function call में pass किया जाता है.”

  • इसमें अगर हम formal parameter की value को change करते है तो actual parameter की value भी change हो जाएगी.

  • call by reference में, दोनों actual और formal parameters एक ही memory location में स्टोर रहते हैं.

इसका उदाहरण –

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

#include<stdio.h>
#include<conio.h>

void swap(int *x, int *y)
{
 int temp;
 temp = *x;
 *x = *y;
 *y = temp;
}

void main() 
{  
 int x = 50, y = 70;  
 clrscr();  
 swap(&x, &y);  // passing value to function
 printf("\nValue of x: %d",x);
 printf("\nValue of y: %d",y);
 getch();  
}  

इसका आउटपुट –
Value of x: 70
Value of y: 50

Difference between Call by Value and Call by Reference in Hindi 

इनके मध्य अंतर निम्नलिखित हैं:-

Call By ValueCall By Reference
function को call करते समय, जब हम variable की value को pass करते हैं तो ऐसे functions को call by value कहते है.function को call करते समय, जब हम variable के address को pass करते हैं तो ऐसे functions को call by reference कहते हैं.
इसमें अगर हम variable की copy को change कर दे तो variable की original value नहीं बदलती.इसमें variable की value बदल दें तो function के बाहर variable की value भी बदल जाएगी
इसमें हम function call के द्वारा वास्तविक variable की value को बदल नहीं सकते.इसमें हम function call के द्वारा वास्तविक variable की वैल्यू को बदल सकते हैं.
इसमें variables की values को सरल तकनीक के द्वारा pass किया जाता है.इसमें variables के address को स्टोर करने के लिए pointer variable की आवश्यकता होती है.
इसमें actual और formal parameters दोनों अलग-अलग मैमोरी लोकेशन में store रहते है.इसमें actual और formal parameters एक ही मैमोरी लोकेशन में स्टोर रहते है.
इसे C++, PHP, Visual Basic NET, और C# के द्वारा support किया जाता है.इसे मुख्यतया Java के द्वारा support किया जाता है.


November 28, 2025

C String Functions

 


C String Functions

C लैंग्वेज में कई बिल्ट-इन फ़ंक्शन होते हैं जिनका इस्तेमाल स्ट्रिंग पर अलग-अलग ऑपरेशन और मैनिपुलेशन के लिए किया जा सकता है। ये स्ट्रिंग फ़ंक्शन स्ट्रिंग कॉपी, कंकैटनेशन, कम्पेरिजन, लेंथ वगैरह जैसे काम करना आसान बनाते हैं। <string.h> हेडर फ़ाइल में ये स्ट्रिंग फ़ंक्शन होते हैं।

1-strlen()

strlen() फ़ंक्शन का इस्तेमाल स्ट्रिंग की लेंथ पता करने के लिए किया जाता है। यह स्ट्रिंग में कैरेक्टर की संख्या बताता है, जिसमें नल टर्मिनेटर ('\0') शामिल नहीं है।

उदाहरण

#include <stdio.h>

#include <string.h>

#include <conio.h>

void main() {

    char s[] = "sapan          ";

   clrscr();

                // Finding and printing length of string s

    printf("%d", strlen(s));

getch();

}

S2-trcpy()

strcpy() फ़ंक्शन सोर्स से डेस्टिनेशन तक एक स्ट्रिंग कॉपी करता है. यह नल टर्मिनेटर सहित पूरी स्ट्रिंग कॉपी करता है.

 

उदाहरण:

#include <stdio.h>

#include <string.h>

#include <conio.h>

 

void main()

 {

   char src[] = "Hello";

    char dest[20];

   

    // Copies "Hello" to dest

    strcpy(dest, src); 

    printf("%s", dest);

   

getch();

}

3-strncpy()

strncpy() फ़ंक्शन strcpy() जैसा ही है, लेकिन यह सोर्स से डेस्टिनेशन स्ट्रिंग में ज़्यादा से ज़्यादा n बाइट्स कॉपी करता है। अगर सोर्स n से छोटा है, तो strncpy() डेस्टिनेशन में एक नल कैरेक्टर जोड़ता है ताकि यह पक्का हो सके कि n कैरेक्टर लिखे गए हैं।

 

उदाहरण:

#include <stdio.h>

#include <string.h>

#include <conio.h>

 

void main()

 {

   char src[] = "Hello";

    char dest[20];

   

    // Copies "Hello" to dest

    strncpy(dest, src, 4);

    printf("%s", dest);

getch();

}

4-strcat()

strcat() फ़ंक्शन का इस्तेमाल एक स्ट्रिंग को दूसरी स्ट्रिंग के आखिर में जोड़ने (जोड़ने) के लिए किया जाता है। यह सोर्स स्ट्रिंग को डेस्टिनेशन स्ट्रिंग में जोड़ता है, और डेस्टिनेशन के नल टर्मिनेटर को सोर्स स्ट्रिंग के कंटेंट से बदल देता है।

 

उदाहरण

#include <stdio.h>

#include <string.h>

#include <conio.h>

 

void main()

 {

    char s1[30] = "Sapan ";

    char s2[] = "Das";

    clrscr();

    // Appends "Geeks!" to "Hello, "

    strcat(s1, s2); 

    printf("%s", s1);

   

getch();

 

 

5-strncat()

C में, strcat() जैसा ही एक फ़ंक्शन strncat() होता है। यह फ़ंक्शन सोर्स से पॉइंट किए गए स्ट्रिंग से डेस्टिनेशन से पॉइंट किए गए स्ट्रिंग के आखिर में n से ज़्यादा कैरेक्टर नहीं जोड़ता है, साथ ही एक टर्मिनेटिंग NULL कैरेक्टर भी जोड़ता है।

 

उदाहरण:

#include <stdio.h>

#include <string.h>

 

int main() {

    char s1[30] = "Hello, ";

    char s2[] = "Geeks!";

   

    // Appends "Geeks!" to "Hello, "

    strncat(s1, s2, 4); 

    printf("%s", s1);

    return 0;

}

 

 

6-strcmp()

strcmp() C में एक बिल्ट-इन लाइब्रेरी फ़ंक्शन है। यह फ़ंक्शन दो स्ट्रिंग को आर्गुमेंट के तौर पर लेता है, इन दो स्ट्रिंग की तुलना लेक्सिकोग्राफ़िकली करता है और तुलना के नतीजे में एक इंटीजर वैल्यू देता है।

 

उदाहरण

#include <stdio.h>

#include <string.h>

#include <conio.h>

 

void main()

 {

     char s1[] = "Apple";

    char s2[] = "Applet";

    clrscr();

                // Compare two strings

                // and print result

    int res = strcmp(s1, s2);

    if (res < 0)

        printf("S1 is smaller than s2");

                else if (res > 0)

                printf("s1 greater than s2");

                else

                printf("both are same length " );

 

 

   

getch();

}

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  का 
निर्णय करता है