Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable declared but not used #42044

Closed
addy1997 opened this issue Oct 17, 2020 · 3 comments
Closed

Variable declared but not used #42044

addy1997 opened this issue Oct 17, 2020 · 3 comments

Comments

@addy1997
Copy link

@addy1997 addy1997 commented Oct 17, 2020

I wrote a program for palindrome. After compiling I am getting an error that says "remainder" declared but not used. How to get rid of this error? The code is given below

package main
import (
        
         "fmt"
)

func Palindrome(number int) {

    var remainder, temp int
    var reverse int = 0
    

    temp = number
    
    for{
        remainder = number%10
        reverse = reverse*10 + number
        number/=10
        
    if(number==0){
      break
    }
  }
    if(temp==reverse){
        fmt.Printf("%d is a Palindrome",temp)
    }else{
        fmt.Printf("%d is not a Palindrome",temp)
    }
  
}    

func main() {
    number:=456
    Palindrome(number)
}
@ALTree
Copy link
Member

@ALTree ALTree commented Oct 17, 2020

Remove the reminder variable, it's not used anywhere, and in Go unused variables are a compilation error. Closing here.

@ALTree ALTree closed this Oct 17, 2020
@addy1997
Copy link
Author

@addy1997 addy1997 commented Oct 17, 2020

Remove the reminder variable, it's not used anywhere, and in Go unused variables are a compilation error. Closing here.

Its again giving me the error that remaider is undeclared

@ALTree
Copy link
Member

@ALTree ALTree commented Oct 17, 2020

That's because you're still declaring the variable. As I wrote:

Remove the reminder variable

Remove the declaration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.