quadratic equation


#include <stdio.h>#include <math.h>int main() {    double a, b, c, discriminant, root1, root2;    printf("Enter coefficients (a, b, c) of the quadratic equation (ax^2 + bx + c = 0):\n");    scanf("%lf %lf %lf", &a, &b, &c);    discriminant = b * b - 4 * a * c;    if (discriminant > 0) {        root1 = (-b + sqrt(discriminant)) / (2 * a);        root2 = (-b - sqrt(discriminant)) / (2 * a);        printf("Roots are real and different.\n");        printf("Root 1 = %.2lf\n", root1);        printf("Root 2 = %.2lf\n", root2);    } else if (discriminant == 0) {        root1 = root2 = -b / (2 * a);        printf("Roots are real and the same.\n");        printf("Root 1 = Root 2 = %.2lf\n", root1);    } else {        double realPart = -b / (2 * a);        double imaginaryPart = sqrt(-discriminant) / (2 * a);        printf("Roots are complex and different.\n");        printf("Root 1 = %.2lf + %.2lfi\n", realPart, imaginaryPart);        printf("Root 2 = %.2lf - %.2lfi\n", realPart, imaginaryPart);    }    return 0;}

c++ to find sum of odd


#include <iostream>class OddNumberSum {public:    int calculateSum() {        int sum = 0;        for (int i = 1; i <= 100; ++i) {            if (i % 2 != 0) {                sum += i;            }        }        return sum;    }};int main() {    OddNumberSum oddSumCalculator;    int result = oddSumCalculator.calculateSum();    std::cout << "Sum of odd numbers from 1 to 100: " << result << std::endl;    return 0;}

Get a 30-minute, no-cost strategy session with a cyber expert.
Speak with our experts to discover the next steps of your journey
Let's Talk

bank acc
#include <iostream>class Account {private:    int accountNumber;    double accountBalance;public:    Account(int accNum, double accBal) : accountNumber(accNum), accountBalance(accBal) {}    double getAccountBalance() const {        return accountBalance;    }    void deposit(double amount) {        accountBalance += amount;    }    void withdraw(double amount) {        if (amount <= accountBalance) {            accountBalance -= amount;        } else {            std::cout << "Insufficient funds. Withdrawal not allowed." << std::endl;        }    }};int main() {    Account myAccount(12345, 1000.0);    std::cout << "Initial Account Balance: $" << myAccount.getAccountBalance() << std::endl;    myAccount.deposit(500.0);    std::cout << "After Deposit, Account Balance: $" << myAccount.getAccountBalance() << std::endl;    myAccount.withdraw(200.0);    std::cout << "After Withdrawal, Account Balance: $" << myAccount.getAccountBalance() << std::endl;    myAccount.withdraw(1500.0);    return 0;}

c ++ prog to calculate volume of box

#include <iostream>class Volume {private:    double length;    double breadth;    double height;public:    Volume(double l, double b, double h) : length(l), breadth(b), height(h) {}    double calculateVolume() {        return length * breadth * height;    }};int main() {    double length, breadth, height;    std::cout << "Enter the length of the box: ";    std::cin >> length;    std::cout << "Enter the breadth of the box: ";    std::cin >> breadth;    std::cout << "Enter the height of the box: ";    std::cin >> height;    Volume box(length, breadth, height);    double result = box.calculateVolume();    std::cout << "Volume of the box: " << result << std::endl;    return 0;}