Skip to content

Commit 781d5e3

Browse files
committed
added few more
1 parent 48bda01 commit 781d5e3

File tree

6 files changed

+127
-0
lines changed

6 files changed

+127
-0
lines changed

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/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)