How do you this program in C Intent Demostrate meaningful application of strings
ID: 3565196 • Letter: H
Question
How do you this program in C
Intent
Demostrate meaningful application of strings, structures, functions.
Program Features
The program should include definition of one structure.
The structure should represent some meaningful, recognizable entity ( such as a computer, a building, a person, a movie, etc.)The structure should include at least two integer fieldsThe structure should include at least two float fieldThe structure should include at least two string fieldThe name of the structure and all fields should be meaningful. (Someone reading your code should be able to easily recognized the entity and your intent)The types and sizes of fields should be appropriate for the field.
Add documentation to the program using comments
Describe the purpose of the structureThe rational for the selection of all data types, sizes.
The main program should
declare an instance of this structure.call a function that allows for input of one instance of the structure. This function should prompt the user for values and allow entry and then return the structure.print a heading that includes your name and
Explanation / Answer
#include<stdio.h>
#include<string.h>
struct Book{
char author[20];
char title[20];
int noOfPages;
int yearPrinted;
int isbnNo;
float price;
};
struct Book getData(){
struct Book temp;
printf("Enter the Title of the Book : ");
gets(temp.title);
printf("Enter the name of the author of the book : ");
gets(temp.author);
printf("Enter the noOfPages of the Book : ");
scanf("%d",&(temp.noOfPages));
printf("Enter the ISBN no. of the Book : ");
scanf("%d",&(temp.isbnNo));
printf("Enter the year of publishing of the Book : ");
scanf("%d",&(temp.yearPrinted));
printf("Enter the Price of the Book : ");
scanf("%f",&(temp.price));
return temp;
}
int main(){
struct Book Book1;
Book1 = getData();
printf("------------------------ ");
printf("----Akash--Homework 5 ");
printf("-Strings And Structures- ");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.