calculate the sum of squares of given integers, excluding any negatives. The first line of the input will be an integer N (1 <= N <= 100), indicating the number of test cases to follow. Each of the test cases will consist of a line with an integer X (0 < X <= 100), followed by another line consisting of X number of space-separated integers Yn (-100 <= Yn <= 100). For each test case, calculate the sum of squares of the integers, excluding any negatives, and print the calculated sum in the output.
Note: There should be no output until all the input has been received. Note 2: Do not put blank lines between test cases solutions. Note 3: Take input from standard input, and output to standard output.
Rules Write your solution using Go Programming Language Your source code must be a single file (package main) Do not use any for statement You may only use standard library packages
"Problem which I am facing" 'square' function below is not getting executed the required number of times according to the input test cases. To meet specific requirements I wasn't allowed to use the 'for' statement. Please help me out. Language is Go.
package main
import "fmt"
var s []int
func square(l int) {
i := 0
sum := 0
Square:
if l > 0 {
s[i] = s[i] * s[i]
sum = sum + s[i]
i++
l--
goto Square
}
fmt.Println(sum)
}
func myfunc(a int) {
Here:
if a > 0 {
var b int
fmt.Scanln(&b)
if b > 0 {
s = append(s, b)
}
a--
goto Here
}
}
func main() {
var a int
fmt.Scanln(&a)
TestCases:
if a > 0 {
var T int
fmt.Scanln(&T)
myfunc(T)
a--
goto TestCases
}
square(len(s))
}