Skip to content

Commit 887e24b

Browse files
committedOct 11, 2017
organizacion de los ejercicios basicos
1 parent 2e14295 commit 887e24b

File tree

6 files changed

+170
-0
lines changed

6 files changed

+170
-0
lines changed
 

‎basic/.gitignore

Whitespace-only changes.

‎basic/1.-sum.c

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <stdio.h>
2+
3+
4+
void main(){
5+
int number_1, number_2;
6+
int sum;
7+
8+
/*set the values*/
9+
printf("put de first number\n");
10+
scanf("%d", &number_1);
11+
printf("put de second number\n");
12+
scanf("%d", &number_2);
13+
14+
//proces sum
15+
sum = number_1 + number_2;
16+
17+
printf("the sum is %d\n", sum);
18+
19+
20+
}

‎basic/2.-aritmethic.c

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <stdio.h>
2+
/*
3+
*BASIC CALCULATOR(aritmethic)
4+
*
5+
*
6+
*/
7+
8+
void main(){
9+
int number_1, number_2;
10+
int sum, mult, mod, diff;
11+
float div;
12+
13+
14+
/*set the values*/
15+
printf("put de first number\n");
16+
scanf("%d", &number_1);
17+
printf("put de second number\n");
18+
scanf("%d", &number_2);
19+
20+
//proces
21+
22+
sum = number_1 + number_2;
23+
div = (float)number_1 / number_2;
24+
mod = number_1 % number_2;
25+
mult = number_1 * number_2;
26+
diff = number_1 - number_2;
27+
28+
printf("--------------------------------------------------\n"
29+
"--------------------------------------------------\n");
30+
31+
32+
//print operations
33+
printf("the sum of number_1 and number_2 = %d \n", sum);
34+
printf("difference of number_1 and number_2 = %d \n", diff);
35+
printf("product of number_1 and number_2 = %d \n", mult);
36+
printf("quotient of number_1 and number_2 = %f \n", div);
37+
printf("modulus of number_1 and number_2 = %d", mod);
38+
39+
40+
}

‎basic/3.-perimeter.c

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <stdio.h>
2+
int its_a_rectangle(int w, int h);
3+
4+
void main(){
5+
int i, j;/*counters*/
6+
int width, heigth;
7+
int perimeter;
8+
9+
/*set the values*/
10+
printf("put de width :");
11+
scanf("%d", &width);
12+
printf("put de heigth :");
13+
scanf("%d", &heigth);
14+
15+
16+
if(its_a_rectangle(width, heigth) == 1){
17+
perimeter = 2 * (width + heigth);
18+
}
19+
else{
20+
printf("its a square\n");
21+
return;
22+
}
23+
//proces sum
24+
25+
26+
printf("------------------------------\n\n");
27+
for (i = 0; i < heigth; ++i)
28+
{
29+
for (j = 0; j < width; j++)
30+
{
31+
printf(" * ");
32+
}
33+
printf("\n");
34+
}
35+
36+
printf("\n\nThe perimeter is %d\n", perimeter);
37+
38+
}
39+
40+
int its_a_rectangle(int w, int h){
41+
if( w != h) return 1;
42+
}

‎basic/4.-area.c

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <stdio.h>
2+
int its_a_rectangle(int w, int h);
3+
4+
void main(){
5+
int i, j;/*counters*/
6+
int width, heigth;
7+
int area;
8+
9+
/*set the values*/
10+
printf("put de width :");
11+
scanf("%d", &width);
12+
printf("put de heigth :");
13+
scanf("%d", &heigth);
14+
15+
16+
if(its_a_rectangle(width, heigth) == 1){
17+
area = width * heigth;
18+
}
19+
else{
20+
printf("its a square\n");
21+
return;
22+
}
23+
//proces sum
24+
25+
26+
printf("------------------------------\n\n");
27+
for (i = 0; i < heigth; ++i)
28+
{
29+
for (j = 0; j < width; j++)
30+
{
31+
printf(" * ");
32+
}
33+
printf("\n");
34+
}
35+
36+
printf("\n\nThe area is %d\n", area);
37+
38+
39+
}
40+
41+
int its_a_rectangle(int w, int h){
42+
if( w != h) return 1;
43+
}
44+

‎basic/5.-circle.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdio.h>
2+
#define PI 3.1416
3+
4+
5+
void main(){
6+
7+
float circumference, diameter, area, radius;;
8+
9+
/*set the values*/
10+
printf("set the radius :");
11+
scanf("%f", &radius);
12+
13+
/*calculate*/
14+
area = PI * (radius * radius);
15+
circumference = 2 * PI* radius;
16+
diameter = 2 * radius;
17+
18+
//show results
19+
printf("\n\nThe area is %.2f\n", area);
20+
printf("\n\nThe circunference is %.2f\n", circumference);
21+
printf("\n\nThe diameter is %.2f\n", diameter);
22+
23+
24+
}

0 commit comments

Comments
 (0)