Print Bill using Structures
C Programming Language Structures in C

C Program to Print Bill using Structures

Are you looking for the usage of structures? here we will discuss how to Print Bill using Structures in C language. It would help if you were excited to know that you were at the right place. here we are going to discuss all structures which are used in C language.

Print Bill using Structures

In this article, we are going to discuss a C program that will Print Bill using Structures in straightforward steps. The previous article discussed C Program to Copy the Elements of One Array into Another Array. but here we will discuss only structures.

Program

C program to print bills using structures.

#include<stdio.h>
struct bill
{
    int id;
    float amount;
    char address[30];
};
int main()
{
    struct bill s1;
    printf("enter id: ");
    scanf("%d",&s1.id);
    printf("\nenter amount: ") ;
    scanf("%f",&s1.amount);
    printf("\nenter address: ");
    scanf("%s",&s1.address);
    printf("\nid=%d \namount=%f \naddress=%s",s1.id,s1.amount,s1.address);
}

Output

The above program describes everything about structures.  We have represented each and everything related to structures in a very deep and easy way. First of all, we have to declare integer type and string variables.

First, we declare a structured datatype which is a struct, and its tag which is bill. then we will declare its attributes which will be id, amount, and address. id is declared as an integer, the amount is declared as float, and the address is declared as a string.

This will be the whole declaration of structure, then we will start our main body. we will use the struct keyword and tag bill and s1 variable. s1 is optional. here we will take the amount, id, and address values from the user.

And after all, we will print these values which are id, amount, and address. we will print these outputs in printf statement. these will be printed and stored like s1.id, s1.amount, and s1.address, means s1 is tag name and its has variables.

Conclusion

From the above article, we concluded that we can easily build and conclude the value of structures and their attributes in C language. You can easily conclude and build the structures in C language by following these some steps.

[sc_fs_faq html=” true” headline=”h4″ img=” question=”What is a prime number?” img_alt=” css_class=”] A prime number is a number which is divisible by 1 and number itself. [/sc_fs_faq][sc_fs_faq html=” true” headline=”h4″ img=” question=” What is opposite of prime number?” img_alt=” css_class=”] The opposite of a prime number is known as a composite number. [/sc_fs_faq][sc_fs_faq html=” true” headline=”h4″ img=” question=” Who is the father of C language?” img_alt=” css_class=”] Dennis Ritchie is known as the father of C language. [/sc_fs_faq][sc_fs_faq html=” true” headline=”h4″ img=” question=”Where C language was introduced?” img_alt=” css_class=”] C language was introduced at Bell Laboratory. [/sc_fs_faq]

Leave a Reply

Your email address will not be published. Required fields are marked *