**
Compile program functions for:
-Enter of a keyboard and a file into an array (by adding) data to 30 girls in the competition "Miss World"
number, name, surname, date of birth, physical data, state and display the current contents of the array on the screen
-display output data for a girl by entered from the keyboard a number and surname / by request
a new report /
-Displays data for the youngest girl in the competition and the number of girls under the age of 20 years
function main () menu selection functions and check the status of the data using the Global
variables or functions with transmission parameters, optional**

#include <iostream> 
#include <cstdio> 
#include <conio.h> 
#include <cstdlib> 
#include <cstring> 

using namespace std; 

#define N 30 //max girls 

 struct girl 
{ 
   char number[10]; 
   char name[10]; 
   char family[10]; 
   int age; 
   float height; 
   float weight; 
   char country[3]; 
} ; 
 girl d[N]; 
 int top=0; 



void input(); 
void disp(int i);
void list();
void teen();
void youngest(girl d[N]);
void showgirl(girl d[N]);
int menu();// menu 



void input() 
{int i, n; 
   do 
   { 
           cout<<"\n What is number of girls?: "; 
           cin>>n; 
   } 
   while (n<1||n>N); 
   fflush(stdin); 
   for(i=top;i<n;i++) 
   { 
           cout<<"\n Number: "; 
           cin>>d[i].number; 
           cout<<"\n name: "; 
           cin>>d[i].name; 
           cout<<"\n Familiy: "; 
           cin>>d[i].family; 
           cout<<"\n Age: "; 
           cin>>d[i].age; 
           cout<<"\n Height(cm): "; 
           cin>>d[i].Height; 
           cout<<"\n Wiight(kg): "; 
           cin>>d[i].weight; 
           cout<<"\n Country: "; 
           cin>>d[i].country; 
   } 
   top+=n; 
} 

void disp(int i) //display 1 girl
{ 
   cout<<"\n "<<d[i].number<<"\t"<<d[i].name<<"\t"<<d[i].family<<"\t"<<d[i].age<<"\t"<<d[i].height<<"\t" 
           <<d[i].weight<<"\t"<<d[i].country<<endl; 
} 

void list() //
{ 
   int i; 
   cout<<"\n List of girls\n"; 
   for(i=0;i<top;i++) 
   disp(i);} 


void teen() 
{ 
     int i; 
      cout<<"\n List of girls under 20\n"; 
         for(i=0;i<top;i++) 
         {d[i].age*=1; 
           if(d[i].age<20) 
                   disp(i); 
         } 
} 

void youngest(girl d[N]) 

{ 
     girl max; int k; 
     max.age = d[0].age; 
     for (int i = 1;i < k ; i++) 
        if (d[i].age > max.age) 
         max = d[i]; 
           cout << "Youngest girl is  "<< max.ime << max.family << max.age << max.visochina << max.teglo << max.country;} 

void showgirl(girl d[N]) 

{ 
     char nomer[10];char family[20];int i; 
         cout<<"Enter number"<<endl; 
         cin>>nomer; 
         cout<<"Enter family"<<endl; 
         cin>>family; 
              if(!(strcmp(d[i].number,number))&&!(strcmp(d[i].family,family))) 
              cout<<"The girl is "<<i; 
} 

int menu() 
{ 
   int ch; 

   cout<<"\n_______________MENU________________"; 
   cout<<"\n 1. Input number of girls"; 
   cout<<"\n 2. List of all girls"; 
   cout<<"\n 3. List of girls under 20"; 
   cout<<"\n 4. Data for 1 girl by entered nomber and family"; 
   cout<<"\n 5. Youngest girl"; 
   cout<<"\n 6. Exit"; 
   do 
   { 
           cout<<"\n Choice: "; 
           cin>>ch; 
   } 
   while(ch<1||ch>7); 
           return(ch); 
} 
int main() 
{ 
   int i; 


   do 
   { 
           i=menu(); 
           switch(i) 
           { 
           case 1: input();break; 
           case 2: list();break; 
           case 3: teen();break; 
           case 4: showgirl(d);break; 
           case 5: youngest(d);break; 


           } 
   } 
                   while(i!=6); 
return 0; 
}

**In function youngest the console say : Youngest girl is: G125.88696e-0396.55965e-039-what is wrong with this function? In function showgirl when i call function and nothing happen-this function is wrong too-where is mymistakes in theese two functions

Sorry for bad english im beginner in c++ and only these 2 functions didnt I want some help

Line 95, you test i < k. What value is k? Since it is unitialized, there is no knowing how many iterations of the loop will occur, probably going past the end of valid data in the array.

Are you looking for the oldest girl or youngest girl. Your naming is confusing. What the comparison in line 96 (and the variable name indicate) is that you are finding the oldest girl.

In showGirl, look at your variable declaration. Does it match what you're comparing in line 108?

Edited 3 Years Ago by vmanes

**Hi
My name is Abdulrazaq, I'm from Iraq

I need a c++ program to 1-identify the identifier.
2-identify the unsigned number.

Thanks....**

This article has been dead for over six months. Start a new discussion instead.