Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

"EXPRESSION IN FUNCTION MAIN"a bug thtz making me to go mad?

see iam a new to C language but not that foolish who can't even copy from the book, every time i tried to run a program written by me turbo c++ gives me an error "EXPRESSION IN FUNCTION MAIN".ven when i copy a program from the book it gives me the same error

herz the program

main()

{

int radius;

float area;

float pi=3.14;

printf("enter the value of radius",%d);

scanf("%d",&radius);

area=pi*radius*radius;

printf("area of circle is \f%",area);

}

this a pure copy from the book but when i tried to run it it gave me that error. folks plz helpme

4 Answers

Relevance
  • cja
    Lv 7
    1 decade ago
    Favorite Answer

    Either you copied it incorrectly, or the book is wrong. Here is the repaired version:

    #include <stdio.h>

    int main(int argc, char *argv[]) {

    int radius;

    float area;

    float pi=3.14;

    printf("enter the value of radius: ");

    scanf("%d",&radius);

    area=pi*radius*radius;

    printf("area of circle is %f\n",area);

    return 0;

    }

    Look carefully and you'll find the differences. They're minor, for sure, but compilers and computers are dumb, relying on you to be the smart one.

    Adding the return type and arguments to main is incidental, but the right thing to do.

  • Anonymous
    1 decade ago

    1>First of all you must include the header file stdio.h.

    2>In 6th line i.e. printf("enter the value of radius",%d); change line to:printf("enter the value of radius");(%d has been used in wrong way).

    3>Since your program is starting with main therefore add return (0); in last line.And now the complete program is:

    #include <stdio.h>

    main()

    {

    int radius;

    float area;

    float pi=3.14;

    printf("enter the value of radius");

    scanf("%d",&radius);

    area=pi*radius*radius;

    printf("area of circle is \f%",area);

    return (0);

    }

  • 1 decade ago

    Well for the work.You are commiting small mistakes.The above program is wrongly coded.The correct code is

    #include<stdio.h>

    #include<conio.h>

    main()

    {

    int radius;

    float area;

    float pi=3.14;

    printf("enter the value of radius....\n");

    scanf("%d",&radius);

    area=(float)(pi*radius*radius);

    printf("area of circle is ....%f",area);

    }

    Now type it you will get correct output.

    And you have a doubt why i use area=(float).....

    This is a special technique that is known as "TYPE CONVERSION".

    Bye

    Source(s): If u have any doubts type your doubt in www.whereweget.wordpress.com
  • 1 decade ago

    everything is correct but in printf("enter the value of radius",%d); shud be like printf("enter the value of radius"); try running this code. Before include <stdio.h>. thats it.

Still have questions? Get your answers by asking now.