Harbingers of Chaos ver. 2

Randomly Random


    C revision/clean up

    Share
    avatar
    Shark Sharkley
    Admin

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

    C revision/clean up

    Post by Shark Sharkley on 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]


    _________________


    avatar
    MrGoose

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

    Re: C revision/clean up

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

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

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

    Re: C revision/clean up

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

    lolz its for my C Programming class


    _________________



    Sponsored content

    Re: C revision/clean up

    Post by Sponsored content


      Current date/time is Sat Dec 15, 2018 8:00 pm