Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operand of * must be a pointer

Tags:

c

This is my script

#include <stdio.h>
#define PI 3.14;

int main(void){
    double hasil, input;
    printf("Enter a positive number : ");
    scanf("%lf",&input);
    hasil = PI * input;
    printf("\nThe result is : %lf",hasil);
    getchar();
    return 0;
}

I get error * must be a pointer? What's it? I mean '*' sign is to multiply number....

like image 405
jeff_ang24 Avatar asked Oct 14 '25 14:10

jeff_ang24


1 Answers

Your PI constant contains a semicolon which will terminate the expression prematurely;

#define PI 3.14;

...will result in the expression;

hasil = 3.14; * input;

It should be defined as only;

#define PI 3.14
like image 140
Joachim Isaksson Avatar answered Oct 17 '25 08:10

Joachim Isaksson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!