1. Program the following. Implement the following equation 3x4 sin(180x) + 4x3 cos(90x) + x2 sin(tan(45)) + 7x + 9cos(90x2 ) where x may be user defined value. 2. Program the following. Prompt user to input distance in Kilometers and display it in meters. Input any number from user and generate its square e.g. square of 8 is 64 Input any number from user and generate its cube e.g. cube of 8 is 512 Input a 4 digit number in any integer type variable and sum all the four digits, e.g. int a =3487, result = 22 Generate the table for a number input by the user. For the following equation 3x4 + 4x3 + x2 + 7x + 9, substitute the user provided value of x and generate the result.
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<"Enter the value of x : ";
int x;
cin>>x;
int eq = (3*(pow(x,4)*sin(180*x))) + (4*pow(x,3)*cos(0*x)) + (pow(x,2)*sin(tan(45)))+ (7*x) + (9*cos(90*(pow(x,2))));
cout<<"Value of eqn (3*(pow(x,4)*sin(180*x))) + (4*pow(x,3)*cos(0*x)) + (pow(x,2)*sin(tan(45)))+ (7*x) + (9*cos(90*(pow(x,2)))) is : "<<eq<<endl;
cout<<endl;
cout<<"Enter distance in kilometers : ";
int km;
cin>>km;
cout<<"Distance in meters : "<<km*1000<<endl<<endl;
cout<<"Enter a number : ";
int n;
cin>>n;
cout<<"Square of "<<n<<" : "<<pow(n,2)<<endl<<endl;
cout<<"Enter a 4-digit number : ";
int num;
cin>>num;
int sum=0;
while(num>0)
{
int rem = num%10;
sum += rem;
num = num/10;
}
cout<<"Sum of digits : "<<sum<<endl<<endl;
cout<<"Enter a number for which u want to see its table : ";
int t;
cin>>t;
cout<<"Table of t"<<endl<<"--------------------"<<endl<<endl;
for(int i=1; i<=10; i++)
{
cout<<t<<" * "<<i<<" = "<<t*i<<endl;
}
int m;
cout<<endl;
cout<<"Enter a number : ";
cin>>m;
int ans = (3*pow(m,2)) + (4*pow(m,3)) + pow(m,2) + (7*m) + 9;
cout<<"Value of eqn (3*pow(m,2)) + (4*pow(m,3)) + pow(m,2) + (7*m) + 9 is ";
cout<<ans<<endl;
}
Comments
Leave a comment