diff --git a/DeitelC/1to10Sum.c b/DeitelC/Chapter3/1to10Sum.c similarity index 100% rename from DeitelC/1to10Sum.c rename to DeitelC/Chapter3/1to10Sum.c diff --git a/DeitelC/3over10factoriel.c b/DeitelC/Chapter3/3over10factoriel.c similarity index 100% rename from DeitelC/3over10factoriel.c rename to DeitelC/Chapter3/3over10factoriel.c diff --git a/DeitelC/ArmstrongNumbers.c b/DeitelC/Chapter3/ArmstrongNumbers.c similarity index 100% rename from DeitelC/ArmstrongNumbers.c rename to DeitelC/Chapter3/ArmstrongNumbers.c diff --git a/DeitelC/BinaryToDecimal.c b/DeitelC/Chapter3/BinaryToDecimal.c similarity index 100% rename from DeitelC/BinaryToDecimal.c rename to DeitelC/Chapter3/BinaryToDecimal.c diff --git a/DeitelC/BonusInstructor.c b/DeitelC/Chapter3/BonusInstructor.c similarity index 100% rename from DeitelC/BonusInstructor.c rename to DeitelC/Chapter3/BonusInstructor.c diff --git a/DeitelC/Chapter3/CheckConstantEOverX.c b/DeitelC/Chapter3/CheckConstantEOverX.c new file mode 100644 index 0000000..eb45894 --- /dev/null +++ b/DeitelC/Chapter3/CheckConstantEOverX.c @@ -0,0 +1,30 @@ +#include + +double powerFun(double base, int exponent) { + double result = 1.0; + for (int i = 0; i < exponent; i++) { + result *= base; + } + return result; +} + +int main(void) { + int userData; + printf("Please Enter x (in E^x): "); + scanf("%d", &userData); + + double constant = 2.0; // Initialize constant as a double + double counter = 1.0; // Initialize counter to 1.0 + double data = 1.0; // Initialize data to 1.0 + + for (int i = 1; i <= userData; i++) { + data *= constant; // Update data by multiplying with constant + double term = powerFun(userData, i) / data; // Calculate the term for the current iteration + counter += term; // Add the term to the counter + printf("counter: %f\n", counter); + } + + printf("e^%d = %f\n", userData, counter); + + return 0; +} diff --git a/DeitelC/CheckerboardPattern.c b/DeitelC/Chapter3/CheckerboardPattern.c similarity index 100% rename from DeitelC/CheckerboardPattern.c rename to DeitelC/Chapter3/CheckerboardPattern.c diff --git a/DeitelC/Circle.c b/DeitelC/Chapter3/Circle.c similarity index 100% rename from DeitelC/Circle.c rename to DeitelC/Chapter3/Circle.c diff --git a/DeitelC/ClassAvarage.c b/DeitelC/Chapter3/ClassAvarage.c similarity index 100% rename from DeitelC/ClassAvarage.c rename to DeitelC/Chapter3/ClassAvarage.c diff --git a/DeitelC/ConditionalExpression.c b/DeitelC/Chapter3/ConditionalExpression.c similarity index 100% rename from DeitelC/ConditionalExpression.c rename to DeitelC/Chapter3/ConditionalExpression.c diff --git a/DeitelC/Chapter3/ConstantE.c b/DeitelC/Chapter3/ConstantE.c new file mode 100644 index 0000000..3b3e53c --- /dev/null +++ b/DeitelC/Chapter3/ConstantE.c @@ -0,0 +1,17 @@ +#include + +int main(void) { + float constant = 2; + float counter = 2; + float data = 1; + float check = 1; + while(constant <= 40) {; + data = constant * data; + check = 1/data; + counter = check + counter; + printf("%s %f\n","counter :", counter); + + constant++; + } + return 0; + } \ No newline at end of file diff --git a/DeitelC/Chapter3/ConstantEOverX.c b/DeitelC/Chapter3/ConstantEOverX.c new file mode 100644 index 0000000..410704d --- /dev/null +++ b/DeitelC/Chapter3/ConstantEOverX.c @@ -0,0 +1,30 @@ +#include +int powerFun(int userData, int i) { + float result = 1.0; + while (i > 0) { + result *= userData; + i--; + } + return result; +} + +int main(void) { + double constant = 2; + double counter = 2; + double data = 1; + float check = 1; + int userData; + int i = 1; + printf("%s\n","Please Enter x (in E^x): "); + scanf("%d", &userData); + while(i <= userData) { + data = constant * data; + check = powerFun(userData, i)/data; + counter = check + counter; + printf("%s %f\n","counter :", counter); + printf("%s %d\n","PowerFun:", powerFun(userData, i)); + i++; + constant++; + } + return 0; + } \ No newline at end of file diff --git a/DeitelC/Factoriel.c b/DeitelC/Chapter3/Factoriel.c similarity index 100% rename from DeitelC/Factoriel.c rename to DeitelC/Chapter3/Factoriel.c diff --git a/DeitelC/FloydsTriangle.c b/DeitelC/Chapter3/FloydsTriangle.c similarity index 100% rename from DeitelC/FloydsTriangle.c rename to DeitelC/Chapter3/FloydsTriangle.c diff --git a/DeitelC/HelloPrint.c b/DeitelC/Chapter3/HelloPrint.c similarity index 100% rename from DeitelC/HelloPrint.c rename to DeitelC/Chapter3/HelloPrint.c diff --git a/DeitelC/HollowSquareOfAsteriks.c b/DeitelC/Chapter3/HollowSquareOfAsteriks.c similarity index 100% rename from DeitelC/HollowSquareOfAsteriks.c rename to DeitelC/Chapter3/HollowSquareOfAsteriks.c diff --git a/DeitelC/HowMany9.c b/DeitelC/Chapter3/HowMany9.c similarity index 100% rename from DeitelC/HowMany9.c rename to DeitelC/Chapter3/HowMany9.c diff --git a/DeitelC/IsPrime.c b/DeitelC/Chapter3/IsPrime.c similarity index 100% rename from DeitelC/IsPrime.c rename to DeitelC/Chapter3/IsPrime.c diff --git a/DeitelC/LargestNum.c b/DeitelC/Chapter3/LargestNum.c similarity index 100% rename from DeitelC/LargestNum.c rename to DeitelC/Chapter3/LargestNum.c diff --git a/DeitelC/MultiplesOf3WithAnInfiniteLoop.c b/DeitelC/Chapter3/MultiplesOf3WithAnInfiniteLoop.c similarity index 100% rename from DeitelC/MultiplesOf3WithAnInfiniteLoop.c rename to DeitelC/Chapter3/MultiplesOf3WithAnInfiniteLoop.c diff --git a/DeitelC/MultiplesOfNumber.c b/DeitelC/Chapter3/MultiplesOfNumber.c similarity index 100% rename from DeitelC/MultiplesOfNumber.c rename to DeitelC/Chapter3/MultiplesOfNumber.c diff --git a/DeitelC/PseudocodeBonusInstructor.md b/DeitelC/Chapter3/PseudocodeBonusInstructor.md similarity index 100% rename from DeitelC/PseudocodeBonusInstructor.md rename to DeitelC/Chapter3/PseudocodeBonusInstructor.md diff --git a/DeitelC/PsudocodeLargestNum.md b/DeitelC/Chapter3/PsudocodeLargestNum.md similarity index 100% rename from DeitelC/PsudocodeLargestNum.md rename to DeitelC/Chapter3/PsudocodeLargestNum.md diff --git a/DeitelC/RightTriangle.c b/DeitelC/Chapter3/RightTriangle.c similarity index 100% rename from DeitelC/RightTriangle.c rename to DeitelC/Chapter3/RightTriangle.c diff --git a/DeitelC/Salary.c b/DeitelC/Chapter3/Salary.c similarity index 100% rename from DeitelC/Salary.c rename to DeitelC/Chapter3/Salary.c diff --git a/DeitelC/SalesCommision.c b/DeitelC/Chapter3/SalesCommision.c similarity index 100% rename from DeitelC/SalesCommision.c rename to DeitelC/Chapter3/SalesCommision.c diff --git a/DeitelC/SalesTax.c b/DeitelC/Chapter3/SalesTax.c similarity index 100% rename from DeitelC/SalesTax.c rename to DeitelC/Chapter3/SalesTax.c diff --git a/DeitelC/SideOfATriangle.c b/DeitelC/Chapter3/SideOfATriangle.c similarity index 100% rename from DeitelC/SideOfATriangle.c rename to DeitelC/Chapter3/SideOfATriangle.c diff --git a/DeitelC/SquareOfAsteriks.c b/DeitelC/Chapter3/SquareOfAsteriks.c similarity index 100% rename from DeitelC/SquareOfAsteriks.c rename to DeitelC/Chapter3/SquareOfAsteriks.c diff --git a/DeitelC/TabularOutput.c b/DeitelC/Chapter3/TabularOutput.c similarity index 100% rename from DeitelC/TabularOutput.c rename to DeitelC/Chapter3/TabularOutput.c diff --git a/DeitelC/TabularOutputPower.c b/DeitelC/Chapter3/TabularOutputPower.c similarity index 100% rename from DeitelC/TabularOutputPower.c rename to DeitelC/Chapter3/TabularOutputPower.c diff --git a/DeitelC/TwoLargestNumber.c b/DeitelC/Chapter3/TwoLargestNumber.c similarity index 100% rename from DeitelC/TwoLargestNumber.c rename to DeitelC/Chapter3/TwoLargestNumber.c diff --git a/DeitelC/XPowerY.c b/DeitelC/Chapter3/XPowerY.c similarity index 100% rename from DeitelC/XPowerY.c rename to DeitelC/Chapter3/XPowerY.c diff --git a/DeitelC/a.exe b/DeitelC/Chapter3/a.exe similarity index 74% rename from DeitelC/a.exe rename to DeitelC/Chapter3/a.exe index 399f74d..e4b3924 100644 Binary files a/DeitelC/a.exe and b/DeitelC/Chapter3/a.exe differ diff --git a/DeitelC/test1.c b/DeitelC/Chapter3/test1.c similarity index 100% rename from DeitelC/test1.c rename to DeitelC/Chapter3/test1.c diff --git a/DeitelC/test2.c b/DeitelC/Chapter3/test2.c similarity index 100% rename from DeitelC/test2.c rename to DeitelC/Chapter3/test2.c diff --git a/DeitelC/Chapter4/a.exe b/DeitelC/Chapter4/a.exe new file mode 100644 index 0000000..9ef15aa Binary files /dev/null and b/DeitelC/Chapter4/a.exe differ diff --git a/DeitelC/Chapter4/sum99.c b/DeitelC/Chapter4/sum99.c new file mode 100644 index 0000000..67e198a --- /dev/null +++ b/DeitelC/Chapter4/sum99.c @@ -0,0 +1,14 @@ +#include +#include + +int main(void) { + int sum = 0; + int count = 1; + + for(;count<=99;count+=2) { + sum += count; + } + printf("%d\n", sum); + printf("%.2f\n", pow(2.5,3)); + return 0; +} \ No newline at end of file