Частина тексту файла (без зображень, графіків і формул):
Звіт
з лабораторної роботи №4
«Розробка програм розгалуженої структури»
з дисципліни:
«Алгоритмічні мови та програмування»
.
Лабораторна робота №4
Розробка програм розгалуженої структури
The purpose of the work: To learn to make programs of a branched structure.
Variant:4
1.
+ -
+ -
+ -
C++ code:
//function main() declaration
int main()
{
//declaration of variable
int x;
float y;
//displaying text on the screen
cout <<"x=";
//data input
cin>>x;
if (x>0 && x<=1)
y=-atan((x+3.14)/(pow(x,2))); // executed if x is greater than 0 and less or equal to 1
if (x>1 && x<10)
y=log(fabs(pow(x,3))); // executed if x is greater than 1 and less than 10
if (x<=0.10 && x>=0.10)
y=exp(-x); // executed if x is less than or equal to 0.10 and greater or equal to 0.10
//displaying the value on the screen
cout<<"y="<<y<<endl;
//the end
return 0;
}
Result:
/
2.
+ -
+ -
+ -
C++ code:
//declaration of libraries
#include <iostream>
#include <cmath>
using namespace std;
//function main() declaration
int main()
//declaration of variable
{double k,l,m,n,p;
//displaying text on the screen
cout<<"k=";
//data input
cin>>k;
//displaying text on the screen
cout<<"l=";
//data input
cin>>l;
if (fabs (n)<5)
n=(1-2*k)/2; // executed if fabs (n) is less than 5
if (fabs (m)<5)
m=(2*1+k)/1; // executed if fabs (m) is less than 5
if (fabs (p)<5)
p=l*k-9.3; // executed if fabs (p) is less than 5
//displaying the value on the screen
cout <<"n="<<n<<endl;
cout <<"n*n="<<n*n<<endl;
cout <<"m="<<m<<endl;
cout <<"m*m="<<m*m<<endl;
cout <<"p="<<p<<endl;
cout <<"p*p="<<p*p<<endl;
//the end
return 0;
}
Result:
/
Conclusion: we learned to make programs of a branched structure in the environment of CodeBlocks and made the programs using the conditional operator - if, which has three operands.