#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <ctype.h>
int main()
{
char s[10];
double t = 0.0, x;
while(fscanf(stdin,"%s",s) == 1)
{
if (isdigit(s[0]))
t += sin(atoi(s));
}
fprintf(stdout,"%f\n",t);
return 0;
}
|
main, what is the
type of the expression 2*t?
main, what is the
type of the expression &t?
main, what is the
type of the expression s[0]?
main, what is the
type of the expression s?
main, what is the
type of the expression atoi(s)? Hint:
The atoi function is defined in the standard
C library stdlib.h. Do a man atoi
to help answser this question.
isdigit. Do a
man isdigit to tell me: a) which .h file do
you have to include for isdigit? and b) what
does the function isdigit do?
fscanf("%i %i %i",&a,&b,&c);
returns the value 2. What does that tell you?
char str[6];is set to contain the the value
"the".
write the contents of the array str.