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

Programming Exercises

Write a Go program to define and use a struct with fields Name and Age.

Easy

Problem Statement

Write a Go program to define and use a struct with fields Name and Age.

Sample Input

A struct instance with fields initialized (e.g., {"John", 25}).

Sample Output

Name: John, Age: 25

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
package main import "fmt" type Person struct { Name string Age int } func main() { // Define a struct and print its fields }
Log in or sign up to run or submit your code.Log inSign up
Input
A struct instance with fields initialized (e.g., {"John", 25}).
Expected Output
Name: John, Age: 25