From 40a50ac69c6320de03710c581a63f9283d6ce1d2 Mon Sep 17 00:00:00 2001 From: DikshantUbale <163621333+DikshantUbale@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:02:32 +0530 Subject: [PATCH 1/7] Update p8.c --- c/p8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/p8.c b/c/p8.c index 5379851..c5f67e9 100644 --- a/c/p8.c +++ b/c/p8.c @@ -5,7 +5,7 @@ float computeAverage(float* x, size_t* N) { float numerator = 0.0; float denominator = 0.0; - for (size_t i = 0; i < (size_t)N; i++) { + for (size_t i = 0; i < (size_t)*N; i++) { numerator += x[i]; denominator++; } From 62d2f319020a56814ece933a159bc04d69d309d6 Mon Sep 17 00:00:00 2001 From: DikshantUbale <163621333+DikshantUbale@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:04:09 +0530 Subject: [PATCH 2/7] Update p9.c --- c/p9.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/c/p9.c b/c/p9.c index 62ae10a..1867648 100644 --- a/c/p9.c +++ b/c/p9.c @@ -9,18 +9,19 @@ */ #include +#include int* filterMultiples(int* arr, int N, int* NOut, int num) { int numPrimes = 0; *NOut = 0; for (int i = 0; i < N; i++) { if (arr[i] >= num && arr[i]%num == 0) { - *NOut++; + (*NOut)++; } } int* multiples = malloc((*NOut)*sizeof(int)); int idx = 0; - for (int i = 0; i < *NOut; i++) { + for (int i = 0; i < N; i++) { if (arr[i] >= num && arr[i]%num == 0) { multiples[idx] = arr[i]; idx++; @@ -33,7 +34,8 @@ int main() { int arr[10] = {5, 6, 12, 20, 18, 24, 48, 58, 60, 68}; // Multiples of 6 int NOut; - int* multiples = filterMultiples(arr, 10, &NOut, 6); + int* multiples = malloc(100*sizeof(int)); + multiples = filterMultiples(arr, 10, &NOut, 6); for (int i = 0; i < NOut; i++) { printf("%i ", multiples[i]); } From 7cb891650c440f320bc8cab9aa6c6eadbe3620af Mon Sep 17 00:00:00 2001 From: DikshantUbale <163621333+DikshantUbale@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:04:44 +0530 Subject: [PATCH 3/7] Update p6.c --- c/p6.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c/p6.c b/c/p6.c index 2e46837..ccc406e 100644 --- a/c/p6.c +++ b/c/p6.c @@ -1,9 +1,10 @@ //allocating memory to a pointer through a function #include +int x; int *fun() { - int x = 5; + x = 5; return &x; } int main() From d912a4afe417379fc8a85370cf864ef58275a6cf Mon Sep 17 00:00:00 2001 From: DikshantUbale <163621333+DikshantUbale@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:05:18 +0530 Subject: [PATCH 4/7] Update p5.c --- c/p5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/p5.c b/c/p5.c index 09475d3..977cf80 100644 --- a/c/p5.c +++ b/c/p5.c @@ -6,6 +6,6 @@ void main(){ int a=10; int *ptr = &a; - *ptr++; + (*ptr)++; printf("%d", *ptr); } From ec9da34f618121c3c1060a133ec61d8451aee457 Mon Sep 17 00:00:00 2001 From: DikshantUbale <163621333+DikshantUbale@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:05:44 +0530 Subject: [PATCH 5/7] Update p14.c --- c/p14.c | 1 + 1 file changed, 1 insertion(+) diff --git a/c/p14.c b/c/p14.c index fdd4b97..e50f8ad 100644 --- a/c/p14.c +++ b/c/p14.c @@ -21,6 +21,7 @@ int romanToInt(char * s){ for(int i=0;i Date: Sat, 16 Mar 2024 11:06:44 +0530 Subject: [PATCH 6/7] Update p13.c --- c/p13.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/p13.c b/c/p13.c index 753cad1..90eeb08 100644 --- a/c/p13.c +++ b/c/p13.c @@ -13,7 +13,7 @@ int main(){ int n = sizeof(a)/sizeof(a[0]); int m = sizeof(b)/sizeof(b[0]); - for(int i=0;i Date: Sat, 16 Mar 2024 11:07:26 +0530 Subject: [PATCH 7/7] Update p11.c --- c/p11.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c/p11.c b/c/p11.c index d6ef183..264549b 100644 --- a/c/p11.c +++ b/c/p11.c @@ -13,7 +13,8 @@ int isSameTree(struct TreeNode* p, struct TreeNode* q){ return 1; } if(p->val == q->val){ - return isSameTree(p->left, q->left) || isSameTree(p->right, q->right); + if( isSameTree(p->left, q->left) || isSameTree(p->right, q->right)) + return 1; } return 0; }