Sorry my English is bad.Im beginner in programing with c/c++ I have to write 2 codes and want some help

1.
Write a program with a function main () and selecting a menu of functions:
Generate a programming-random number generator data for lottery ticket / max 100 / with six-digit numbers and store them in an array
-Overwrite generated a new array and sort this array in ascending order and display output
-Counting and display output and numbers of all "happy" six digit lottery tickets /these numbers which sum of the first 3 digits is equal to the last three/
-Save in the array and display output sequence numbers of downloaded "lucky" lottery tickets

I know only rand and srand but how to display these lucky/happy numbers and how to store 6dight numbers i array?

2.
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

I have a code but its wrong maybe and not completed I dont know how to display youngest girl and data for 1 girl also dont know how to work with files

#include <stdio>
#include <conio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

#define N 30 //max girls

typedef struct
{
   char number[10];
   char name[10];
   char family[10];
   int age;
   float heigth;
   float weight;
   char country[3];
} girl;

girl d[N];
int top=0;
float height;
float weight;

void load();
void save();


void input()
{
   int i, n;
   do
   {
       cout<<"\n Whats the 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: ";
       cin>>d[i].height;
       cout<<"\n weight: ";
       cin>>d[i].weight;
       cout<<"\n country: ";
       cin>>d[i].country;
   }
   top+=n;
}


void disp(int i) //Display data for 1 girl
{
   cout<<"\n "<<d[i].nomer<<"\t"<<d[i].ime<<"\t"<<d[i].family<<"\t"<<d[i].age<<"\t"<<d[i].visochina<<"\t"
       <<d[i].teglo<<"\t"<<d[i].country<<endl;
}

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

void teen()
{
   int i;

   cout<<"\n Girls under 20\n";
   for(i=0;i<top;i++)
   {
       d[i].age*=1;
       if(d[i].age<20)
           disp(i);
   }
}


void load() //file
{
   FILE *fp;
}

int menu()
{
   int ch;
   cout<<"\n_______________MENU_____________________";
   cout<<"\n 1. Input number of girls";
   cout<<"\n 2. Display list of all girls";
   cout<<"\n 3. Display girls under 20";
   cout<<"\n 4. Exit";

   do
   {
       cout<<"\n Choice: ";
       cin>>ch;
   }
   while(ch<1||ch>4);
       return(ch);
}

int main()
{
   int i;
   cout<<"\n Loading file\n";
   load();
   do
   {
       i=menu();
       switch(i)
       {
       case 1: input();break;
       case 2: list();break;
       case 3: teen();break;



       }

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

And 2 codes msut be console applications and not object-oriented

You wrote all that code and you can't create a random number generator??!!!

i just dont know how im learning programing since september 2012 and i cant understend all things just know arrays and loops and functions a little just basic things want just some help

I know only rand and srand but how to display these lucky/happy numbers and how to store 6dight numbers i array?

Simple: just an assignment statement. Below is an example.

int numbers[20];

for(int i = 0; i < 20; i++)
   numbers[i] = rand();


// now to display them
for(int i = 0; i < 20; i++)
    cout << numbers[i] << '\n';

If you want a six digit number
numbers[i] = (rand()%100000) + 100000;

In the above, % is the mod operator, which returns the remainder after division.

also dont know how to work with files

google is your friend when you want quick answer to a question. Read any of these google links.

EDIT: Problem solved

I'm having trouble with the rand() function. Here's a fragment of my code (from Tortoise.cpp). I call this function from main():

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include "Tortoise.h"


int Tortoise::generateMovement()
{
     srand(time(0));
     int current;
     current = (rand()%10)+1;
     cout << current;

     // ... more code ...

}

I would expect current to be a random number between 1 and 10, but I keep getting random numbers between 10 and 100 that are multiples of 10, like 20, 50, 80, 90, etc. I've compared my code and includes with several online samples and samples from my textbook, and have even tried two different compilers, but can't find where I've gone wrong. Thanks!

Ok i get it but I don know how to display "happy/lucky" numbers which sum of the first 3 digits is equal to the last three/??? Can you give an example how to do it?

I apologize for my last post, I solved the problem myself (there is something about looking at it one last time, even though I've looked at it often). Sorry to bother!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.