i've started doing structure today so i'm still not perfect to them.my lecturer has asked me to this program so i really need ur suggestions about it.
The following information is available of each of 6 pets.
Kind of pet ( for example Marmoset monkey)
Name of pet (e.g Penta)
Age of pet (e.g 10 yrs)
Gender of pet (M if male, F if female)
Only pet of family (true or false)
Value of pet (e.g. R120.00)
Task 1
Write down the declaration for a struct containing the information of a single pet
Task 2
Write down the declaration of an array of 6 structs that will contain the information of 6 pets
Task 3
Write a function getInput which will input the information for 6 pets
Task 4
Write a function displayKindAndName which will display the kind and name of every pet of age 5 or above
Task 5
Write a main function to call the other two functions. Use the test data given below to run your program and submit printouts of the program and output.
so i've done the first function and it is giving me an error that i can't figure out the problem about it.this is my code.
[code=c++]
include<iostream>
using namespace std;
#include<string>
struct Pet{
string kind;
char name;
int age;
char gender;
char family;
double value;
};
void GetInput(char&,char&,int&,char&,char&,double&);
void DisplayKindAndName(string[],int[]);
int main()
{
Pet information[6];
Pet Results;
Pet kind;
Pet name;
Pet age;
Pet gender;
Pet family;
Pet value;
GetInput(kind,name,age,gender,family,value);
return 0;
}
void GetInput(char&kind,char&Name,int&Age,char&Gender,c har&Family,double&Value)
{
cout<<"please enter the kind of the pet(e.g.Marmoset monkey) \n";
cin>>kind;
cout<<"please enter the name of the pet(e.g.Penta)\n";
cin>>Name;
cout<<"Please enter the age of ther pet(e.g. 10 yrs)\n";
cin>>Age;
cout<<"Please may you enter the gender of the pet(M if male, F if female) \n";
cin>>Gender;
cout<<"Is that the Only pet of family (true or false) \n";
cin>>Family;
cout<<"What is the value of the pet?(e.g. R120.00)\n";
cin>>Value;
}
3 2627 -
include<iostream>
-
using namespace std;
-
#include<string>
-
-
struct Pet{
-
string kind;
-
char name;
-
int age;
-
char gender;
-
char family;
-
double value;
-
};
-
-
-
void GetInput(char&,char&,int&,char&,char&,double&);
-
void DisplayKindAndName(string[],int[]);
-
-
int main()
-
-
{
-
-
Pet information[6];
-
Pet Results;
-
-
Pet kind;
-
Pet name;
-
Pet age;
-
Pet gender;
-
Pet family;
-
Pet value;
-
-
GetInput(kind,name,age,gender,family,value);
-
-
-
return 0;
-
}
-
void GetInput(char&kind,char&Name,int&Age,char&Gender,char&Family,double&Value)
-
-
{
-
cout<<"please enter the kind of the pet(e.g.Marmoset monkey) \n";
-
cin>>kind;
-
cout<<"please enter the name of the pet(e.g.Penta)\n";
-
cin>>Name;
-
cout<<"Please enter the age of ther pet(e.g. 10 yrs)\n";
-
cin>>Age;
-
cout<<"Please may you enter the gender of the pet(M if male, F if female) \n";
-
cin>>Gender;
-
cout<<"Is that the Only pet of family (true or false) \n";
-
cin>>Family;
-
cout<<"What is the value of the pet?(e.g. R120.00)\n";
-
cin>>Value;
-
}
-
What error are you getting?
u forgot to include a '#' in front of include<iostream>
What error are you getting?
You have a problem with your getInput function and how you are calling it. The getInput function takes in an address to a character. Instead, you put in a structure of type Pet.
Also, remember, the structure Pet describes your pet. So creating a variable name of type Pet doesn't make sense.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: kazack |
last post by:
I am a little confused with code I am looking at. My c++ book does not go
into passing a structure to a function so I pulled out a c book which does.
and I do not understand the prototype verses...
|
by: Oliver Elphick |
last post by:
The attached proposal is written primarily for Debian. Its
motivation is that the current package upgrade process is pretty flaky
and also that the current packaging does not really provide for...
|
by: brett valjalo |
last post by:
Hey Gang!
SORRY ABOUT THE LENGTH!
Nice to see some of the same faces around this place from way back
when ... Whatta buncha CDMA addicts some o' y'all are ;)
Don't get me wrong, I...
|
by: Mannequin* |
last post by:
Hi all,
I'm working on a quick program to bring the Bible into memory from a
text file. Anyway, I have three questions to ask.
First, is my implementation of malloc () correct in the program to...
|
by: Anand Buddhdev |
last post by:
Hi everyone,
I'm a C newbie, so please be gentle. I have a program that defines the
following things:
typedef union
{
unsigned int I;
unsigned char b;
} dword;
|
by: Randy Yates |
last post by:
Hi,
I work in an embedded environment in which we often use a mix of C and
assembly code. Thus a recurring requirement is to be able to take a C
header file with structure definitions as input...
|
by: Robert S |
last post by:
Hello group
Since I want to modify a large program written in C(40K line) for the
academic purposes and the program consists of several modules, it is
necessary to have software structure in order...
|
by: chellappa |
last post by:
Hi EveryBody!
i need a information about creatting structure at runtime....
like example
.....
int main()
{
char *a,*b;
printf("Enter the structure");
scanf("%s",a);
printf ("Enter The...
|
by: Jake Thompson |
last post by:
Hello I created a DLL that has a function that is called from my main c
program.
In my exe I first get a a pointer to the address of the function by
using GetProcAddress and on the dll side I...
|
by: zehra.mb |
last post by:
Hi,
I had written application for storing employee data in binary file and
reading those data from binary file and display it in C language.
But I face some issue with writing data to binary file....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |