Promedio de notas

Pedir al usuario 5 notas y calcular el promedio usando un ciclo PARA.

← Volver a Artículos

¿Cómo funciona?

Pedir al usuario 5 notas y calcular el promedio usando un ciclo PARA.



Solución en PSeInt

Proceso PromedioNotas
Definir i Como Entero;
Definir nota, suma, promedio Como Real;
suma <- 0;
Para i <- 1 Hasta 5 Con Paso 1 Hacer
  Escribir "Ingrese nota ", i, ": ";
  Leer nota;
  suma <- suma + nota;
FinPara
promedio <- suma / 5;
Escribir "Promedio = ", promedio;
FinProceso


Solución en Python

suma = 0
for i in range(1,6):
    nota = float(input(f"Ingrese nota {i}: "))
    suma += nota
print("Promedio =", suma/5)


Solución en JavaScript

let suma = 0;
for (let i = 1; i <= 5; i++) {
  let nota = parseFloat(prompt("Ingrese nota " + i + ":"));
  suma += nota;
}
console.log("Promedio =", suma/5);


Solución en C++ (Dev C++)

#include 
using namespace std;
int main() {
  double suma=0, nota;
  for(int i=1;i<=5;i++) {
    cout << "Ingrese nota " << i << ": ";
    cin >> nota;
    suma+=nota;
  }
  cout << "Promedio = " << suma/5 << endl;
  return 0;
}


Solución en C#

using System;
class Program {
  static void Main() {
    double suma=0;
    for(int i=1;i<=5;i++) {
      Console.Write("Ingrese nota " + i + ": ");
      double nota = double.Parse(Console.ReadLine());
      suma+=nota;
    }
    Console.WriteLine("Promedio = " + suma/5);
  }
}


Solución en Java

import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double suma=0;
    for(int i=1;i<=5;i++) {
      System.out.print("Ingrese nota " + i + ": ");
      double nota = sc.nextDouble();
      suma+=nota;
    }
    System.out.println("Promedio = " + suma/5);
  }
}


Publicado por: ObiWan
Fecha: 13/09/2025