Swift Program To Create A Simple Structure

You are currently viewing Swift Program To Create A Simple Structure

Swift Program To Create A Simple Structure

//Swift program to create a simple structure.

import Swift

struct Student {
    var id: Int      = 0
    var name:String  = ""
    var fees:Int     = 0
}

var stu = Student()

stu.id      = 101
stu.name    = "Rohit"
stu.fees    = 5000

print("Student Information:")
print("\tStudent Id  : ",stu.id)
print("\tStudent Name: ",stu.name)
print("\tStudent Fees: ",stu.fees)

Output

Student Information:
        Student Id  :  101
        Student Name:  Rohit
        Student Fees:  5000

...Program finished with exit code 0
Press ENTER to exit console.

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply