-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_functionality.c
More file actions
89 lines (59 loc) · 1.81 KB
/
basic_functionality.c
File metadata and controls
89 lines (59 loc) · 1.81 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//==================================================================
//File: basic_functionality.c
//Author: James Anthony Ortiz
//Description: This program explores the
//basic functionalities of C99.
//gcc -std=c99 -g -o basic_functionality basic_functionality.c
//==================================================================
//STL Libraries for functionality support:
#include <stdio.h>
#include <math.h>
//------------------------------------------------
//Function: add_together()
//Description: adds two numbers
//together.
//parameters:
//x: integer
//y: integer
//------------------------------------------------
int add_together(int x, int y)
{
int result = x + y;
return result;
}//end add_together()
//Example of a datastruct
//and typedef
typedef struct{
float x;
float y;
}point;
//Initialization of struct with values:
int main()
{
int a;
//50 + 55 = 105
a = add_together(50, 55);
int num_of_helloworlds;
printf("Enough of that, now, let's enter a number to generate n Hello Worlds:\n");
scanf("%d", &num_of_helloworlds);
while(num_of_helloworlds > 0)
{
//Print statement:
printf("Hello, World!\n");
//Decrement variable of counter:
num_of_helloworlds--;
}//end while
//Exploring data-type sizes.. (output may differ on computer hardware):
printf("The size of a short is: %lu\n", sizeof(short));
printf("The size of a char is: %lu\n", sizeof(char));
printf("The size of an integer is: %lu\n", sizeof(int));
printf("The size of a float is: %lu\n", sizeof(float));
printf("The size of a double is: %lu\n", sizeof(double));
printf("If we add 50 and 55 together we get: %d\n", a);
point p;
p.x = 0.1;
p.y = 10.0;
float length = sqrt(p.x * p.x + p.y * p.y);
printf("The square root of two random numbers is: %f\n", length);
return 0;
}//end main