chapter3
This commit is contained in:
parent
7522af1dc2
commit
bb35fb2db6
BIN
DeitelC/Chapter3Test/a.out
Normal file
BIN
DeitelC/Chapter3Test/a.out
Normal file
Binary file not shown.
35
DeitelC/Chapter3Test/float.c
Normal file
35
DeitelC/Chapter3Test/float.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
float f = 123.456;
|
||||||
|
printf("%.2f\n", f);
|
||||||
|
|
||||||
|
f = 3.14159;
|
||||||
|
printf("%.3f\n", f); // 3.3 examples
|
||||||
|
|
||||||
|
int x = 1, sum = 0;
|
||||||
|
|
||||||
|
while (x < 11) {
|
||||||
|
sum = x + sum;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
printf("And the sum is: %d\n", sum); // 3.4 and 3.5 examples
|
||||||
|
|
||||||
|
|
||||||
|
printf("Enter int x: \n");
|
||||||
|
scanf("%d", &x);
|
||||||
|
|
||||||
|
int y;
|
||||||
|
printf("Enter int y: \n");
|
||||||
|
scanf("%d", &y);
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
while (y > 0) {
|
||||||
|
i *= x;
|
||||||
|
y--;
|
||||||
|
}
|
||||||
|
printf("Result is: %d\n", i);
|
||||||
|
|
||||||
|
}
|
BIN
DeitelC/Chapter4/a.out
Normal file
BIN
DeitelC/Chapter4/a.out
Normal file
Binary file not shown.
BIN
test/a.out
Normal file
BIN
test/a.out
Normal file
Binary file not shown.
6
test/alert.c
Normal file
6
test/alert.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
printf("Alert!\a");
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user