Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a Go program to find the index of an element in a slice using a loop.

Easy

Problem Statement

Create a Go program to find the index of an element in a slice using a loop.

Sample Input

A slice of integers (e.g., [10, 20, 30, 40]) and an element to find (e.g., 30).

Sample Output

2

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
package main import "fmt" func main() { // Find and print the index of an element in the slice }
Log in or sign up to run or submit your code.Log inSign up
Input
A slice of integers (e.g., [10, 20, 30, 40]) and an element to find (e.g., 30).
Expected Output
2