C program to read values of w, x, y and z and display the value of P, where P= w+x / y-z.

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

P= w+x / y-z

Ans.

#include<stdio.h>

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

void main()

{

int w,x,y,z,P;

clrscr();          //for clear screen

printf(“\n Enter the value of w: “);

scanf(“%d”,&w);

printf(“\n Enter the value of x: “);

scanf(“%d”,&x);

printf(“\n Enter the value of y: “);

scanf(“%d”,&y);

printf(“\n Enter the value of z: “);

scanf(“%d”,&z);

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

printf(“\n The value of P is: %d”,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 *

96 Views
%d bloggers like this: