C++ program that read values of w, x, y and z and display the value of P.

Q28. Write a program to read values of w, x, y and z and display the value of P, where

P= w+x / y-z

Ans.

#include<iostream.h>

#include<conio.h>   //for clrscr()

void main()

{

int w,x,y,z,P;

clrscr();          //for clear screen

cout<<“\n Enter the value of w: “;

cin>>w;

cout<<“\n Enter the value of x: “;

cin>>x;

cout<<“\n Enter the value of y: “;

cin>>y;

cout<<“\n Enter the value of z: “;

cin>>z;

P=(w+x)/(y-z);

cout<<“\n The value of P is: “<<P;

}

 

Output

Enter the value of w: 5

Enter the value of x: 5

Enter the value of y: 20

Enter the value of z: 10

The value of P is: 1

Leave a Reply

Your email address will not be published. Required fields are marked *

267 Views
%d bloggers like this: