2 and 3 Write a program that needs of a and b to calculate t
2 and 3
Solution
2)
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n,k;
double z;
cout<<\"\ enter n , k : \";
cin>>n;
cin>>k;
abc:
cout<<\"\ enter n between 0 and 180 :\";
cin>>n;
if(!(n>=0&&n<=180))
goto abc;
z=k*sin((n*PI)/180)+sqrt(n*k)
cout<<\"z=\"<<z;
return 0;
}
3)
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n,k;
double s;
cout<<\"\ enter n , k : \";
cin>>n;
cin>>k;
abc:
cout<<\"\ enter n between 0 and 180 :\";
cin>>n;
if(!(n>=0&&n<=180))
goto abc;
s=0.0;
for(int i=1;i<=n;i++)
{
s=s+(pow(k,sqrt(i)))*sqrt(sin(i));
}
cout<<\"s=\"<<s;
return 0;
}
