Thread: pseudocode, algorithm and flowwchart

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    24

    pseudocode, algorithm and flowwchart

    hello, can anyone out there in the programming world help me to develope a pseudocode, algorithm and flowchart for this program? Thanks!


    /* This program shows how to change a temperature in
    Fahrenheit to Celsius
    Written by:
    Date:
    */
    #include <stdio.h>

    #define CONVERSION_FACTOR (100.0 / 180.0)

    int main (void)
    {
    /* Local Definitions */
    float cel;
    float fah;

    /* Statements */
    printf("Enter the temperature in Fahrenheit: ");
    scanf("%f", &fah);

    cel = CONVERSION_FACTOR * (fah - 32);

    printf("Fahrenheit temperature is: %5.1f\n", fah);
    printf("Celsius temperature is: %5.1f\n", cel);

    return 0;
    } /* main */

    /* Results:
    Enter the temperature in Fahrenheit: 98.6
    Fahrenheit temperature is: 98.6
    Celsius temperature is: 37.0

    */

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Code:
    #include<stdio.h>
    #define CONVERSION_FACTOR (100.0 / 180.0) 
    double convert (double);
    
    int main (void) 
    { 
    /* Local Definitions */ 
    	double cel; 
    	double fah; 
    
    	/* Statements */ 
    	printf("Enter the temperature in Fahrenheit: "); 
    	scanf("%lf", &fah); 
    
    	/* call function */
    	cel = convert(fah);
    	printf("Fahrenheit temperature is: %5.1lf\n", fah); 
    	printf("Celsius temperature is: %5.1lf\n", cel); 
    
    	return 0; 
    } /* main */
    
    double convert(double fah)
    {
    
    	return CONVERSION_FACTOR * (fah - 32); 
    }
    Although by no means a good looking function, still this is what you want to do. In 'C' the main focus is the breaking the code up into functions that are cohesive, and can be re-used.

    Ask yourself what are the 'inputs / processes / outputs' of each function.

    Main:
    PROMPT for temperature in Fahrenheit
    CALL conversion function
    DISPLAY result
    END

    Converstion:
    CALCULATE conversion from Fahrenheit to Celcius
    RETURN result
    Last edited by Troll_King; 10-31-2001 at 01:10 AM.

Popular pages Recent additions subscribe to a feed