Sie sind auf Seite 1von 6

1.

Dado N nmeros enteros ingresados por teclado,


determine el promedio de estos
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20

static void Main(string[] args)


{
Console.Write("Cantidad de nmeros a ingresar: ");
int cantidad = Convert.ToInt32(Console.ReadLine());
int suma = 0;
Console.WriteLine();
for (int i = 1; i <= cantidad; i++)
{
Console.Write(">Nmero {0}: ", i);
suma += Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
}
int promedio = suma / cantidad;
Console.WriteLine("> El promedio es: {0} \n", promedio);
Console.WriteLine("+ Presione cualquier tecla pata terminar");
Console.ReadKey();
}

2. Dado N notas de alumnos de computacin, se pide


calcular
a) Cantidad de alumnos aprobados. Nota mnima 51 puntos
b) Cantidad de reprobados
c) Promedio de notas totales, aprobados y reprobados
01 static void Main(string[] args)
02
{
03
Console.Write("Cantidad de notas a ingresar: ");
04
int cantidad = Convert.ToInt32(Console.ReadLine());
05
Console.WriteLine();
06
07
int tAprobados = 0;
08
int tReprobados = 0;
09
double tNotaAprobados=0, tNotaReprobados=0, tNotaCurso=0;
10
11
for (int i = 1; i <= cantidad; i++)
12
{
13
Console.Write("> Nota {0}: ", i);
14
double nota = Convert.ToDouble(Console.ReadLine());
15
Console.WriteLine();
16
tNotaCurso += nota;//se acumula el total de las notas
17
if (nota >= 51)//alumnos aprobados
18
{
19
tAprobados++;
20
tNotaAprobados += nota;
21
}

22
else
23
{
24
tReprobados++;
25
tNotaReprobados += nota;
26
}
27
}
28
29
Console.WriteLine("> Alumnos aprobados {0} con un promedio de {1}
puntos\n", tAprobados, Math.Round((tNotaAprobados/tAprobados),2));
30
Console.WriteLine("> Alumnos reprobados {0} con un promedio de {1}
puntos\n", tReprobados, Math.Round((tNotaReprobados / tReprobados),2));
31
Console.WriteLine("> El promedio total del curso es de {0} puntos \n",
Math.Round((tNotaCurso/cantidad),2));
32
33
Console.WriteLine("+ Presione cualquier tecla pata terminar");
34
Console.ReadKey();
35
}

3. Dado un array de N nmeros enteros positivos,


desarrolle un programa que permita sumar por
separados los nmeros pares de los impares. Mostrar
el resultado.
01 static void Main(string[] args)
02 {
03
04
int[] num = { 1, 34, 89, 15, 3, 17, 10, 32, 78, 98, 2, 4, 88 };
05
06
int tPar = 0;
07
int tImpar = 0;
08
09
//suma de numeros
10
for (int i = 0; i < num.Length; i++ )
11
{
12
if ((num[i] % 2) == 0)//es par
13
{
14
tPar += num[i];
15
}
16
else
17
{
18
tImpar += num[i];
19
}
20
}
21
Console.WriteLine("> Total suma nmeros pares: {0} \n",tPar);
22
Console.WriteLine("> Total suma nmeros impares: {0}", tImpar );
23
24
Console.ReadKey();
25 }

4. Desarrolle un programa para sumar dos matrices


33 usando mtodos, un mtodo para sumar y otro
mtodo para imprimir.

01 class Program
02
{
03
static void Main(string[] args)
04
{
05
06
int[,] a = { { 0, 2, 3 }, { 1, 2, 0 }, { 0, 2, 7 } };
07
int[,] b = { { 1, 2, 1 }, { 4, 5, 6 }, { 0, 6, 1 } };
08
09
10
Console.WriteLine("Matriz A");
11
imprimir(a);
12
Console.WriteLine("\nMatriz B");
13
imprimir(b);
14
Console.WriteLine("\nMatriz Resultantes");
15
int[,] c = sumar(a, b);
16
imprimir(c);
17
18
Console.ReadKey();
19
}
20
21
22
static int[,] sumar( int[,] a, int[,] b)
23
{
24
int[,] c = new int[3, 3];
25
26
for (int fila = 0; fila < 3; fila++)
27
{
28
for (int col = 0; col < 3; col++)
29
{
30
c[fila, col] = a[fila, col] + b[fila, col];
31
}
32
}
33
return c;
34
}
35
36
37
static void imprimir( int[,] matriz)
38
{
39
for (int f = 0; f < 3; f++)
40
{
41
for (int c = 0; c < 3; c++)
42
{
43
Console.Write(" {0} |",matriz[f,c]);
44
}
45
Console.WriteLine("");
46
}
47
}
48
49
50
}
programa para cajero automatico
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40

41
42
43
44

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
Program cajero;
static void Main(string[] args)
{
use;
crt;
var;
don; ret; consig; sald; serv:real;
opc; cla; opci;opcio:integer;
begin;
whileopc.<6; DOBEGIN;
clrscr;
gotoxy(20,3);
Console.ForegroundColor;
Writeline;("----BIENVENIDO A SUS CAJEROS AUTOMATICOS DIANA----");
WriteLline;("");
gotoxy(20,3);
Console.ForegroundColor(blue);
WriteLine("por favor inserte su tarjeta y siga las intrucciones");
gotoxy(20,5);
Console.ForegroundColor(blue);
WriteLine("digite su clave por favor");
ReadLine(cla);
if cla<>4711; thenbegin;
gotoxy(20,6);
Console.ForegroundColor(blue);
WriteLine("su clave es incorrecta;rectifiquela por favor");

ReadLine(cla);
end,
WriteLine("");
if cla;=4711;THENBEGIN;
clrscr;
WriteLine("*****menu principal******");

}
}
}

Das könnte Ihnen auch gefallen