Skip to content

Commit 046d98a

Browse files
committed
Merge pull request #26 from nak1b/master
Added more source code files
2 parents 2d28bb4 + 781d5e3 commit 046d98a

File tree

10 files changed

+219
-0
lines changed

10 files changed

+219
-0
lines changed

C_Begineer/09-CBegineer.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
int main() {
6+
7+
char name[14] = "Bucky Roberts";
8+
printf("My name is %s \n", name);
9+
10+
//changin 3rd element [Array index start from 0]
11+
name[2] = 'z';
12+
printf("My name is %s \n", name);
13+
14+
char food[] = "tuna";
15+
printf("The best food is %s \n", food);
16+
17+
//changing value of food by copying new value usinf strcpy function
18+
strcpy(food, "bacon");
19+
printf("The best food is %s \n", food);
20+
21+
return 0;
22+
}

C_Begineer/11-CBegineer.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
int main() {
6+
7+
char firstName[20];
8+
char crush[20];
9+
int numberOfBabies;
10+
11+
//Using scanf to get user Input
12+
printf("What is your name?\n");
13+
scanf("%s", &firstName);
14+
15+
printf("Who you gonna get marry to? \n");
16+
scanf("%s", &crush);
17+
18+
printf("How many kids will you have? \n");
19+
scanf("%d", &numberOfBabies);
20+
21+
printf("%s and %s are in love and have %d babies \n", firstName, crush, numberOfBabies);
22+
return 0;
23+
}

C_Begineer/12-CBegineer.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
int main() {
6+
7+
//Math operators
8+
// + Addition
9+
// - Subtraction
10+
// / Divide
11+
// * Multiplication
12+
// % Modulos or remainder
13+
14+
int a = 86;
15+
int b = 21;
16+
17+
//Integer result (INT)
18+
printf("%d \n", a/b);
19+
20+
float c = 86.0;
21+
float d = 21.0;
22+
23+
//float resukt (FLOAT)
24+
printf("%f \n", c/d);
25+
26+
return 0;
27+
}

C_Begineer/12.CBegineer.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
int main() {
6+
7+
//Math operators
8+
// + Addition
9+
// - Subtraction
10+
// / Divide
11+
// * Multiplication
12+
// % Modulos or remainder
13+
14+
int a = 86;
15+
int b = 21;
16+
17+
//Integer result (INT)
18+
printf("%d \n", a/b);
19+
20+
float c = 86.0;
21+
float d = 21.0;
22+
23+
//float resukt (FLOAT)
24+
printf("%f \n", c/d);
25+
26+
return 0;
27+
}

C_Begineer/13-CBegineer.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
int main() {
6+
7+
// Order of math operation
8+
// First inside brackets
9+
// Then * or /
10+
// Then + or -
11+
12+
int a = 4 + 2 * 6;
13+
14+
printf("Result: %d \n", a);
15+
16+
a = (4 + 2) * 6;
17+
printf("Result: %d \n", a);
18+
19+
return 0;
20+
}

C_Begineer/13.CBegineer.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
int main() {
6+
7+
// Order of math operation
8+
// First inside brackets
9+
// Then * or /
10+
// Then + or -
11+
12+
int a = 4 + 2 * 6;
13+
14+
printf("Result: %d \n", a);
15+
16+
a = (4 + 2) * 6;
17+
printf("Result: %d \n", a);
18+
19+
return 0;
20+
}

C_Begineer/14-CBegineer.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
int main() {
6+
7+
float age1, age2, age3, average;
8+
age1 = age2 = 4;
9+
10+
printf("Enter your age? \n");
11+
scanf("%f", &age3);
12+
13+
average = (age1 + age2 + age3) / 3;
14+
printf("The average of group is %f \n", average);
15+
return 0;
16+
}

C_Begineer/15-CBegineer.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main() {
5+
int pageViews = 0;
6+
7+
pageViews = pageViews + 1;
8+
printf("Pageviews: %d \n", pageViews);
9+
10+
pageViews = pageViews + 1;
11+
printf("Pageviews: %d \n", pageViews);
12+
13+
pageViews = pageViews + 1;
14+
printf("Pageviews: %d \n", pageViews);
15+
16+
17+
float balance = 1000.00;
18+
19+
balance *= 1.1;
20+
printf("Balance: %f \n", balance);
21+
22+
balance *= 1.1;
23+
printf("Balance: %f \n", balance);
24+
25+
balance *= 1.1;
26+
printf("Balance: %f \n", balance);
27+
28+
}
29+

C_Begineer/16-CBegineer.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main() {
5+
float avgProfit;
6+
int priceOfPumpkin = 10;
7+
int sales = 59;
8+
int daysWorked = 7;
9+
10+
avgProfit = ((float)priceOfPumpkin * (float)sales) / (float)daysWorked;
11+
printf("Average daily profit: $%.2f \n", avgProfit);
12+
return 0;
13+
}
14+

C_Begineer/17-CBegineer.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main() {
5+
6+
int age;
7+
8+
printf("How old are you? \n");
9+
scanf("%d", &age);
10+
11+
if(age >= 18){
12+
printf("You may enter this website \n");
13+
}
14+
15+
if(age < 18){
16+
printf("Nothing to see here! \n");
17+
}
18+
19+
return 0;
20+
}
21+

0 commit comments

Comments
 (0)