In: Computer Science
In C#, declare structure named Person. The structure should have the following attributes of first name, last name, zip code, and phone number.
C# Program
using System;
struct Person { /* declaring structure */
public string firstname; /*declaring firstname as
string */
public string lastname; /* declaring structure last
name as string*/
public int zipcode; /* declaring zipcode as integer
type */
public int phonenumber; /* declaring phone number as
integer type */
}
public class Program
{
public static void Main()
{
Person p; /* declaring p of person
type */
/* initializing values */
p.firstname="John";
p.lastname="Jackson";
p.zipcode=658523;
p.phonenumber=85965544;
/* printing details */
Console.WriteLine( "Name
:"+p.firstname+" "+p.lastname);
Console.WriteLine( "Zipcode
:"+p.zipcode);
Console.WriteLine(
"Phonenumber:"+p.phonenumber);
}
}
Screenshot
Output
If you find this useful, please rate positive , thankyou