ieillory for the new the new variable orange that points to class Fruit. 16. If
ID: 3574361 • Letter: I
Question
ieillory for the new the new variable orange that points to class Fruit. 16. If struct declaration CartesianPoint has subitems int x and int y, how many total int locations in memory are allocated for these variable definitions? int myNu Cartesian Point myPoint Cartesian Point my Point 17. Define a variable person1 of type Person, where Person is already declared as a struct type. definition for a function CalcSpeed that returns a double value 18. a function and has two s type parameters startLoc and endLoc (in that order of typeExplanation / Answer
ans 1) 20
4 bytes of memory is occupied by int datatype. since struct has 2 integers, each struct variable occupies 8 bytes.
4+8+8 =20
-----------------------------
ans 2)
#include <stdio.h>
#include <string>
using namespace std;
struct Person
{
string name;
string address;
};
int main()
{
int i;
Person person1 = {"jasmine", "India"};
return 0;
}
----------------------------------------------------------------
ans 3)
struct GPSPosition
{
double i;
double j;
};
double CalcSpeed(GPSPosition startLoc, GPSPosition endLoc);
-----------------------------------------------------------------------------------------------------
part ii
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
char personName[100] = "Albert Johnson";
char searchChar = 'J';
char* searchresult = NULL;
searchresult = strchr(personName, searchChar);
if(searchresult !=NULL)
printf("character found");
else
printf("character not found");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.