forked from buckyroberts/Source-Code-from-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request buckyroberts#48 from Nodetails/master
Tuts 11 & 12
- Loading branch information
Showing
6 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// This is in a header file. Go to "File" --> New --> | ||
// Empty File, call it "Buckysroom.h" | ||
|
||
// Done right, a headers folder should show up on CodeBlocks | ||
|
||
# define MYNAME "Bucky" | ||
# define AGE 28 | ||
|
||
////////////////////////////////////////// | ||
|
||
|
||
// Shows how values defined in header file work. | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "Buckysinfo.h" | ||
|
||
int main() | ||
{ | ||
int girlsAge = (AGE / 2) + 7; | ||
printf("%s can date girls age %d or older.", MYNAME, girlsAge); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
// using scanf stuff | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
|
||
int main() | ||
{ | ||
|
||
char firstName[20]; | ||
char crush[20]; | ||
int numberOfBabies; | ||
|
||
printf("What is your name? \n"); | ||
scanf("%s", firstName); | ||
|
||
printf("Who are you going to marry? \n"); | ||
scanf("%s", crush); | ||
|
||
printf("How many kids will you have? \n"); | ||
scanf("%d", &numberOfBabies); | ||
|
||
printf("%s and %s are in love and will have %d babies", firstName, crush, numberOfBabies); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
// Math in statements, floats. Code modified a bit | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
|
||
int main() | ||
{ | ||
|
||
int weight = 595; | ||
printf("I weigh %d lbs. \n", weight + 12); | ||
printf("I weigh %d lbs. \n", weight / 12); | ||
printf("I weigh %d lbs. \n\n", weight % 12); | ||
|
||
int a = 86; | ||
int b = 21; | ||
|
||
printf("%d \n", a/b); | ||
|
||
float c = 86.0; | ||
float d = 21.0; | ||
printf("%f \n", c/d); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
// Order of operations | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
|
||
int main() | ||
{ | ||
|
||
int a = 4 + 2 * 6; | ||
printf("Result: %d \n", a); | ||
a = (4 + 2) * 6; | ||
printf("Result: %d \n", a); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
// Moar math. | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
|
||
int main() | ||
{ | ||
|
||
float age1, age2, age3, average; | ||
age1 = age2 = 4.0; | ||
|
||
printf("Enter your age\n"); | ||
scanf("%f", &age3); | ||
|
||
average = (age1 + age2 + age3) / 3; | ||
printf("\n The average age of the group is %f", average); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
// Even moar math. | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
|
||
int main() | ||
{ | ||
|
||
int pageViews = 0; | ||
|
||
pageViews = pageViews + 1; | ||
printf("Page views: %d \n", pageViews); | ||
pageViews = pageViews + 1; | ||
printf("Page views: %d \n", pageViews); | ||
pageViews = pageViews + 1; | ||
printf("Page views: %d \n", pageViews); | ||
|
||
float balance = 1000.00; | ||
|
||
balance *= 1.1; | ||
printf("Balance: %f \n", balance); | ||
balance *= 1.1; | ||
printf("Balance: %f \n", balance); | ||
balance *= 1.1; | ||
printf("Balance: %f \n", balance); | ||
|
||
return 0; | ||
} |