-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconversionTipos.cpp
More file actions
26 lines (20 loc) · 858 Bytes
/
conversionTipos.cpp
File metadata and controls
26 lines (20 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Proyecto: TiposDeDatos
// Archivo: conversionTipos.cpp
// Este programa demuestra la conversión implícita de un número entero (int) a un número decimal (float).
// Se muestra el valor original del número entero y su valor convertido a float.
// Programador: Profesorcito
// Fecha: 27/ene/2025
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
system("chcp 65001");
system("chcp 65001");
int num = 10; // Variable de tipo int
float decimal = num; // Conversión implícita de int a float
cout << "Número entero: " << num << endl;
cout << "Número convertido a float: " << decimal << endl;
cout << "Número convertido a float: " << fixed << setprecision(2) << decimal << endl;
cout << "Número convertido a float: " << fixed << setprecision(4) << decimal << endl;
return 0;
}