#I have no idea whats wrong with this

6 messages · Page 1 of 1 (latest)

covert hinge
#
#include <stdio.h>
#define PI 3.14f

int main(void){

 double perimiter;
 double area;
 double radius;
 int choice;
 printf("\nArea or perimiter caculator\n");
 printf("Select area(1) or perimiter(2): ");
 scanf("%d", &choice);

 if(choice <2){
  printf("Radius: ");
  scanf("%f", &radius);
  double area = radius * radius * PI;
  printf("Area %f\n", area);
 }
 else{
  printf("Radius: ");
  scanf("%f", &radius);
  double perimiter = 2 * PI * radius;
  printf("Perimiter %f\n", perimiter);
 }

}

ive tried everything I know, any help is greatly appreciated
no matter what perimiter and area always = 0.0

random vigilBOT
#

ℹ️ @covert hinge this post has been closed. Feel free to reopen it if you have any further questions.

latent juniper
#

hello, i'm not sure you'll see this however, the problem seemed to have been your data type.

#

double takes %lf and float take %f. after adjusting the data type your code should run perfectly.

young coral
#

btw, you spelled "perimeter" wrong

unkempt hedge
#

@robust plank is this expected bobbins behavior?