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

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");

                                                }

 

                }

Posted Date: 9/29/2012 7:15:08 AM | Location : United States







Related Discussions:- C program to construct a structure , Assignment Help, Ask Question on C program to construct a structure , Get Answer, Expert's Help, C program to construct a structure Discussions

Write discussion on C program to construct a structure
Your posts are moderated
Related Questions

Build a program that calculates a discount for items based on quantity bought each item is $99.99 Ask user to enter the quantity of the items Get the quantity of items from the u

The Main program is slightly more complicated and you need to think about the I/O process. First of all, for most applications you do not call the low level routines GetChar and P

Armed with your function from above, we can do some interesting things. For instance, any pixel where the offsets are both zero is a pit (lower than all surrounding points) .


Project Description: Online game development Online Live Baccarat Game is needed - client program. - server program(IOCP or ect..). - web program(ASP or PHP or etc..

Consider a group of n robots, numbered R2D1 through R2Dn, and m tasks, numbered 1 through m. Tasks can be different and robots are specialized, hence a given robot can only perform

Need someone to look over my assignment for correctness and make any necessary changes.

Should one design a classes from the outside (interfaces first) or inside (data first)? A: From the outside. A superior interface provides a simplified view which is express

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given