Home

A program to declare a structure and access its elements

C Programming Language 088

Program

#include <stdio.h>

struct bank
{
    char name[15];
    int accno, bal;
};

void main()
{
    struct bank b = {"John Doe\0", 101, 1000};
    printf("\nName = %s \nAccount Number = %d", b.name, b.accno);
    printf("\nBalance = %d", b.bal);

    printf("\n");
}

Result

Name = John Doe
Account Number = 101
Balance = 1000


Last Updated on

Next Post: GraphProtocol: TS2322 null assignment in Subgraph →

Comments