Harbingers of Chaos ver. 2

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Harbingers of Chaos ver. 2

Randomly Random


2 posters

    C revision/clean up

    Shark Sharkley
    Shark Sharkley
    Admin


    Posts : 522
    Join date : 2009-06-19
    Age : 33
    Location : Meridian, ID

    C revision/clean up Empty C revision/clean up

    Post by Shark Sharkley Thu Nov 05, 2009 2:25 am

    dont know if anybody knows or remembers C, but i need someone to check if my coding needs clean up or what.

    here's the problem (by the way, we just did our section on the 'while' statement so ya):
    Write a C program to convert Celsius degrees to Fahrenheit. The program should request the starting Celsius value, the number of conversions to be made, and the increment between Celsius values. The display should have appropriate headings and list the Celsius value and the corresponding Fahrenheit value. Use the relationship: Fahrenheit = (9.0/5.0) * Celsius + 32.0

    here's my coding:

    #include stdio.h <------- left the brackets out on purpose, wouldn't show that part

    int main()
    {
         // initialize variables
         int maxcount, counter = 1;
         float celsius, fahrenheit, increment;

         // prompt user for starting celsius
         printf( "Please enter the starting celsius value: " );
         scanf( "%f", &celsius );

         // prompt user or increasing value
         printf( "Please enter the maximum amount to convert to fahrenheit: " );
         scanf( "%d", &maxcount );

         // prompt user for increasing value
         printf( "Please enter amount to increase celsius: " );
         scanf( "%f", &increment );

         // blank line
         printf( "\n" );

         // Heading of Table
         printf( "CELSIUS FAHRENHEIT\n" );
         printf( "------ ----------\n" );

         // while loop
         while( counter <= maxcount )
         {
              if( counter == 1 )
              {
                   fahrenheit = ( 9.0 / 5.0 ) * celsius = 32.0;
                   printf( "%7.1f%13.1f\n", celsius, fahrenheit );
                   counter++;
              }
              else
              {
                   celsius += increment;
                   fahrenheit = ( 9.0 / 5.0 ) * celsius = 32.0;
                   printf( "%7.1f%13.1f\n", celsius, fahrenheit );
                   counter++;
              }
         }

         return 0;
    }

    any help would be appreciated Very Happy, i might have more coding to post too if anybody knows Java or C. otherwise, THANKS FOR NOTHING ASSHOLES :S[wow][/wow]
    MrGoose
    MrGoose


    Posts : 24
    Join date : 2009-10-23
    Age : 34

    C revision/clean up Empty Re: C revision/clean up

    Post by MrGoose Thu Nov 05, 2009 12:13 pm

    I have no idea what tis is for :p
    Shark Sharkley
    Shark Sharkley
    Admin


    Posts : 522
    Join date : 2009-06-19
    Age : 33
    Location : Meridian, ID

    C revision/clean up Empty Re: C revision/clean up

    Post by Shark Sharkley Thu Nov 05, 2009 1:55 pm

    lolz its for my C Programming class

    Sponsored content


    C revision/clean up Empty Re: C revision/clean up

    Post by Sponsored content


      Current date/time is Sun May 12, 2024 11:37 pm