******** En Algorithme ********
Algorithme Moyenne_Notes Variables Notes[10], S :réels i :entier Debut S ← 0 pour i de 1 jusqu'à 10 faire Lire (Notes[i]) S ← S + Notes[i] FinPour Ecrire ("La moyenne est:",S/10) Fin Résultat => 2 6 6 7 5 6 1 0 7 1 La moyenne est: 4,1
Retour vers la liste d'exercices
******** En C ********
#include <stdio.h> int main(){ float notes[10],Som=0; int i ; for( i=0; i < 10; i++){ printf("Entrer un entier:"); scanf("%f",¬es[i]); Som = Som + notes[i]; } printf("La moyenne est:%f",Som/10); return 0; }
Retour vers la liste d'exercices
******** En C++ ********
#include <iostream>
using namespace std;
int main(){
float notes[10],Som=0;
int i;
for( i=0; i<10; i++){
cout<<"Entrer un entier:";
cin>>notes[i];
Som = Som + notes[i];
}
cout<<"La moyenne est "<<Som/10;
return 0;
}
******** En JAVA ********import java.util.Scanner;
class Main {
public static void main(String[] args){
Scanner sc = new Scanner (System.in);
float[] notes = new float[10];
float Som=0;
int i ;
for( i=0; i < 10; i++){
System.out.print("Entrer un entier :");
notes[i] = sc.nextInt();
Som = Som + notes[i];
}
System.out.print("La moyenne est: "+Som/10);
}
}
******** En C# ********
using System;
public class Ex26{
public static void Main(string[] args)
{
float[] notes = new float[10];
float Som=0;
int i ;
for( i=0; i < 10; i++){
Console.Write("Entrer un entier :");
notes[i]=float.Parse(System.Console.ReadLine());
Som = Som + notes[i];
}
Console.Write("La moyenne = "+Som/10);
}
}
class Main {
public static void main(String[] args){
Scanner sc = new Scanner (System.in);
float[] notes = new float[10];
float Som=0;
int i ;
for( i=0; i < 10; i++){
System.out.print("Entrer un entier :");
notes[i] = sc.nextInt();
Som = Som + notes[i];
}
System.out.print("La moyenne est: "+Som/10);
}
}
using System;
public class Ex26{
public static void Main(string[] args)
{
float[] notes = new float[10];
float Som=0;
int i ;
for( i=0; i < 10; i++){
Console.Write("Entrer un entier :");
notes[i]=float.Parse(System.Console.ReadLine());
Som = Som + notes[i];
}
Console.Write("La moyenne = "+Som/10);
}
}
0 Commentaires