Fixed the logical errors and formated the code for better readeability#1
Open
Ank-Frost wants to merge 5 commits into
Open
Fixed the logical errors and formated the code for better readeability#1Ank-Frost wants to merge 5 commits into
Ank-Frost wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
File name Error fixed
issue1.c
revstr was assigned characters as in*str ="Forward". So ,I revered the order of assignmentissue2.c in for loop variable even was being multiplied by 2 (
even*=2)in each iteration instead ofaddition(
even+=2). Since even was initiated with value =0multiplication was giving zero everyiteration.
issue3.c in for loop, statement
new[i]=z; is error it should benew[i]=z[i]instead, for proper assignmentelements of array z to string new
issue4.c sorting algo was logically wrong , it involved comparing of the every
ithelements from first to lastelement which is causing errors , which should be comparing
ithelement from(i +1)thtill 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 falseso 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)iscorrect operation
issue8.c we can use
strlen()function to get the length of string . Running for loop for length of string -1 loopsavoids newline character
issue9.c statement
if(n==2): return 1;was causing to stop recursive function factorial to stop multiplication assoon as its argument become 2 ,causing the result to be half of correct result .(factorial is product of
natural number from 1 to n)