0% found this document useful (0 votes)
28 views

Laboratory Work 8

The document provides 20 examples of C++ programs that define functions to calculate various mathematical expressions. Each function takes a float variable x as a parameter, performs the specified calculations, and returns the result. The main function prompts the user to input a number, passes it to the function, and outputs the return value. The expressions involve operations like logarithms, exponents, trigonometric functions, and absolute values applied to variables and constants.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Laboratory Work 8

The document provides 20 examples of C++ programs that define functions to calculate various mathematical expressions. Each function takes a float variable x as a parameter, performs the specified calculations, and returns the result. The main function prompts the user to input a number, passes it to the function, and outputs the return value. The expressions involve operations like logarithms, exponents, trigonometric functions, and absolute values applied to variables and constants.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Laboratory work

Malikomar Yerkebulan IT1-2110


Write a C++ program for solving this task, using a function. You must
write your function in the program:
5 4 3 3x
1. f ( x )=|x−1. 5|+ √ x + √ e +4;
Solution:
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=(fabs(x-1.5)+pow(x,4/5))+pow((exp(3*x)+4),1/3);

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
5
f ( x )=tg x+ln|2 x +5|+1 . 8 ;
2. 3

Solution:
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=tan(5*x/3)+log(fabs(2*x+5))+1.8;

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
5
3. f ( x )=x +ln √ π+|5−x|;
Solution:
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=pow(x,5)+log(sqrt(3.14+fabs(5-x)));
cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
4
4. f ( x )=√ e +7+cos x +ln|3 x+7|
3x 5

Solution:
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=pow(exp(3*x)+7,1/4)+cos(pow(x,5))+log(fabs(3*x+7));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
3
5. f ( x )=tg sin πx +x + √e ;
7 2 x +3

Solution:
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=tan(sin(3.14*x))+pow(x,7)+pow(exp(2*x+3),1/3);

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
7
6. f ( x )=√ x +1 .7+cos x +ln x +sin πx ;
5 3 4

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=pow(pow(x,5)+1.7,1/7)+cos(pow(x,3))+log(pow(x,4))+sin(3.14*x);

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
5
7. f ( x )=ln|7 x +3|+ √ e +sin x +tg 4 x .
9 3 x+5 6

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=log(fabs(7*x+3))+pow(exp(3*x+5),1/5)+sin(pow(x,6))
+tan(4*x);

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
8. f ( x )=√ x+0.7+cos x +sin πx ;
32

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=sqrt(x+1.7)+cos(pow(x,32))+sin(3.14*x);

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}

9. f ( x )=ln|2x +10|+ √ e +tg3 x.


9 3 x+5

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=log(fabs(pow(2*x,9)+10))+pow(exp(3*x+5),1/2)+tan(3*x);

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
11. f ( x )=cos πx +cos x + √ e
7 x +3
;

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=cos(5*x)+pow(3.14+fabs(2-x),(1/7));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
7
12. f ( x )=cos5 x+ √ π+|2−x|;
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=cos(5*x)+pow(3.14+fabs(2-x),(1/7));

cout<<"Your result:"<<s;
}
int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}

5
13. f ( x )=√ x +4+sin x +tgx ;
3 4 3

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=pow(pow(x,3)+4,1/5)+sin(pow(x,4))+tan(pow(x,3));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
5 3 4
14. f ( x )=ln5 x +x sin x +tgx ;
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=log(5*x)+pow(x,5)*sin(pow(x,4))+tan(pow(x,3));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}

2 3
15. f ( x )=ln|5 x+3|+cosπx +tgx ;
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=log(5*x+3)+cos(pow(x,4))+tan(pow(x,3));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
16.0

7
17. f ( x )=x +ln √2 π+|7−x|;
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=pow(x,7)+log(sqrt(2*3.14+fabs(7-x)));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
3 2
18. f ( x )=cos x +ln x +sin 3 πx ;

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=pow(x,3)+log(sqrt(2*3.14+fabs(7-x)));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
3
19. f ( x )=x +ln √5 π+|9−x|;
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=pow(x,3)+log(sqrt(2*3.14+fabs(7-x)));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}
2 3
20. f ( x )=ln|9x+3|+sin πx +tgx ;

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
float algebramath(float x){
float s;
s=pow(x,3)+log(sqrt(2*3.14+fabs(7-x)));

cout<<"Your result:"<<s;
}

int main() {
float x,res;
cout<<"Enter Your number=";
cin>>x;
algebramath(x);
}

You might also like