Write source code in C++ that prompts the user to enter two numeric values. Store these values in double variable objects named first and second. Write your program to display the following calculations:
What happens when second is equal to zero?
#include<iostream> using namespace std; int main() { double first, second; cout<<"Enter value for first: "; cin>>first; cout<<"Enter value for second: "; cin>>second; cout<<(first-second)<<endl; cout<<(second-first)<<endl; cout<<(first+second)<<endl; cout<<(first*second)<<endl; if(second==0) cout<<"Infinity"<<endl; else cout<<(first/second)<<endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.