Вы находитесь на странице: 1из 5

Ministerul Educaiei al Republicii Moldova

Universitatea Tehnic a Moldovei

Catedra Informatica Aplicat

RAPORT
Lucrarea de laborator nr.1
la Programarea Calculatoarelor

A efectuat:
st. gr. FAF-161

V. Cola

A verificat:
dr., conf.univ.

M. Kulev

Chiinu -2016
0

Laboratory work no.1


Subject: Programming liniar structured algorithms
Objective: Gaining the practice skills of elaborating and programming an
algorithm of liniar calculus, skills of writing and testing programs n C language.
Task [1]: To calculate the values of the given variables according to following
formulas and initial data. To introduce initial data from the keyboard. To print the
obtained results on the screen.
Variant 8:
Calculus:
D=sin(e2cost+z-x3)+lnz
C=(x3+t-sin2x3/(2t+z))/|x-t3z|
Initial data values:
x = 0.1
t= 0.5
z = 2.5
The process:
Main notions of theory and used methods:
In computer programming algorithm is a finite set of operations (actions) to
solve the problem on the computer. There are several forms of representation of
algorithms [2]:
- natural form,
- graphic form,
- pseudo form,
- program written in a programming language.
Linear structured algorithm is characterized by the absence of decision operations
[2].
The structure of a simple program in C is the following [2, 3]:
- preprocessor directives;
- header of function main( );
- body of function main( ).
Functions structure in C:
- .........
1

Data analysis:
a) input data:
x,t,z simple variables of float type, parametrii expresiilor date (type from the
keyboard).
b) output data:
D,C - simple variables of float type, the values of given expressions (write on
the screen).
c) intermediate data: doesnt exist.
Flowchart of the algorithm:

Start
clrscr()
Inroduceti datele
initiale x,t,z:
x,t,z
D=sin(e2cos+z-x3)+lnz
C=(x3+t-sin2x3/(2t+z))/|x-t3z|
Rezultatele
obtinute:
D=,D
C=,C
Q
getch()
Stop

The code of the program in C:


#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
float t,z,x;
float d,c;
printf("Enter t,z,x:");
scanf("%f%f%f",&t,&z,&x);
d = sin(exp(2*cos(t)+z)-pow(x,3))+log(z);
c = (pow(x,3) + t-(pow(sin(pow(x,3)),3))/(2*t + z))/(pow(abs(x-pow(t,3)*z),1/2.));
printf("Results:\n");
printf("D:%.4f\nC:%.4f\n",d,c);
}
Input data (x, t, z):
0.1 0.5 2.5
Obtained results:
D = 1.893 , C = 1.087
Testing and verifying the results:
D=sin(e2cos0.5+2.5-0.13)+ln2.5=sin(e4.5-0.001)+0.916=0.977+0.916=1.893
C=(0.13+0.5-sin20.13/(20.5+2.5))/|0.1-0.53 *2.5|=(0.501-3.046/23)/(-0.212)=1.087

Result analysis and conclusions:


1. Verification shows that the results are correct and the program works correctly.
2. Algorithms with linear structure may be used for the calculation of mathematical
expressions.
3. There were obtained first skills for writing a simple program in C language.

Bibliogaphy:
1. Carcea L.,Vlas S., Bobicev V. Informatica: Sarcini pentru lucrri de laborator.
Chiinu: UTM, 2005. - 19 p.
2. Conspectul prelegerilor cursului Programarea Calculatoarelor pentru studeni gr.
TI-154, TI-155, SI-151, SI-152. Lector: dr., conf. univ. M.Kulev. Chiinu, UTM,
2015.
3. Tutorial in C language. http://devcentral.iftech.com/learning/tutorials/ccpp/c/(accesat 12.09.2015).

Вам также может понравиться