How to make a calculator without menu driven or having options in C language in hindi

C language में बिना Options के Calculator कैसे बनाए ?

Post Image


अक्सर आप जब भी Google में सर्च करते होंगे किसी ऐसे Calculator के बारे में जिसमे कोई Options ना हो या menu driven ना हो, तब आपको शायद ही कोई आर्टिकल मिलता होगा जिसमे बिना options के Calculator बनाने के बारे में बताया हो। हम आपको आज बिना Options के Calculator बनाना सिखाएंगे।हमारे Calculator का Output कुछ ऐसा होगा।

C language Calculator


विजुअल स्टूडियो कोड इंस्टॉल कीजिए। 

IDE(Integrated development environment) यह एक टूल है जिसका उपयोग हम अपने कोड को अच्छी तरह लिखने के लिए कर सकते हैं । यहां से आप विजुअल स्टूडियो कोड IDE को कंप्यूटर में डाउनलोड कर सकते है। नीचे दी हुई लिंक पे जाइए ।

Link : https://code.visualstudio.com/download


यदि आप कोई कोडिंग नहीं जानते हैं तो बस नीचे दिए गए कोड को कॉपी करें और इसे चलाने के लिए बनाम कोड में पेस्ट करें। यदि आप कोड करना जानते हैं तो जारी रखें!


कोड यहां से शुरू है।

#include <stdio.h>

int main()
{
    int repeat = 1, operate;
    char sign;
    float , num1, num2;
    do
    {
        printf("Enter the numbers:\n");
        scanf("%f", &num1);
        scanf("%c", &sign);
        scanf("%f", &num2);

        if (sign == '+')
        {
            operate = num1 + num2;

            printf("= %0.3f\n", add);

        }
        else if (sign == '-')
        {
            operate = num1 - num2;
            printf("= %0.3f\n", add);
        }
        else if (sign == '*')
        {
            operate = num1 * num2;
            printf("= %0.3f\n", add);
        }
        else if (sign == '/')
        {
               if (num1 == 1 && num2 == 0)
        {
            
            printf("Error 1 cannot be divided by 0\n");

        }
        else 
        {
            operate = num1 / num2;
            printf("= %0.3f\n", add);
        }

    } while (repeat == 1);

    return 0;
}

कोड यहां से खत्म है।

इस आर्टिकल को पढ़ने के लिए धन्यवाद :)


टिप्पणियाँ

लोकप्रिय पोस्ट