From d950d4b10b88aba5cbf7a85961bd53a4fa349845 Mon Sep 17 00:00:00 2001 From: AmirHossein Zendavani Date: Sun, 17 Apr 2022 01:12:11 +0430 Subject: [PATCH] bugs fixed in 3 first file and in others show its output --- 1.cpp | 2 +- 2.cpp | 6 +++--- 3.cpp | 2 +- 4.cpp | 4 +++- 5.cpp | 5 ++++- 6.cpp | 2 ++ 7.cpp | 4 +++- 8.cpp | 2 ++ 8 files changed, 19 insertions(+), 8 deletions(-) diff --git a/1.cpp b/1.cpp index fedde2c..575af44 100644 --- a/1.cpp +++ b/1.cpp @@ -13,7 +13,7 @@ long long int factorial(int n) long long int *producingTheFactorialFractions() { - long long b[10]; + b = new long long[10]; for (int i = 10; i >= 0; i--) { diff --git a/2.cpp b/2.cpp index 6a27746..432cb78 100644 --- a/2.cpp +++ b/2.cpp @@ -5,9 +5,9 @@ using namespace std; // count all the specific char in the whole array of strings int countAllSpecificChars(string sArr[], int arrLength, char specificChar) { - int count; - for (int i = 0; i <= arrLength; ++i) - for (int j = 0; j <= sArr[i].size(); ++j) + int count = 0; + for (int i = 0; i < arrLength; ++i) + for (int j = 0; j < sArr[i].size(); ++j) // if the jth char of the string is the specific char if (sArr[i][j] = specificChar) count++; diff --git a/3.cpp b/3.cpp index 77eb722..5855d07 100644 --- a/3.cpp +++ b/3.cpp @@ -97,7 +97,7 @@ int average() return sum / count; } -void main() +int main() { int cmd; long long int x; diff --git a/4.cpp b/4.cpp index a9a32f2..27b4503 100644 --- a/4.cpp +++ b/4.cpp @@ -6,4 +6,6 @@ int main() float *ptr2 = ptr1 + 3; printf("%f", *ptr2 - *ptr1); return 0; -} \ No newline at end of file +} + +// 78.000000 \ No newline at end of file diff --git a/5.cpp b/5.cpp index 1be3d10..3605578 100644 --- a/5.cpp +++ b/5.cpp @@ -7,4 +7,7 @@ int main() printf("%d\n", (*ptr2 - *ptr1)); printf("%c", (char)(*ptr2 - *ptr1)); return 0; -} \ No newline at end of file +} + +// 50 +// 2 \ No newline at end of file diff --git a/6.cpp b/6.cpp index f8b3141..30b21ac 100644 --- a/6.cpp +++ b/6.cpp @@ -9,3 +9,5 @@ int main() printf("%d\n", a); return 0; } + +// 513 \ No newline at end of file diff --git a/7.cpp b/7.cpp index 7b065a0..195b6a6 100644 --- a/7.cpp +++ b/7.cpp @@ -7,4 +7,6 @@ int main() p += 2; printf("%d", *p); return 0; -} \ No newline at end of file +} + +// 3 \ No newline at end of file diff --git a/8.cpp b/8.cpp index ac3d613..27268a6 100644 --- a/8.cpp +++ b/8.cpp @@ -11,3 +11,5 @@ int main() { } + +// Be WooW \ No newline at end of file