-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlecture3.c
More file actions
41 lines (37 loc) · 757 Bytes
/
Copy pathlecture3.c
File metadata and controls
41 lines (37 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const double PI=3.1415929;
struct _sometag
{
int onefield;
char anotherfield;
float stillanotherfield;
};
double an_example_function(double angle)
{
angle = PI/180.*angle; //convert to radians
return(2.*sin(angle));
}
int main(int argc,char *argv[])
{
int i;
int sum=0;
FILE *fp;
char string_array[7];
struct _sometag a_struct,*pointer;
int a[3];
a_struct.onefield=7;
a_struct.anotherfield='c';
a_struct.stillanotherfield=3.7;
pointer=&a_struct;
if (argc < 2)
{
printf("You did not give me enough information\n");
exit(0);
}
fp=(FILE *)fopen("output.txt","a");
fprintf(fp,"%f\n", an_example_function(atof(argv[1])));
fclose(fp);
return(0);
}