Question:

A C-Language Problem ...

by  |  earlier

0 LIKES UnLike

I'm especially counting on the help of computer programmers out there.

Please give me a program that can compute the circumference of a circle using the const keyword.

Thank you!

 Tags:

   Report

1 ANSWERS


  1. perhaps i can help. but i need more info than what you just provided.

    Const is only a data type.

    for example

    int a=10; makes a=10.

    but I am allowed define a=12 later in the program. Therefore the value 10 is not hard coded to that memory variable.

    Where as const b=5; sets b as 5. no exceptions.

    Do you just simply want a program to compute the circumference of a circle?

    I think I u/stand your problem a bit though you are not very clear. You need to understand the question properly.

    In case of a circle, the value of (pi) is a contant 3.14 or (22/7) . And your equation for computing the circumference would be 2*pi*r where 'r' is the radius of the circle?

    Hence your program would be this way,

    #include <stdio.h>

    #include <conio.h>

    main()

    {

    clrscr();

    int r;

    const float pi=3.14;

    cout<< "]\n Enter radius  \t : ";

    cin>>r;

    cout<< "\n\n Circumference \t = "<<"2 * pi * "cout<<r<<" is : "<<2*pi*r;

    getch();

    }

    hope this helps. :)

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.