I need help desperately. To declare an array to hold 5 fives and pass the entire array to it and convert all the measurements in centimeters. The following is what I came up with:

#include <stdio.h>

#define SIZE 5

double calculateInches1 (double);
double calculateInches2 (double);
double calculateInches3 (double);
double calculateInches4 (double);
double calculateInches5 (double);

int main(void)
{
	int a[SIZE] = {0,1,2,3,4};
	int counter;
	double inches1, inches2, inches3, inches4, inches5;

	printf("Please enter value number 1 in inches:");
	scanf("%1f",&inches1);

	printf("Please enter value number 2 in inches:");
	scanf("%1f",&inches2);

	printf("\nPlease enter value number 3 in inches:");
	scanf("%1f",&inches3);

	printf("\nPlease enter value  number 4 in inches:");
	scanf("%1f",&inches4);

	printf("\nPlease enter value number 5 in inches:");
	scanf("%1f",&inches5);

	printf("The conversion of value number 1: is %3.2f cm", calculateInches1(inches1));

	return 0;
}

double calculateInches1(double inches1)

{
	return inches1 * 2.54;

	//printf("The conversion of measure in modifycalculateInches is %3.2f cm", calculateInches(inches));
}

Some snippets

double myInchesArray[5];
scanf("%lf", &myInchesArray[2] );  // now read about loops

Declare a function void foo ( double inches[] ); Call a function foo ( myInchesArray); Define a function

void foo ( double inches[] ) {
}

Please, please help me. I made the changes and I'm still having errors:

#include <stdio.h>

#define SIZE 5

double myInchesArray[5];

void mrinch ( double inches[]);

int main(void)

{
	//int a[SIZE] = {0,1,2,3,4};
	//int counter;
	double inches, inches1, inches2, inches3, inches4, inches5;

	printf("Please enter value number 1 in inches:  ");
	scanf("%lf", &myInchesArray[2] );

	printf("\nPlease enter value number 2 in inches:  ");
	scanf("%lf", &myInchesArray[2] );

	printf("Please enter value number 3 in inches:  ");
	scanf("%lf", &myInchesArray[2] );

	printf("\nPlease enter value  number 4 in inches:  ");
	scanf("%lf", &myInchesArray[2] );

	printf("\nPlease enter value number 5 in inches:");
	scanf("%lf", &myInchesArray[2] );

	printf("The conversion of value number 1 is: %3.2f cm", calculateInches(inches));
	//printf("The conversion of value number 1 is: %3.2f cm", calculateInches(inches));

	return 0;
}

double calculateInches(double inches)

{
	return inches * 2.54;

	//printf("The conversion of measure in modifycalculateInches is: %3.2f cm", calculateInches(inches));
}

That's because what I posted were NOT CHANGES, they were hints.

As in, you read them and then think about what they're saying, then apply that fresh insight to your specific problem.

Comments
A less popular but more admirable concept

That's because what I posted were NOT CHANGES, they were hints.

As in, you read them and then think about what they're saying, then apply that fresh insight to your specific problem.

An implementation of:
Give a man a fish and he will eat for a day. Teach a man to fish and he will eat for the rest of his life.
- Chinese Proverb

Another more popular implementation :
Give a man a fish and he will eat for a day. Teach him how to fish and he will sit in a boat and drink beer all day.

Comments
Online, give a man a fish today and he'll be back for another fish tomorrow ;)

Another one: Give man a fish he will keep it for next day. Teach a man how to fish he will keep that fish for another next day.

okay, theres a few things that i can see wrong with your code.

Line 7

void mrinch ( double inches[]);

your declaring the function "mrinch" ,but the function doesnt exist within your code.

Line 37

double calculateInches(double inches)

your defining the function "calculateInches" but the function hasnt been declared at the top.

maybe your declaration on line 7 should be

double calculateInches(double inches);

in your scanf calls your always reading the data into the same place so it will overwrite the data each time. the number in the square brackets is the position in the array so in your case between 0(first number) - 4(last number)

your code

printf("Please enter value number 1 in inches: ");
scanf("%lf", &myInchesArray[2] );

should be

printf("Please enter value number 1 in inches: ");
scanf("%lf", &myInchesArray[0] );

and another possible implementation:

Give a man a fish and he will eat for a day, teach a man to fish and he will get tired of eating fish.

This article has been dead for over six months. Start a new discussion instead.