In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "C language structure type program example analysis". In daily operation, I believe that many people have doubts about c language structure type program case analysis. The editor has consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "c language structure type program example analysis". Next, please follow the editor to study!
Examples of structural type programs
Example: define a structure type student, including student number, name, grade and average score of 3 courses, a total of 6 members. Define a structural variable, enter the data of the first five members of the student from the keyboard, calculate the average score and output the values of all members.
The reference code is as follows
# include
Struct student / / define the structure type
{
Int id
Char name [20]
Double score1
Double score2
Double score3
Double aver
}
Int main ()
{
Struct student stu
Printf ("input: student ID number name score 1 into é score 2 into é score 3:\ n")
Scanf ("% d%s%lf%lf%lf", & stu.id,stu.name,&stu.score1,&stu.score2,&stu.score3)
Stu.aver= (stu.score1+stu.score2+stu.score3) / 3
Printf ("student ID:% d\ n", stu.id)
Printf ("name:% s\ n", stu.name)
Printf ("score 1% .2f\ n", stu.score1)
Printf ("score 2%. 2f\ n", stu.score2)
Printf ("Grade 3% .2f\ n", stu.score3)
Printf ("GPA:% .2f\ n", stu.aver)
Return 0
}
At this point, the study of "C language structure type program example analysis" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.