I have just started off with Unix (TCSH) although I have a pretty sound background with C-programming. Kindly convey any error in foll script.
#include<stdio.h>
#include<math.h> #define PI 3.142857
main ()
{
float r, A;
printf("Enter the value of radius: ");
scanf(" %f ",&r);
A = ((PI/4)*r*r);
printf("Area of circle is %f", A);
}
I can compile it with gcc but when I run it in terminal, it returns nothing, guess it goes into a loop.
include<stdio.h>
include<math.h>
define PI 3.142857
main ()
{
float r, A;
printf("Enter the value of radius: ");
scanf(" %f ",&r);
A = (PI/4)*(r*r);
printf("Area of circle is %f", A);
}
#include<stdio.h>
#include<math.h>
#define PI 3.142857
int main(int argc,char **argv)
{
float r, A;
printf("Enter the value of radius: ");
scanf("%f",&r);
A = ((PI/4)*r*r);
printf("Area of circle is %f", A);
return 0;
}
sscanf would other wise be looking for a space before the number hence why if you just type a number it appears to hang because you have not provided the space.