Pages

Friday, March 21, 2025

calculate sum and product in C++

 #include<iostream>

#include<iomanip>
using namespace std;

int main() {
    int a;
    int b;

    //input a
    cout<<"Enter a : ";
    cin>>a;

    //input b
    cout<<"Enter b: ";
    cin>>b;

    //calculate sum
    int sum = a + b;
    int prod = a*b;
    cout<<"sum = "<<sum<<endl;
    cout<<"product = "<<prod<<endl;

    return 0;

}

No comments:

Post a Comment

3917. Count Indices With Opposite Parity (Brute Force) O(n2) + Optimized Solution O(n) + tips LEETCODE WEEKLY 500

  class Solution {     public int [] countOppositeParity ( int [] nums ) {          // approach 1 - checks every pair         int n = n...