Pointer Programming in C


Write a program to find the area of a Circle where area is equal to PI*Radius2. The standard value of PI is 3.144. Use pointer variable

4 comments:

  1. #include
    #include
    #define PI 3.144
    int *funcx(int);
    int main()
    {
    int r, ptr;
    int (*pFn)(int);
    pFn=funcx;
    printf("\n Enter value for radius: ");
    scanf("%d",&r);
    ptr=(*pFn)(r);
    printf("\n Area of a circle is %f",((float)ptr));

    getch();
    return 0;

    }

    int *funcx(int radius)
    {
    int area;
    area=PI*radius*radius;
    return (area);


    }

    ReplyDelete
  2. #include
    #include
    int *find(int);
    int main()
    {
    int r, n;
    int (*w)(int);
    w=find;
    printf("\n Enter value for radius: ");
    scanf("%d",&r);
    n=(*w)(r);
    printf("\n Area of a circle is %f",((float)n));
    getch();
    return 0;
    }
    int *find(int radius)
    {
    int area;
    area=3.1416*radius*radius;
    return (area);
    }

    ReplyDelete
  3. #define PI 3.144
    int *funcx(int);
    int main()
    {
    int r, ptr;
    int (*pFn)(int);
    pFn=funcx;
    printf("\n Enter value for radius: ");
    scanf("%d",&r);
    ptr=(*pFn)(r);
    printf("\n Area of a circle is %f",((float)ptr));

    getch();
    return 0;
    }

    int *funcx(int radius)
    {
    int area;
    area=PI*radius*radius;
    return (area);


    }

    ReplyDelete
  4. #include
    float circ(float r,float pt)
    {
    float sum=0.0;
    sum=pt * (r*r);
    return sum;
    }
    main()
    {
    float r,*pt,p=3.1413;
    printf("Enter the value of r in radius : ");
    scanf("%f",&r);
    pt=&p;
    printf("\nThe area of circle :%f\n",circ(r,*pt));
    }

    ReplyDelete