Skip to content

Tuts 11 & 12 #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions C/10_cProgramming.c
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;
}
27 changes: 27 additions & 0 deletions C/11_cProgramming.c
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;
}
26 changes: 26 additions & 0 deletions C/12_cProgramming.c
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;
}
17 changes: 17 additions & 0 deletions C/13_cProgramming.c
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;
}
21 changes: 21 additions & 0 deletions C/14_cProgramming.c
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;
}
30 changes: 30 additions & 0 deletions C/15_cProgramming.c
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;
}