Posts

C++ Program for Swapping Two Numbers Without Using a Third Variable (तीसरे Variable का उपयोग किए बिना दो संख्याओं की अदला-बदली करने का C++ प्रोग्राम)

Swapping means exchanging the values of two variables. In this C++ program, we swap two numbers without using a third variable. We use arithmetic operators ( + and - ) to exchange their values. स्वैपिंग (Swapping) का अर्थ दो Variables के मानों को आपस में बदलना है। इस C++ प्रोग्राम में तीसरे Variable का उपयोग किए बिना Arithmetic Operators ( + और - ) की सहायता से दो संख्याओं के मान बदले जाते हैं। C++ Program #include <iostream> using namespace std; int main() { float a, b; cout << "Enter Two Numbers: "; cin >> a >> b; cout << "\nBefore Swapping:" << endl; cout << "a = " << a << " and b = " << b << endl; a = a + b; b = a - b; a = a - b; cout << "\nAfter Swapping:" << endl; cout << "a = " << a << " and b = " << b << endl; return 0; } Sample Output (उदाहरण आउटपुट) Enter ...

C++ Program for Swapping Two Numbers Using a Third Variable (तीसरे Variable की सहायता से दो संख्याओं की अदला-बदली करने का C++ प्रोग्राम)

Swapping means exchanging the values of two variables. In this C++ program, we use a third variable to swap the values of two numbers. स्वैपिंग (Swapping) का अर्थ दो Variables के मानों को आपस में बदलना है। इस C++ प्रोग्राम में दो संख्याओं के मानों को बदलने के लिए तीसरे Variable का उपयोग किया गया है। C++ Program #include <iostream> using namespace std; int main() { float a, b, c; cout << "Enter Two Numbers: "; cin >> a >> b; cout << "\nBefore Swapping:" << endl; cout << "a = " << a << " and b = " << b << endl; c = a; a = b; b = c; cout << "\nAfter Swapping:" << endl; cout << "a = " << a << " and b = " << b << endl; return 0; } Sample Output (उदाहरण आउटपुट) Enter Two Numbers: 10 20 Before Swapping: a = 10 and b = 20 After Swapping: a = 20 and b = 10 Explanation of the P...

C++ Program for Parking Charges of Two-Wheelers, Four-Wheelers and Heavy Vehicles (दोपहिया, चार पहिया और भारी वाहनों का पार्किंग शुल्क ज्ञात करने का C++ प्रोग्राम)

A parking management system is used to calculate parking charges according to the type of vehicle and the total parking duration. In this C++ program, we use a class named Parking to calculate the parking charges for three types of vehicles: Two-Wheelers – Bike or Scooter Four-Wheelers – Car or Loading Vehicle Heavy Vehicles – Bus or Truck The program accepts the vehicle type, vehicle number, entry time, exit time and parking days. It then calculates the total parking duration and displays the parking receipt. पार्किंग प्रबंधन प्रणाली का उपयोग वाहन के प्रकार और पार्किंग की कुल अवधि के आधार पर शुल्क ज्ञात करने के लिए किया जाता है। इस C++ प्रोग्राम में Parking नाम की Class बनाई गई है, जो तीन प्रकार के वाहनों का पार्किंग शुल्क ज्ञात करती है। Parking Charges (पार्किंग शुल्क) Vehicle Type Vehicle Category First 24 Hours Additional Hours 1 Bike / Scooter ₹10 per hour ₹1 per hour 2 Car / Loading Vehicle ₹20 per hour ₹5 per hour 3 Bus / Truck ₹50 per hour ₹10 per hour C++ Program #include ...

C++ Program to Check Whether a Given Year is a Leap Year or Not (दिया गया वर्ष Leap Year है या नहीं, जाँचने का C++ प्रोग्राम)

A Leap Year is a year that contains 366 days instead of the usual 365 days. February has 29 days in a leap year instead of 28 days. A year is a leap year if It is completely divisible by 400, or It is divisible by 4 but not divisible by 100. Leap Year वह वर्ष होता है जिसमें सामान्य 365 दिनों के स्थान पर 366 दिन होते हैं। सामान्य वर्ष में February के 28 दिन होते हैं, जबकि Leap Year में February के 29 दिन होते हैं। किसी वर्ष को Leap Year माना जाता है यदि वह 400 से पूर्णतः विभाजित हो, अथवा 4 से विभाजित हो लेकिन 100 से विभाजित न हो। C++ Program #include <iostream> using namespace std; int main() { int year; cout << "Enter a year: "; cin >> year; if (year % 400 == 0) { cout << year << " is a leap year." << endl; } else { if (year % 100 == 0) { cout << year << " is not a leap year." << endl; } else { if (y...

C++ Program to Check Whether an Alphabet is Vowel or Consonant Using switch-case (Vowel या Consonant की जाँच)

This C++ program checks whether a given alphabet is a vowel or a consonant using the if statement and switch-case statement. यह C++ प्रोग्राम if तथा switch-case स्टेटमेंट की सहायता से दिए गए alphabet के vowel या consonant होने की जाँच करता है। Program: #include <iostream> using namespace std; int main() { char ch; cout << "Enter an alphabet: "; cin >> ch; // Check whether the input is an alphabet if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) { switch (ch) { case 'A': case 'a': case 'E': case 'e': case 'I': case 'i': case 'O': case 'o': case 'U': case 'u': cout << ch << " is Vowel" << endl; ...

C++ Program to Calculate Percentage and Display Division Using if-else (प्रतिशत एवं डिवीजन ज्ञात करना)

This C++ program accepts the percentage of a student and displays the division based on the percentage obtained using nested if-else statements. यह C++ प्रोग्राम विद्यार्थी का प्रतिशत input करता है तथा nested if-else statements की सहायता से प्राप्त प्रतिशत के आधार पर उसकी division प्रदर्शित करता है। Program: #include <iostream> using namespace std; int main() { float per; cout << "Enter Percentage of student: "; cin >> per; if (per >= 60) { cout << "I Division " << per << "%" << endl; } else { if (per >= 45) { cout << "II Division " << per << "%" << endl; } else { if (per >= 33) { cout << "III Division " << per << "%" << endl; } else { c...

C++ Program to Find Greatest Among Three Numbers Using if-else (तीन संख्याओं में सबसे बड़ी संख्या ज्ञात करना)

In this program, we use nested if-else statements to find the greatest or largest among three numbers. इस प्रोग्राम में nested if-else statements की सहायता से तीन संख्याओं में से सबसे बड़ी संख्या ज्ञात की जाती है। Program: #include <iostream> using namespace std; int main() { float a, b, c; cout << "Enter Three Numbers: "; cin >> a >> b >> c; if (a > b) { if (a > c) { cout << a << " is greatest" << endl; } else { cout << c << " is greatest" << endl; } } else { if (b > c) { cout << b << " is greatest" << endl; } else { cout << c << " is greatest" << endl; } } return 0; } Output 1: Enter Three Numbers: 10 25 15 25 is greatest Output 2: Enter T...