Advertisement
Bitupx

ari- ejercicios 1.2

Apr 13th, 2025 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int cantidad;
  6.     float nota, notapromedio, notamax, notamin;
  7.  
  8.     cout << "Ingrese la cantidad de estudiantes: ";
  9.     cin >> cantidad;
  10.  
  11.     // ❌ Aquí está pidiendo solo una nota fuera del bucle.
  12.     //    Eso significa que usará la misma nota para todos los estudiantes, lo cual está mal.
  13.     cout << "Ingrese su nota final: ";
  14.     cin >> nota;
  15.  
  16.     // ❌ Esta línea de for tiene errores:
  17.     // - 'For' debe ir en minúscula: 'for'
  18.     // - 'nota -> cantidad' no tiene sentido. Probablemente quiso decir: i < cantidad
  19.     // - Falta declarar la variable 'i'
  20.     For (int i = 0; nota -> cantidad; i++)
  21.  
  22.     // ❌ El cálculo del promedio está mal:
  23.     //    Está dividiendo cantidad / nota, cuando lo correcto sería: sumaNotas / cantidad
  24.     notapromedio = cantidad / nota;
  25.  
  26.     cout << "El promedio de las notas es de: " << notapromedio << endl;
  27.  
  28.     // ❌ Este segundo bucle también tiene errores:
  29.     // - 'For' mal escrito (debe ser 'for')
  30.     // - La condición 'i > nota' es incorrecta. Además, no se justifica este segundo bucle
  31.     For (int i = 0; i > nota; i++)
  32.  
  33.     // ✅ Esta condición es válida, pero está usando solo UNA nota para decidir si es aprobado
  34.     //    y debería hacerlo con cada nota dentro del bucle principal
  35.     if (nota >= 60) {
  36.         cout << "aprobado" << endl;
  37.     }
  38.     else {
  39.         cout << "desaprobado" << endl;
  40.     }
  41.  
  42.     return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement