MR PROGRAMATOR

Vectores A y B

/************************************/
/*    Nombre del programa : prog11            */
/*    Autor : Luis Alberto Saucedo                    */
/*    Objetivo : Vectores                                    */
/*    Fecha: 15/05/12                                        */
/************************************/
#include <stdafx.h>
#include <malloc.h>
#define NMAX 1000;
void leerVector(int N, float *V);
float promedio(int N, float *V);
int main (void)
{
    int N;
    float P,P2;
    float A[1000];
    float B[1000];
    printf("nIngrese el número de notas que va a ingresar: ");
    do
    {
        scanf_s("%d",&N);
    }
    while(N<1 || N>1000);
    printf("nVECTOR An");
    leerVector(N,A);
    printf("nVECTOR Bn");
    leerVector(N,B);
    P = promedio(N,A);
    P = P*P;
    P2= promedio(N,B);
    P = P + P2;
    printf("nLa suma es : %10.2fn",P);
    return 0;
}
void leerVector(int N, float *V)
{
    
    int i;
    for(i = 0; i<N; i++)
    {
        printf("nIngrese el valor %d: ",i+ 1);
        scanf_s("%f",&V[i]);
    }
    
}
float promedio(int N, float *V)
{
    float S,P;
    int i;
    S = 0;
    for(i = 0; i<N; i++)
    {
    S = S + V[i];
    }    P = S/float(N);
    return P;
}
Este sitio web fue creado de forma gratuita con PaginaWebGratis.es. ¿Quieres también tu sitio web propio?
Registrarse gratis