C program to construct a structure , C/C++ Programming

Assignment Help:

c program to construct a structure:

struct sensus

                {

                                char name[30];

                                long int population;

                                float litracy_rate;

                };

 

                void main()

                {

                                struct sensus city[5];

                                printf("\n Enter Data for 5 cities:\n");

                                                for(int i=0; i<5;i++)

                                                {

                                                                printf("\n City Name:\t");

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

                                                                printf("\n Population:\t");

                                                                scanf("%ld",&city[i].population);

                                                                printf("\n litracy rate:\t");

                                                                scanf("%f",&city[i].litracy_rate);

                                                                printf("\n\n\a");

                                                }

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

                                                {for(int j=0;j<5-(i+1);j++)

                                                                {

                                                                if(city[i].litracy_rate>city[i+1].litracy_rate)

                                                                {

                                                                                struct sensus t=city[i];

                                                                                city[i]=city[i+1];

                                                                                city[i+1]=t;

                                                                }

                                                }

                                                }

                                                printf("You enter the Following Data:\n");

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

                                                {

                                                                printf("\n CityName:\t%s",city[i].name);

                                                                printf("\n Pupulation:\t%ld",city[i].population);

                                                                printf("\n Litracy Rate=\t%f",city[i].litracy_rate);

                                                                printf("\n\n");

                                                }

 

                }


Related Discussions:- C program to construct a structure

Is always the default constructor for fred fred::fred()?, Is always the def...

Is always the default constructor for Fred Fred::Fred()?

What should one catch?, A: By keeping along with the C++ tradition of "ther...

A: By keeping along with the C++ tradition of "there's more than one method to do that" (translation: "give programmers options & tradeoffs so they can choose what's best for them

Metric number, how are metric numer change the number of metric

how are metric numer change the number of metric

Decode the code, Smugglers are becoming very smart day by day. Now they hav...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Program that computes square matrix multiplication, Goal: Design a progr...

Goal: Design a program that computes square matrix multiplication on GPU using CUDA. Write the code in C. In particular, your implementation should obey the following requiremen

Explain the function of five elements that are on a, explain the function o...

explain the function of five elements that are found on a motherboard#

What is the best fit algorithm, The Best fit algorithm: The best fit metho...

The Best fit algorithm: The best fit method occurs the smallest free block whose size is greater than or equivalent to n. An algorithm to get such a block by traversing the whole

Can copy constructor admit an object of the same class , Can copy construct...

Can copy constructor admit an object of the same class as parameter, rather than reference of the object?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd