Skip to content

Commit

Permalink
Merge pull request buckyroberts#48 from Nodetails/master
Browse files Browse the repository at this point in the history
Tuts 11 & 12
  • Loading branch information
buckyroberts committed Nov 16, 2015
2 parents 3c758f5 + f0a20cb commit 2404a71
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
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;
}

0 comments on commit 2404a71

Please sign in to comment.