Homework: Converting Temperature (F to K)

This is a discussion on Homework: Converting Temperature (F to K) within the C Programming forums, part of the General Programming Boards category; Hey everyone! I am rushing to finish my last Cprogramming homework question. However i am not that familiar with Calling ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    6

    Unhappy Homework: Converting Temperature (F to K)

    Hey everyone! I am rushing to finish my last Cprogramming homework question. However i am not that familiar with Calling functions and i was wondering if u guys can check out my program and educate me on what errors i made. (I know I should read up on this kind of stuff but i just have no time today) So please any help would be greatly appreciated. Thanks!

    Code:
    #include <stdio.h>
    #include <math.h>
    
    
    int main (void)
    {
    
    	float a[6], b[6], p;
    
    	FILE *input;
    	FILE *output;
    	input = fopen("a7q2.in","r");
    	output= fopen("a7q1.out","w");
    	
    	a[i]=read_data(float a[i]);	  	  	  	  	  	  	  	  	  	  	  //Reading Data
    	
    	k[i]=temp_conv(float a[i], k[i], numbers);	  	  	  	  	  	  	  //Converting F to K
    	
    	print2(float a[i], k[i];								 	 	 //Printing to screen and
    	
    }
    
    int read_data (float a[i])
    
    	{
    	fscanf(input,"%f",&a[i]);
    	}
    	
    int temp_conv(float a[i], k[i], numbers)
    
    	{
    	for (i=0, i<20, i++)
    		{
    		
    		if (i=0)
    			{
    			numbers=a[i]
    			}
    		
    		else if (i>0 && i<20)
    			{
    			k[i]=(a[i]-32)*(5/9)+273.15
    			}
    	}
    	
    print2(float a[i], k[i])
    
    	{
    	printf("The total number of the temperatures is: %f"
    		   "Temp (F)		Temp (K)"
    		   "%.2f			%.2f", numbers, a[i], k[i]);
    	
    	fprintf(outfile,"The total number of the temperatures is: %f"
    		   			"Temp (F)	 	 Temp (K)"
    		   			"%.2f	 	 	 %.2f", numbers, a[i], k[i]);
    	}
    please retain format as much as possible

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Dude - function prototypes - use them. You are not supposed to call a function before it is defined.

    And be sure you use proper return types - if you don't want the function to return a value (ie, you want it to just do something and not return a value to the caller), use a void return type. Otherwise, you need to use the return statement.

    You need to check out your for statements too - gotta be careful you don't type a comma instead of a semi-colon.

    There is more, but this should get you started.

    If you get more help than what I have given you here, you are doing well. A lot of people on here get somewhat annoyed when people want a rush fix up job on a rushed homework assignment. Maybe a poor mark would be enough motivation to start it earlier next time. That said, good luck on figuring out your bugs.

    ~/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Temperature conversion...
    By Onslaught in forum C Programming
    Replies: 3
    Last Post: 10-21-2005, 02:15 PM
  2. read the CPU temperature
    By BianConiglio in forum Windows Programming
    Replies: 2
    Last Post: 05-19-2004, 12:41 PM
  3. Homework
    By kermi3 in forum C Programming
    Replies: 10
    Last Post: 09-27-2001, 05:49 PM
  4. Homework
    By kermi3 in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2001, 04:16 PM
  5. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 02:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21