Saturday, July 29, 2017

Given the following pseudo code, write a program that executes it.

/*
Pseudocode

a.read x
b.read y
c.compute p=x*y
d.compute s=x+y
e.total=s2+p*(s-x)*(p+y)
f.Print total
*/


/*
For more exercises and lessons, visit http://shegertech.blogspot.com/
*/

#include <cstdlib>
#include <iostream>
#include<iomanip>

using namespace std;

int main()
{
    float x;
    float y;
    float p;
    float s;
    float total;
    cout<<"Enter x value:";
    cin>>x;
    cout<<"\n";
    cout<<"Enter y value:";
    cin>>y;
    cout<<"\n";
    p=x*y;
    s=x+y;
    total=s*s+p*(s-x)*(p+y);
    cout<<"Total:"<<total;
    cout<<"\n";
 
    system("PAUSE");
    return EXIT_SUCCESS;
}

Share: