Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Objective-C Basics (Retired) Fundamentals of C Variables

Lewis Davidson
Lewis Davidson
694 Points

Stuck already need help writing radius float in early lesson.

how to write a float variable specific question:

Create a float variable named 'radius' with the value '14.5'. (Do not write the main function).

5 Answers

Stone Preston
Stone Preston
42,016 Points

you create a float variable like so

float variableName = value;

so to create one named radius with a value of 14.5:

float radius = 14.5;
Chris Shaw
Chris Shaw
26,662 Points

Hi Lewis,

If you go back to the variables video Douglass has a float variable on the screen, that is what the challenge is asking for but using the value of 14.5 instead.

Lewis Davidson
Lewis Davidson
694 Points

This is what I put for the code:

#include <stdio.h>

int main()
{

    int days_in_a_week = 7;
    float cm_to_in = 2.54;
    float radius = 14.5;

    char the_w;

    the_w = 'W';

    printf("%d days in a week. \n", days_in_a_week);
    printf("%f cm per in.\n", cm_to_in);
    printf("The %c is a cool hotel\n", the_w);

    return 0;
}
Lewis Davidson
Lewis Davidson
694 Points

conflicting types for 'main' int main() ^ note: previous declaration is here int main(int argc, const char * argv[]) ^ 2 errors generated.

Lewis Davidson
Lewis Davidson
694 Points

thanks all. got it just write that one sample line is all!