Hey guys I am stuck with this program and i need help with it
this is what i got until now

#include <stdio.h>
#include "checkit.h"

double vectorDotProduct(double x1, double y1, double z1, double x2, double y2, double z2) 
{
	return(x1 * x2 + y1 * y2 + z1 * z2);
}
int main (void)
{
  int x,y,z,a,b,c;
  printf("Please enter the x, y, and z coordinates for the first vector: ");
  scanf("%f%f%f",&x,&y,&z);
  printf("Please enter the x, y, and z coordinates for the second vector: ");
  scanf("%f%f%f",&a,&b,&c);
  
  return 0;
}

this is for my hw but I am absolutely stuck on this one. Im trying to get help but its not working out.

Recommended Answers

All 3 Replies

Hey guys I am stuck with this program and i need help with it
this is what i got until now

#include <stdio.h>
#include "checkit.h"

double vectorDotProduct(double x1, double y1, double z1, double x2, double y2, double z2) 
{
	return(x1 * x2 + y1 * y2 + z1 * z2);
}
int main (void)
{
  int x,y,z,a,b,c;
  printf("Please enter the x, y, and z coordinates for the first vector: ");
  scanf("%f%f%f",&x,&y,&z);
  printf("Please enter the x, y, and z coordinates for the second vector: ");
  scanf("%f%f%f",&a,&b,&c);
  
  return 0;
}

this is for my hw but I am absolutely stuck on this one. Im trying to get help but its not working out.

A first look would suggest that you have declared variables a, b, c, x, y and z as integers and scanning in the scanf() function call for these variables as floats.

A first look would suggest that you have declared variables a, b, c, x, y and z as integers and scanning in the scanf() function call for these variables as floats.

but in class we havent used floats yet. I saw some examples on internet but they were too advanced for the class i am in right now. We're just in the basics. we went through only printf, int /double functions and scanf and if statements lol

but in class we havent used floats yet. I saw some examples on internet but they were too advanced for the class i am in right now. We're just in the basics. we went through only printf, int /double functions and scanf and if statements lol

Well then, change your scanf's as so:

scanf("%d%d%d",&x,&y,&z);

Also, in your code snippet, you are not calling the function - perhaps something like this may help:

printf("The result is %lf\n", vectorDotProduct(a, b, c, x, y, z));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.