Skip to content
Open
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
2 changes: 2 additions & 0 deletions C/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gitignore
executables/
2 changes: 1 addition & 1 deletion C/05_cProgramming.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ int main() {
printf("Bucky is cool \a");
return 0;

}
}
11 changes: 1 addition & 10 deletions C/10_cProgramming.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// 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.
Expand All @@ -18,6 +9,6 @@
int main()
{
int girlsAge = (AGE / 2) + 7;
printf("%s can date girls age %d or older.", MYNAME, girlsAge);
printf("%s can date girls age %d or older.\n", MYNAME, girlsAge);
return 0;
}
2 changes: 1 addition & 1 deletion C/11_cProgramming.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main()
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);
printf("%s and %s are in love and will have %d babies\n", firstName, crush, numberOfBabies);

return 0;
}
2 changes: 1 addition & 1 deletion C/14_cProgramming.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main()
scanf("%f", &age3);

average = (age1 + age2 + age3) / 3;
printf("\n The average age of the group is %f", average);
printf("\n The average age of the group is %f\n", average);

return 0;
}
15 changes: 15 additions & 0 deletions C/16_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
float avgProfit;
int priceOfPumpkin = 10;
int sales = 59;
int daysWorked = 7;

avgProfit = ( (float)priceOfPumpkin * (float)sales) / (float)daysWorked;
printf("Average daily profit: %.2f\n", avgProfit);

return 0;
}
20 changes: 20 additions & 0 deletions C/17_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
int age;

printf("How old are you? \n");
scanf("%d", &age);

if(age >= 18) {
printf("You may enter this website!\n");
}

if(age <18) {
printf("Nothing to see here!\n");
}

return 0;
}
31 changes: 31 additions & 0 deletions C/18_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
int age;
char gender;

printf("How old are you? \n");
scanf(" %d", &age);

printf("What is your gender? (m/f) \n");
scanf(" %c", &gender);

if(age >= 18) {
printf("You may enter this website, ");

if(gender == 'm') {
printf("dude!\n");
}
if (gender == 'f') {
printf("m'lady!\n");
}
}

if(age <18) {
printf("Nothing to see here!\n");
}

return 0;
}
28 changes: 28 additions & 0 deletions C/19_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
int age;
char gender;

printf("How old are you? \n");
scanf(" %d", &age);

printf("What is your gender? (m/f) \n");
scanf(" %c", &gender);

if(age >= 18) {
printf("You may enter this website, ");

if(gender == 'm') {
printf("dude!\n");
}else{
printf("m'lady!\n");
}
}else{
printf("Nothing to see here!\n");
}

return 0;
}
29 changes: 29 additions & 0 deletions C/20_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
float grade1;
float grade2;
float grade3;

printf("Enter your 3 test grades: \n");
scanf(" %f", &grade1);
scanf(" %f", &grade2);
scanf(" %f", &grade3);

float avg = (grade1 + grade2 + grade3) / 3;
printf("Average: %.2f \n", avg);

if(avg >= 90) {
printf("Grade: A\n");
}else if(avg >= 80) {
printf("Grade: B\n");
}else if(avg >= 70) {
printf("Grade: C\n");
}else{
printf("You are dumb!\n");
}

return 0;
}
20 changes: 20 additions & 0 deletions C/21_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
int hoursStudied = 60; // 10 or more
int kidsBeatUp = 0; // 0 kids

// int hoursStudied = 2;
// int kidsBeatUp = 9;

// int hoursStudied = 80;
// int kidsBeatUp = 12;

if( (hoursStudied>=10) && (kidsBeatUp==0) ) {
printf("You are a good student\n");
}

return 0;
}
18 changes: 18 additions & 0 deletions C/22_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
char answer;

printf("Do you like bagels? (y/n) \n");
scanf(" %c", &answer);

if( (5 < 90) || (10 == 10) ) {
printf("Good job, you didn't mess anything up\n");
}else{
printf("Keyboard much?\n");
}

return 0;
}
12 changes: 12 additions & 0 deletions C/23_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
int friends = 87;
// int friends = 1;

printf("I have %d friend%s\n", friends, (friends != 1) ? "s" : "");

return 0;
}
25 changes: 25 additions & 0 deletions C/24_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
int a = 5, b = 10, answer = 0;
printf("The first a = %d \n", a);

// add one to a immediately
answer = ++a * b;

printf("Answer: %d \n", answer);
printf("The second a = %d \n", a);

a = 5, b = 10, answer = 0;
printf("\nThe reset a = %d \n", a);

answer = a++ * b;
// add one after running code

printf("Answer: %d \n", answer);
printf("The last a = %d \n", a);

return 0;
}
16 changes: 16 additions & 0 deletions C/25_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
int day = 1;
float amount = .01;

while(day <= 31) {
printf("Day: %d \t Amount: $%.2f \n", day, amount);
amount *= 2;
day++;
}

return 0;
}
24 changes: 24 additions & 0 deletions C/26_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
float grade = 0;
float scoreEntered = 0;
float numberOfTests = 0;
float average = 0;

printf("Press 0 when complete. \n\n");

do{
printf("Tests: %.0f Average: %.2f \n", numberOfTests, average);
printf("\nEnter test score: \n");
scanf(" %f", &scoreEntered);
grade += scoreEntered;
numberOfTests++;
average = grade / numberOfTests;
}
while(scoreEntered != 0);

return 0;
}
20 changes: 20 additions & 0 deletions C/27_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>



int main()
{
int bacon;

for(bacon; bacon <=10; bacon++) {
// for(bacon; bacon <=100; bacon+=8) {

printf("Bacon is %d \n", bacon);
}

return 0;
}
24 changes: 24 additions & 0 deletions C/28_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>



int main()
{
int columns;
int rows;

for(rows = 1; rows <= 4; rows++) {

for(columns = 1; columns <= 4; columns++) {
printf("%d ", columns);
}

printf("\n");
}

return 0;
}
28 changes: 28 additions & 0 deletions C/29_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>



int main()
{
int a;
int howMany;
int maxAmount = 10;

printf("How many times do you want this loop to loop? (up to 10)\n");
scanf(" %d", & howMany);

for(a =1; a <= maxAmount; a++) {

printf("%d\n", a);

if(a == howMany) {
break;
}

}
return 0;
}
25 changes: 25 additions & 0 deletions C/30_cProgramming.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>



int main()
{
int num = 1;

do{
if(num == 6 || num == 8) {
num++;
continue;
}

printf("%d is available \n", num);
num++;

}while(num <= 10);

return 0;
}
Loading