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
Introduction to I/O interfacing, discuss microcontrollers applications in industry. Detailed product design specifications that have sections on both hardware and software inclu

Using your mountain project source code as a starting point, you are to write a code that randomly chooses one of the triangles on the surface of your mountain, this will be the en

C Program to FIND VOWELS AND REMOVE VOWELS void main() {           char s[100],s1[100];           int i,j,k=0;           clrscr();           printf("ENTER ANY S

Webcam Driver static library or DLL required for Windows I want a .dll or .lib file using which i will take a snapshot from the webcam and it can't turn on the webcam LED while

what is the purpose of pointer ? what is the syntax? how it works?

Use 16 digit credit card numbers that contain 15 digits an 1 check digit. The format of the card number consists of the 15 digits followed by the check digit. The check digit is co


Develop Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: C

Reverse a string - C ++ program: Write a program in c to reverse a string. int main() {     Stack theStack;     String reverse("reverse");       cout

input marks of c and c++ if c grater than equal to 50 grater than 50 you are pass if c greater than equal to 50 c++ less than 50 than supplementry c++ if c less then 50 and c++ gra