Ryan is appearing for a techathon that offers price money of 10K for the winner. Techathon has provided a platform where an incomplete code will appear, and the participants have to complete it. Ryan got a program in c++ where he needs to create a complex calculator. Can you help Ryan win this competition?
Answers
Answered by
6
Answer:
#include <iostream>
using namespace std;
int main()
{
int a,b,c,d,n;
cin>>n>>a>>b>>c>>d;
switch(n)
{
case 1:
cout<<(a+c)<<"+"<<(b+d)<<"i";
break;
case 2:
cout<<(a-c)<<"-"<<(b-d)<<"i";
break;
case 3:
cout<<((a*c)-(b*d))<<((b*c)+(a*d))<<"i";
break;
}
}
Explanation:
Answered by
4
Answer:
#include<iostream>
int main()
{
int a,b,c,d,n;
std::cin>>n>>a>>b>>c>>d;
switch(n)
{
case 1:
std::cout<<(a+c)<<"+"<<(b+d)<<"i";
break;
case 2:
std::cout<<(a-c)<<"+"<<(b-d)<<"i";
break;
case 3:
std::cout<<((a*c)-(b*d))<<((b*c)+(a*d))<<"i";
break;
default:
std::cout<<"Invalid choice";
}
}
Explanation:
All test case 100% pass.
Similar questions