guys I need these answers asap plzzz thanq very muchSolution
guys I need these answers asap plzzz thanq very much
Solution
1
#include <stdio.h>
struct Phone
{
char description[50];
int id;
float cost;
};
struct Phone ReadPhone(struct Phone phone)
{
printf(\"\ Enter Phone\'s name \");
scanf(\"%s\",phone.description);
printf(\"\ Enter Phone\'s ID\");
scanf(\"%d\",&phone.id);
printf(\"\ Enter Cost of Phone\");
do
{
scanf(\"%f\",&phone.cost);
if(phone.cost<0)
printf(\"\ cost should be poistive.Enter cost again\");
}while(phone.cost<0);
return phone;
}
void PrintPhone(struct Phone phone)
{
if(phone.cost<50)
printf(\"\ %s (%d) %.2f bargain\",phone.description,phone.id,phone.cost);
else if(phone.cost > 1000)
printf(\"\ %s (%d) %.2f ...really\",phone.description,phone.id,phone.cost);
}
void TotalCost(struct Phone phones[5])
{
int i;
float totalcost=0;
for(i=0;i<5;i++)
{
totalcost=totalcost+phones[i].cost;
}
printf(\"\ Total Cost=$%.2f\",totalcost);
}
int main(void)
{
struct Phone phones[5];
int i;
for(i=0;i<5;i++)
{
phones[i]=ReadPhone(phones[i]);
}
for(i=0;i<5;i++)
{
PrintPhone(phones[i]);
}
TotalCost(phones);
return 0;
}
Output:
2
#include <stdio.h>
struct Card
{
char title[50];
int id;
float cost;
};
struct Card ReadCard(struct Card card)
{
printf(\"\ Enter Card\'s name \");
scanf(\"%s\",card.title);
printf(\"\ Enter Card\'s ID\");
scanf(\"%d\",&card.id);
printf(\"\ Enter Cost of Card\");
do
{
scanf(\"%f\",&card.cost);
if(card.cost<0)
printf(\"\ cost should be poistive.Enter cost again\");
}while(card.cost<0);
return card;
}
void PrintCard(struct Card card)
{
if(card.cost<10)
printf(\"\ %s (%d) %.2f cheap\",card.title,card.id,card.cost);
else if(card.cost > 50)
printf(\"\ %s (%d) %.2f must sell\",card.title,card.id,card.cost);
}
void TotalCost(struct Card cards[5])
{
int i;
float totalcost=0;
for(i=0;i<5;i++)
{
totalcost=totalcost+cards[i].cost;
}
printf(\"\ Total Cost=$%.2f\",totalcost);
}
int main(void)
{
struct Card cards[5];
int i;
for(i=0;i<5;i++)
{
cards[i]=ReadCard(cards[i]);
}
for(i=0;i<5;i++)
{
PrintCard(cards[i]);
}
TotalCost(cards);
return 0;
}
output:
3
#include <stdio.h>
struct Shoe
{
char description[50];
int id;
float size;
};
struct Shoe ReadShoe(struct Shoe shoe)
{
printf(\"\ Enter Shoe\'s name \");
scanf(\"%s\",shoe.description);
printf(\"\ Enter Shoe\'s ID\");
scanf(\"%d\",&shoe.id);
printf(\"\ Enter size of Shoe\");
do
{
scanf(\"%f\",&shoe.size);
if(shoe.size<0)
printf(\"\ size should be poistive.Enter size again\");
}while(shoe.size<0);
return shoe;
}
void PrintShoe(struct Shoe shoe)
{
if(shoe.size<6)
printf(\"\ %s (%d) %.2f small\",shoe.description,shoe.id,shoe.size);
else if(shoe.size > 14)
printf(\"\ %s (%d) %.2f giant\",shoe.description,shoe.id,shoe.size);
}
void LargestSize(struct Shoe shoes[5])
{
int i;
int largestsize=0;
for(i=0;i<5;i++)
{
if(largestsize<shoes[i].size)
largestsize=shoes[i].size;
}
printf(\"\ largest Size=%d\",largestsize);
}
int main(void)
{
struct Shoe shoes[5];
int i;
for(i=0;i<5;i++)
{
shoes[i]=ReadShoe(shoes[i]);
}
for(i=0;i<5;i++)
{
PrintShoe(shoes[i]);
}
LargestSize(shoes);
return 0;
}
output:
4
#include <stdio.h>
struct Flower
{
char name[50];
int id;
int count;
};
struct Flower ReadFlower(struct Flower flower)
{
printf(\"\ Enter Flower\'s name \");
scanf(\"%s\",flower.name);
printf(\"\ Enter flower\'s ID\");
scanf(\"%d\",&flower.id);
printf(\"\ Enter count of Flower\");
do
{
scanf(\"%d\",&flower.count);
if(flower.count<0)
printf(\"\ count should be poistive.Enter count again\");
}while(flower.count<0);
return flower;
}
void PrintFlower(struct Flower flower)
{
if(flower.count<5)
printf(\"\ %s (%d) %d running low\",flower.name,flower.id,flower.count);
else if(flower.count > 50)
printf(\"\ %s (%d) %d discount\",flower.name,flower.id,flower.count);
}
void SumFlowers(struct Flower flowers[5])
{
int i;
int sumflowers=0;
for(i=0;i<5;i++)
{
sumflowers=sumflowers+flowers[i].count;
}
printf(\"\ Sum of Flowers=%d\",sumflowers);
}
int main(void)
{
struct Flower flowers[5];
int i;
for(i=0;i<5;i++)
{
flowers[i]=ReadFlower(flowers[i]);
}
for(i=0;i<5;i++)
{
PrintFlower(flowers[i]);
}
SumFlowers(flowers);
return 0;
}
output:
5
#include <stdio.h>
struct Pet
{
char name[50];
int id;
int age;
};
struct Pet ReadPet(struct Pet pet)
{
printf(\"\ Enter pet\'s name \");
scanf(\"%s\",pet.name);
printf(\"\ Enter Pet\'s ID\");
scanf(\"%d\",&pet.id);
printf(\"\ Enter age of Pet\");
do
{
scanf(\"%d\",&pet.age);
if(pet.age<0)
printf(\"\ age should be poistive.Enter age again\");
}while(pet.age<0);
return pet;
}
void PrintPet(struct Pet pet)
{
if(pet.age<3)
printf(\"\ %s (%d) %d so cute\",pet.name,pet.id,pet.age);
else if(pet.age > 10)
printf(\"\ %s (%d) %d time to consider insurance\",pet.name,pet.id,pet.age);
}
void OldestPet(struct Pet pets[5])
{
int i;
int oldestpet=0;
for(i=0;i<5;i++)
{
if(pets[i].age>oldestpet)
oldestpet=pets[i].age;
}
printf(\"\ Oldest pet age=%d\",oldestpet);
}
int main(void)
{
struct Pet pets[5];
int i;
for(i=0;i<5;i++)
{
pets[i]=ReadPet(pets[i]);
}
for(i=0;i<5;i++)
{
PrintPet(pets[i]);
}
OldestPet(pets);
return 0;
}
Output:
![guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone](/WebImages/12/guys-i-need-these-answers-asap-plzzz-thanq-very-muchsolution-1012464-1761522777-0.webp)
![guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone](/WebImages/12/guys-i-need-these-answers-asap-plzzz-thanq-very-muchsolution-1012464-1761522777-1.webp)
![guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone](/WebImages/12/guys-i-need-these-answers-asap-plzzz-thanq-very-muchsolution-1012464-1761522777-2.webp)
![guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone](/WebImages/12/guys-i-need-these-answers-asap-plzzz-thanq-very-muchsolution-1012464-1761522777-3.webp)
![guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone](/WebImages/12/guys-i-need-these-answers-asap-plzzz-thanq-very-muchsolution-1012464-1761522777-4.webp)
![guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone guys I need these answers asap plzzz thanq very muchSolution1 #include <stdio.h> struct Phone { char description[50]; int id; float cost; }; struct Phone](/WebImages/12/guys-i-need-these-answers-asap-plzzz-thanq-very-muchsolution-1012464-1761522777-5.webp)