Computer Science, asked by sukruthprimus674, 7 months ago

Develop a structure to represent planets in the solar system. Each planet has fields for the planets name,
its distance from the sun in miles and the number of moons it has. Write a program to read data from each
planet and store. Also print the name of the planet that has the highest number of moons,​

Answers

Answered by subhan34291
1

Answer:

vagahaahhajaanassnsnsnssn

Explanation:

hahahaahajajababahahaahaabbaba sbssbbsbshahajaajajajajanaanajja

Answered by shubhamsing1211
3

Answer:

#include<stdio.h>

struct solarsystem

{

   char name[20];

   int distance;

   int moons;

};

void main()

{

   struct solarsystem planet[9];

   int i,max,pos;

   printf("\n Enter Details for Planet");

   for(i=0;i<9;i++)

   {

       printf("\n Enter Name of Planet : ");

       scanf("%s",planet[i].name);

       printf("\n Enter distance of %s in miles : ",planet[i].name);

       scanf("%d",&planet[i].distance);

       printf("\n Enter moons of %s : ",planet[i].name);

       scanf("%d",&planet[i].moons);

   }

   //displaying Details

   printf("\n Planets Details : ");

   printf("\n-------------------------------");

   printf("\nName\tDistance\tMoons");

   printf("\n-------------------------------");

   for(i=0;i<9;i++)

   {

       printf("\n%s\t%d\t\t%d",planet[i].name,planet[i].distance,planet[i].moons);

   }

   //least Distance

   pos=0;

   max=planet[0].distance;

   for(i=0;i<9;i++)

   {

       if(planet[i].distance>max)

       {

           max=planet[i].distance;

           pos=i;

       }

   }

   printf("\n\nPlanet having Maximum Moon is %s (%d) ",planet[pos].name,max);

}

Explanation:

Similar questions