Write a CC program that uses if and else if statements to ca

Write a C/C+ program that uses if and else if statements to calculate and display the value where the user inputs the values of integers x and y from the cases:, If x > 0 && y > 0 F1 = x*2 + y*y*; Else if x > 0 && y

Solution

//Following is the C++ program for the problem statement 5.

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()

{

int x,y;

int f1=0,f2=0,f3=0,f4=0;

cout<<\"Enter the value of x and y\ \";

cin>>x>>y;

if(x>0 && y>0)

f1=x*2+y*y;

else if(x>0 && y<=0)

f2=pow(3,((x-y)/(x+y)));

else if(x<=0 && y>=0)

f3=pow(x+y,(x*x-y*y*y)/(x+y)*(x-y));

else if(x<=0 && y<=0)

f4=pow((x*y)/(x-y),x*y/3);

cout<<\"Value of F1 :\"<<f1<<\"\ \";

cout<<\"Value of F2 :\"<<f2<<\"\ \";

cout<<\"Value of F3 :\"<<f3<<\"\ \";

cout<<\"Value of F4 :\"<<f4<<\"\ \";

return 0;

}

//Output:

~$ g++ first.cpp
~$ ./a.out
Enter the value of x and y
2
3
Value of F1 :13
Value of F2 :0
Value of F3 :0
Value of F4 :0
~$ ./a.out
Enter the value of x and y
2
0
Value of F1 :0
Value of F2 :3
Value of F3 :0
Value of F4 :0

 Write a C/C+ program that uses if and else if statements to calculate and display the value where the user inputs the values of integers x and y from the cases
 Write a C/C+ program that uses if and else if statements to calculate and display the value where the user inputs the values of integers x and y from the cases

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site