Sie sind auf Seite 1von 5

Technical University Of Moldova

Faculty CIM

Report
on Labaratory Work nr.1
at Computer Programming realized in C++
Subject: Employment of Control and Looping Function
V-5

Accomplished : st.gr.FAF-081

Colun Mihai

Checked by:

Kulev Mihail

Chisinau 2008

LABWORK NR.1

Objective : Studying the ways of usage of condition check


operators and cycle operators for tabulation of function.
Problem : Calculate and compute the result of next function on
screen on a given interval, with step dx, also given by user.
a, b, c are real numbers.

1
ax b
x a
F
sin x
10 x
c 6

, if + < 0 and = 0;
, if + a > 0 and 0;
, in other cases.

Work course: In this Labwork i have calculate values of


function F in diferents points x on inteval [x1,x2] using step
dx.For this problem i have used looping function for and ifelse statement. a,b,c,x1,x2,dx are read from the keyboard.
Variable op describe the number of operation.

Start

Clrscr()

a,b,c,x1, x2,dx

Results\n

OP
OP=1

.
.
.

x=x1, x<=x2,
x=x+dx

x+c<0 &&
b=0

NO

YES

F=(a+b)/log(x-c)
x+c>0 && b!
=0

YES

NO
F=(sin(a)-x+3)/(c*c)

F=(4*x*x+8)/(a*a*x)+sin(x)

Getch()
"<%i> x=%.2f; F=%.3f\n",op,x,F

op=op+1

STOP

Program:
# include <stdio.h>
# include <math.h>
# include <conio.h>
int main()
{float a,b,c,x,x1,x2,D,F;
int op;
clrscr();
printf("introduceti datele a,b,c,x1,x2,D\n");
scanf("%f%f%f%f%f%f",&a,&b,&c,&x1,&x2,&D);
printf("results: \n");
op=1;
for(x=x1;x<=x2;x=x+D)
{if ((x+c<0)&&(b==0)) F=(a+b)/log(x-c);
else if ((x+c>0)&&(b!=0)) F=(sin(a)-x+3)/(c*c);
else F=(4*x*x+8)/(a*a*x)+sin(x);
printf("<%i> x=%.2f; F=%.3f\n",op,x,F);
op=op+1;
}
getch();
return 0;
}

Results on screen:

Conclusion:after computing the program i can say that for is a


easy looping function and if-else statement its an easy control
function in C++.

Das könnte Ihnen auch gefallen