reate data type VECTOR in c
Step 1: Write the following code in the file vector.h
//vector.h
typedef struct vect{
int i;
int j;
}VECTOR;
VECTOR add_vect(VECTOR x,VECTOR y){
VECTOR sum;
sum.i=x.i+y.i;
sum.j=x.j+y.j;
return sum;
}
void print(VECTOR z){
printf("%di+%dj",z.i,z.j);
}
Step 2: Now by including vector.h you can use VECTOR data type and add_vect and print function.
#include"vector.h"
#include"stdio.h"
int main(){
VECTOR a={5,4},b={4,8},c;
c=add_vect(a,b);
print(c);
return 0;
}
Output: 9i+12j
1 comment:
I was wondering if you could tell me what this means as it is the name of a withdrawal from my bank account.
OUTPUTON.C 39.95_V
Post a Comment