Friday, 10 November 2017

Area of Circle

/*this code will work only if radius is integer value */

int main(int argc, char * argv[])
    int radius;
    float area = 0;
    radius = atoi(argv[1]);
    area = 3.14 * (radius * radius);
    return 0;

Output:  AreaCircle  5

/* for float values of radius we need to use atof() instead of atoi() and we have include header file <stdlib.h> */


  1. Replies
    1. "print" treats the % as a special character you need to add, so it can know, that when you type "f", the number (result) that will be printed will be a floating point type, and the ".2" tells your "print" to print only the first 2 digits after the point.


Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...