// create a structure to store vectors.Then make a function to return
// sum of two vectors
#include <stdio.h>
struct vector {
int x;
int y;
}; //remember to put ; after ending of struct structure
void calcSum(struct vector v1,struct vector v2, struct vector sum);
int main() {
struct vector v1 = {5, 10};
struct vector v2 = {3, 7};
struct vector sum={0};
calcSum(v1, v2, sum);
return 0;
}
void calcSum(struct vector v1, struct vector v2, struct vector sum){
sum.x = v1.x + v2.x;
sum.y = v1.y + v2.y;
printf("sum of x is : %d\n",sum.x);
printf("sum of y is : %d",sum.y);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: