Skip to content

Added more source code files #26

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 3 commits into from
Mar 7, 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
22 changes: 22 additions & 0 deletions C_Begineer/09-CBegineer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

char name[14] = "Bucky Roberts";
printf("My name is %s \n", name);

//changin 3rd element [Array index start from 0]
name[2] = 'z';
printf("My name is %s \n", name);

char food[] = "tuna";
printf("The best food is %s \n", food);

//changing value of food by copying new value usinf strcpy function
strcpy(food, "bacon");
printf("The best food is %s \n", food);

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

int main() {

char firstName[20];
char crush[20];
int numberOfBabies;

//Using scanf to get user Input
printf("What is your name?\n");
scanf("%s", &firstName);

printf("Who you gonna get marry to? \n");
scanf("%s", &crush);

printf("How many kids will you have? \n");
scanf("%d", &numberOfBabies);

printf("%s and %s are in love and have %d babies \n", firstName, crush, numberOfBabies);
return 0;
}
27 changes: 27 additions & 0 deletions C_Begineer/12-CBegineer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

//Math operators
// + Addition
// - Subtraction
// / Divide
// * Multiplication
// % Modulos or remainder

int a = 86;
int b = 21;

//Integer result (INT)
printf("%d \n", a/b);

float c = 86.0;
float d = 21.0;

//float resukt (FLOAT)
printf("%f \n", c/d);

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

int main() {

//Math operators
// + Addition
// - Subtraction
// / Divide
// * Multiplication
// % Modulos or remainder

int a = 86;
int b = 21;

//Integer result (INT)
printf("%d \n", a/b);

float c = 86.0;
float d = 21.0;

//float resukt (FLOAT)
printf("%f \n", c/d);

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

int main() {

// Order of math operation
// First inside brackets
// Then * or /
// Then + or -

int a = 4 + 2 * 6;

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

a = (4 + 2) * 6;
printf("Result: %d \n", a);

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

int main() {

// Order of math operation
// First inside brackets
// Then * or /
// Then + or -

int a = 4 + 2 * 6;

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

a = (4 + 2) * 6;
printf("Result: %d \n", a);

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

int main() {

float age1, age2, age3, average;
age1 = age2 = 4;

printf("Enter your age? \n");
scanf("%f", &age3);

average = (age1 + age2 + age3) / 3;
printf("The average of group is %f \n", average);
return 0;
}
29 changes: 29 additions & 0 deletions C_Begineer/15-CBegineer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
#include <stdlib.h>

int main() {
int pageViews = 0;

pageViews = pageViews + 1;
printf("Pageviews: %d \n", pageViews);

pageViews = pageViews + 1;
printf("Pageviews: %d \n", pageViews);

pageViews = pageViews + 1;
printf("Pageviews: %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);

}

14 changes: 14 additions & 0 deletions C_Begineer/16-CBegineer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#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;
}

21 changes: 21 additions & 0 deletions C_Begineer/17-CBegineer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#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;
}