👤

Care este valoarea tipărită de secvenţa de
program C/C++ alăturată, ştiind că x şi y
sunt variabile întregi, iar z este o variabilă
reală? (4p.)
x=30;
y=5;
z=(x+y)/6.0;
z=floor(z*100);
z=z/100;
cout< a. 5 b. 5.833333 c. 5.83 d. 583


Răspuns :

pasii sunt:
z = (x + y)/6.0 deci z = 5.83333333333333 etc.
z = floor (z*100) => z = floor (583.333333) => z = 583
z = z / 100 => z = 5.83
program in Visual Studio 2011 in Windows 7:

#include "stdafx.h"#include <math.h>       /* floor */

int _tmain(int argc, _TCHAR* argv[]){ int x,y;float z; x=30;y=5;z=(x+y)/6.0;z=floor(z*100);z=z/100;//cout< a. 5 b. 5.833333 c. 5.83 d. 583 return 0;}

Nu conoste statement cout cum este scris.
Variabile la sfarcit de program sunt:
x=30 int
y=6 int
z= 5.82999992 float