Reads a real number and outputs its inverse. If 0 is read, writes a warning mess
ID: 3883687 • Letter: R
Question
Reads a real number and outputs its inverse. If 0 is read, writes a warning message and quit.Sample program:
Reads a real number, x, and outputs its sine, i.e. sin x. You need to use math.h and the -lm compile option.Sample program:
Sample run (note the -lm option):
I like to do each problem as a seperate nano file, thanks.
#include <stdio.h> int main() { float a; printf("Enter a number = ");scanf("%f", &a); if (a==0.0) printf("You entered 0. "); else printf("You entered a number other than 0. "); return 0; }
Explanation / Answer
prog2.c
#include<stdio.h>
#include<math.h>
int main()
{
float a;
printf(" Enter a real number : "), scanf("%f", &a);
printf(" x = %f sin(x) = %f ", a, sin(a));
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.