EJERCICIO CLASE
Realizar un programa en la que se utilice la funcion struct
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
struct vector {
double x;
double y;
};
struct vector sumar (struct vector v1, struct vector v2) {
struct vector vres;
vres.x = v1.x + v2.x;
vres.y = v1.y + v2.y;
return vres;
}
int main (){
struct vector va;
struct vector vb;
struct vector vc;
va.x=0.5;
va.y=1;
vb.x=1;
vb.y=0.5;
vc = sumar (va,vb);
printf ("res: \n%.2f,\n%.2f,\n%.2f", vc.x, vc.y);
getch ();
}
No hay comentarios:
Publicar un comentario