Skip to content

Fixed the logical errors and formated the code for better readeability#1

Open
Ank-Frost wants to merge 5 commits into
MysteriousCoder7:mainfrom
Ank-Frost:main
Open

Fixed the logical errors and formated the code for better readeability#1
Ank-Frost wants to merge 5 commits into
MysteriousCoder7:mainfrom
Ank-Frost:main

Conversation

@Ank-Frost

@Ank-Frost Ank-Frost commented Feb 27, 2025

Copy link
Copy Markdown

File name Error fixed

issue1.c rev str was assigned characters as in *str ="Forward". So ,I revered the order of assignment

issue2.c in for loop variable even was being multiplied by 2 (even*=2)in each iteration instead of
addition(even+=2). Since even was initiated with value =0 multiplication was giving zero every
iteration.

issue3.c in for loop, statement new[i]=z ; is error it should be new[i]=z[i] instead, for proper assignment
elements of array z to string new

issue4.c sorting algo was logically wrong , it involved comparing of the everyithelements from first to last
element which is causing errors , which should be comparing ith element from (i +1)th till last .

issue5.c. break; statements were missing in each case , causing execution of default every time . so i add break for
every case .

issue6.c strcmp() function returns 0 for same string which is causing condition for if statement to become false
so used "not !" to reverse the condition .

issue7.c the operation (a+b) was adding a to b which is a pointer instead the value it points to , (a+*b) is
correct operation

issue8.c we can use strlen() function to get the length of string . Running for loop for length of string -1 loops
avoids newline character

issue9.c statement if(n==2): return 1; was causing to stop recursive function factorial to stop multiplication as
soon as its argument become 2 ,causing the result to be half of correct result .(factorial is product of
natural number from 1 to n)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant