C LANGUAGE DEFINING STRUCTURAL TYPES OF DATA I have define structural types of d
ID: 3813165 • Letter: C
Question
C LANGUAGE DEFINING STRUCTURAL TYPES OF DATA
I have define structural types of data which allow me to represent the following objects and a variable for each created type restricted to certain conditions
1)
We want to store certain data for a student type (type tSudent?)
Store name and surnames (guess is not necessary to use namespace std, string and that's it )
Store gender (male or female)
Store whether they are vaxinated or not
Store the school code ( int, without letters)
Store birthday date
Conditions: Max character length 100 (so I guess that #define MAXCHAR 100 ? )
The only possible variables for the gender variable are boy or girl
Center code is within the range 1 99999
For the birthday date we separate like always day, month and year.
2)
We want to store certain data to classify one computer game from a computer game shop (tGame?)
Store game name
Store type of game (racing, adventure,children,rpg,shooter)
Store recommended minimum age to be allowed to play
A vector where to store all different computer brands that can run the game (types: ab, bc, cd or ef)
Store game price
Conditions: Conditions: Max character length 100
Explanation / Answer
#include<stdio.h>
struct student
{
char *name,*sur_name;
char *gender;
int vaxinated,code;
char *birth;
};
int main()
{
struct student st1;
st1.name="durgaprasad";
st1.sur_name="bongu";
st1.gender="M";
st1.code=110469;
st1.vaxinated=1;
st1.birth="02-10-1994";
printf("Student details : ");
printf("%s %s %s %d %d(yes-1 or no-0) %s ",st1.name,st1.sur_name,st1.gender,st1.code,st1.vaxinated,st1.birth);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.