# C++ program to find the value of y for a particular value of n

## C++ program to find the value of y for a particular value of n

Write a program to find the value of y for a particular value of n. The a, x, b, n is input by user

• if n=1 y=ax%b
•  if n=2 y=ax²+b²
• if n=3 y=a-bx
• if n=4 y=a+x/b .

Sample input

`2 3 41 1 (Values of a,x,b,n)`

Sample output

`Value of the y is: 6`

## C++ program to find the value of y for a particular value of n

The objective of the code is to find the value of y .

Code(C++):-

#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,x,b,n,y;
cout<<"Enter the value of a,x,b,n\n";
cin>>a>>x>>b>>n;
if(n==1)
y=(a*x)%b;
if(n==2)
y=(a*x*x)+(b*b);
if(n==3)
y=a-b*x;
if(n==4)
y=a+(x/b);
cout<<"Value of the y is: "<<y;
return 0;
}

Output:-

Enter the value of a,x,b,n
2 3 41 1
Value of the y is : 6

### Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-
iMocha coding Questions:-
Tech Mahindra coding questions:-
Unthinkable Solutions coding questions:-