Problem with sin()

I am using linux and gcc.

This code works as expected.

#include <stdio.h>
#include <math.h>

int main()
{
	float a;

	a=1.1;

	// printing the calculated value
	printf("value in sin is = %.4f\n", sin(1.1));

	return 0;
}

The code below fails to compile with the error undefined reference to sin

#include <stdio.h>
#include <math.h>

int main()
{
	float a;

	a=1.1;

	// printing the calculated value
	printf("value in sin is = %.4f\n", sin(a));

	return 0;
}

I have seen this same issue with the command line version of gcc as well as various IDE’s?

I’ve tried to run this program in OnlineGDB and it is working fine

I have compiled it on a Mac and it worked fine. Under my Linux it will not compile?
I saw the same problem with ubuntu and redhat?
What could I be doing wrong?

This can be an issue with gcc requiring special formatting/syntax to be followed. The program However is correct and hence cannot be debugged. Maybe try reaching out to gcc documentation or ubuntu forums to understand the issue better?