Hi i have to make this work...

//INFO: -eingabeprüfung auf buchstabe/zahl
//      -eingabeprüfung auf zahlenbereich
//      -wiederholung einbauen vill...

#include <iostream>
using namespace std;

int main()
{
    int eingabe;
    
    cout<<"Geben sie eine zahl ein> ";
    cin>>eingabe;
    

    if(eingabe>0 && eingabe<13)
    {
        switch(eingabe)
        {
            case 1:
                cout<<"eins"<<endl;
                break;
            case 2:
                cout<<"zwei"<<endl;
                break;
            case 3:
                cout<<"drei"<<endl;
                break;
            case 4:
                cout<<"vier"<<endl;
                break;
            case 5:
                cout<<"fuenf"<<endl;
                break;
            case 6:
                cout<<"sechs"<<endl;
                break;
                case 7:
                cout<<"sieben"<<endl;
                break;
            case 8:
                cout<<"acht"<<endl;
                break;
            case 9:
                cout<<"neun"<<endl;
                break;
            case 10:
                cout<<"zehn"<<endl;
                break;
            case 11:
                cout<<"elf"<<endl;
                break;
            
        }
    }
    
    const char *vw[]={"zehn", "drei", "vier", "fuenf", "sech", "sieb", "acht", "neun"};
    const char *xy[]={"einund", "zweiund", "dreiund", "vierund", "fuenfund", "sechsund", "siebenund", "achtund", "neunund"};
    const char *wx[]={"zwanzig", "dreisig", "vierzig", "fuenfzig", "sechzig", "siebzig", "achtzig", "neunzig"};
    
    int x;
    int y;
    
    char anf[10];
    char end[10];


        if(eingabe>=13 && eingabe<=19)
        {
            x=eingabe/10;
            y=eingabe%10-1;
            
            strcpy(anf, vw[y-1]);
            //cout<<anf;
            
            
}

could someone plz finish or find me the mistake...

Your german needs some work!

Review your one's list! vw[]
zero and one are missing. 10 should be at the end of the list!

Looks like its missing a close bracket } at the last line.

What other compiler errors are you getting? What compiler and operating system are you using?

My German is a bit rusty but...

You can put all your number's text in a single array or two arrays.
0 ... 19
20,30,40,50,60,70,80,90
or
0 ... 19, 20, 30 ... 90, 100, 1000,

All your single noun forms are 0...19

tens = num / 10;
ones = num % 10;

if (tens >= 2)
          print    ary[ones] "und" ary[tens + 18]
else 
          print ary num

German is an 8-bit ASCII not a 7-bit as it used umlauts on characters and those are encoded in the upper 128...255 character range. You should change your char's to byte's when you get a chance! If you're using simple 7-bit ASCII then no need to make the byte change, but it is something to keep in mind!

Can you please write the lines whitch i have mistaked.... so i can look better whats wrong...

im using Dev c++

here are the mistakes he says

In function `int main()':
expected `}' at end of input

Ok Now i can compile but it still dont work like i want to....

//INFO: -eingabeprüfung auf buchstabe/zahl
//      -eingabeprüfung auf zahlenbereich
//      -wiederholung einbauen vill...

#include <iostream>
using namespace std;

int main()
{
    int eingabe;
    
    cout<<"Geben sie eine zahl ein> ";
    cin>>eingabe;
    

    if(eingabe>0 && eingabe<13)
    {
        switch(eingabe)
        {
            case 1:
                cout<<"eins"<<endl;
                break;
            case 2:
                cout<<"zwei"<<endl;
                break;
            case 3:
                cout<<"drei"<<endl;
                break;
            case 4:
                cout<<"vier"<<endl;
                break;
            case 5:
                cout<<"fuenf"<<endl;
                break;
            case 6:
                cout<<"sechs"<<endl;
                break;
                case 7:
                cout<<"sieben"<<endl;
                break;
            case 8:
                cout<<"acht"<<endl;
                break;
            case 9:
                cout<<"neun"<<endl;
                break;
            case 10:
                cout<<"zehn"<<endl;
                break;
            case 11:
                cout<<"elf"<<endl;
                break;
            
        }
    }
    
    const char *vw[]={"zehn", "drei", "vier", "fuenf", "sech", "sieb", "acht", "neun"};
    const char *xy[]={"einund", "zweiund", "dreiund", "vierund", "fuenfund", "sechsund", "siebenund", "achtund", "neunund"};
    const char *wx[]={"zwanzig", "dreisig", "vierzig", "fuenfzig", "sechzig", "siebzig", "achtzig", "neunzig"};
    
    int x;
    int y;
    
    char anf[10];
    char end[10];


        if(eingabe>=13 && eingabe<=19)
        {
            x=eingabe/10;
            y=eingabe%10-1;
            
            strcpy(anf, vw[y-1]);
            //cout<<anf;
            }
            
}

As Ancient Dragon indicated, Insert your } onto line 75.
(Never mind, crossed posts, you just did the insertion!)

But look at your ASCII in vw as well!

what do you mean with look at your ascii in vw as well

You don't need the case statement to do the 0 through 19
though you're printing 1 through 11.

Then your are trapping the 1 through 13 and using it on a ones table lookup and your list only has eight items.


const char *vw[]={ "Zero", "eins", "drei", "vier", "fuenf", "sech", "sieb", "acht", "neun", "zehn"};

Okay I forget my German.
zero, eins, ... zen
elf, 12, 13, 14 ... 19
zwanzeg, ein und zwanzieg, zwei und zwanzig, etc.

What are 12 through 19 ???
Note you can also glue ones+"und"+{tens} thus not need the extra table for the leading ones!

so i dont need case 1 till case 11?

I'm modifying your example to try to make what I'm saying more understandable. Since I don't remember 12 through 19, I'm coding them in. Please post your code after you make your adjustments so we can all see it!

const char *vw[]={
    "zero", "eins", "zwei", "drei", "vier", "fuenf", "sech",
    "sieben", "acht", "neun", "zehn",
    "elf", "12", "13", "14", "15", "16", "17", "18", "19",
    "zwanzig", "dreisig", "vierzig", "fuenfzig", "sechzig",
    "siebzig", "achtzig", "neunzig"};
    
    int x;
    int y;
    
        if(eingabe>=20)
        {
            x=eingabe/10;            // tens
            y=eingabe%10;          // ones
            if (y != 0)
                 printf( "%sund%s", vw[ y ], vw[ x + 18 ] );  // {21..29,31..39, etc.}
            else
                  printf( "%s", vw[ x + 18 ];      // {20,30...80,90}
        }
        else
         {
             printf( "%s", vw[ eingabe ] );       // 0...19
         }   
  }

but i dont know why you want to change so much its working.. the only thing i have ist that when i use it after he changed one number in to letter that he closes my Consol

//INFO: -eingabeprüfung auf buchstabe/zahl
//      -eingabeprüfung auf zahlenbereich
//      -wiederholung einbauen vill...

#include <iostream>
using namespace std;

int main()
{
    int eingabe;
    
    cout<<"Geben sie eine zahl ein> ";
    cin>>eingabe;
    

    if(eingabe>0 && eingabe<13)
    {
        switch(eingabe)
        {
            case 1:
                cout<<"eins"<<endl;
                break;
            case 2:
                cout<<"zwei"<<endl;
                break;
            case 3:
                cout<<"drei"<<endl;
                break;
            case 4:
                cout<<"vier"<<endl;
                break;
            case 5:
                cout<<"fuenf"<<endl;
                break;
            case 6:
                cout<<"sechs"<<endl;
                break;
                case 7:
                cout<<"sieben"<<endl;
                break;
            case 8:
                cout<<"acht"<<endl;
                break;
            case 9:
                cout<<"neun"<<endl;
                break;
            case 10:
                cout<<"zehn"<<endl;
                break;
            case 11:
                cout<<"elf"<<endl;
                break;
            
        }
    }
    
    const char *vw[]={"zehn", "drei", "vier", "fuenf", "sech", "sieb", "acht", "neun"};
    const char *xy[]={"einund", "zweiund", "dreiund", "vierund", "fuenfund", "sechsund", "siebenund", "achtund", "neunund"};
    const char *wx[]={"zwanzig", "dreisig", "vierzig", "fuenfzig", "sechzig", "siebzig", "achtzig", "neunzig"};
    
    int x;
    int y;
    
    char anf[10];
    char end[10];


        if(eingabe>=13 && eingabe<=19)
        {
            x=eingabe/10;
            y=eingabe%10-1;
            
            strcpy(anf, vw[y-1]);
            //cout<<anf;
            }
            fflush(stdin);
            getchar();
            return 0;
}

try it

Fine. I was trying to help reduce your code size into something more simpler...

//Not handling zero case

Doing range 1 ... 12 but no 12!!!! You stop at 11

if(eingabe>0 && eingabe<13)
    {
        switch(eingabe)
        {
            case 1:
                cout<<"eins"<<endl;
                break;
            case 2:
                cout<<"zwei"<<endl;
                break;
            case 3:
                cout<<"drei"<<endl;
                break;
            case 4:
                cout<<"vier"<<endl;
                break;
            case 5:
                cout<<"fuenf"<<endl;
                break;
            case 6:
                cout<<"sechs"<<endl;
                break;
                case 7:
                cout<<"sieben"<<endl;
                break;
            case 8:
                cout<<"acht"<<endl;
                break;
            case 9:
                cout<<"neun"<<endl;
                break;
            case 10:
                cout<<"zehn"<<endl;
                break;
            case 11:
                cout<<"elf"<<endl;
                break;
            
        }
    }

10, 3,4,5,6,7,8,9 8 elements in vw[]

const char *vw[]={"zehn", "drei", "vier", "fuenf", "sech", "sieb", "acht", "neun"};
    const char *xy[]={"einund", "zweiund", "dreiund", "vierund", "fuenfund", "sechsund", "siebenund", "achtund", "neunund"};
    const char *wx[]={"zwanzig", "dreisig", "vierzig", "fuenfzig", "sechzig", "siebzig", "achtzig", "neunzig"};
    
    int x;
    int y;
    
    char anf[10];
    char end[10];


        if(eingabe>=13 && eingabe<=19)
        {
            x=eingabe/10;

precendence??? is it (eingabe%10 ) - 1
or

eingabbe % (10 - 1)

which has higher precedence? % or - ????

y=eingabe%10-1;    //    3...9   <---     13...19

Either way your output is 0....N
vw[0] is 10, vw[1] is 3, etc.
Where's the 13 ...19 nouns?

And no 20+ handling yet.

strcpy(anf, vw[y-1]);
            //cout<<anf;
            }
            fflush(stdin);
            getchar();
            return 0;
}

yea omg it only changes from 1 till 11 and not the rest so what would you change... plz show me in views

Good Ole'Google

Now that I've reviewed my German, I see you were missing your teens!

"null", "eins", "zwei", "drei", vier", "f:unf", "sechs", "sieben",
"acht", "neun", "zehn", 
"elf", "zw:olf", "dreizen", "vierzehn", "f:unfzehn", "sechzehn"
"siebsehn", "achtzehn", "neunzehn",
"zwanzig", "dreiBig", vierzig", "f:unfzig", "sechzig", "siebzig",
"achzig", "neunzig" };

ok and where do i have to add this?

omg wildgoose could you please wirte the programm like you would like do it how you try to explain so i can run it on my computer and try it my self

You have a noun break down of unique nouns
0 through 12
so that's your first lookup block.
13 through 19 have appended "%szehn" so you can glue them
together without lauguage masculine/feminine/neutral issues.
20,30,40 through 90 are single word nouns
So number mod 10 = 0 are single word nouns.
21 through 29, 31 through 39 etc.
number mod 10 <>0 are glue words.

tens = num / 10
ones = num % 10

    "%sund%s", szAry[ ones ], szAry[ tens + 18 ]

Cut in that code I rewrote and posted to get the idea.
Or use the number break down I just posted to regroup your number print outs.

its really hard for me to understand you becouse of the language...

i dont even understand the half of what you tell me i know your trying to help me but if you would write the code for me so i could studi it and learn at it would be much easier for me...

So using those breakdowns.

You can't use the 0 to 12 because the teens, 13, etc. are not full ones words. So you need to keep the teens grouped with the ones.

0...19

"null", "eins", "zwei", "drei", vier", "f:unf", "sechs", "sieben","acht", "neun", "zehn", "elf", "zw:olf", "dreizen", "vierzehn", "f:unfzehn", "sechzehn""siebsehn", "achtzehn", "neunzehn"

20, 30, 40, 50, etc. 90

"zwanzig", "dreiBig", "vierzig", "f:unfzig", "sechzig", "siebzig","achzig", "neunzig"

tens = N / 10 thus {2...9}
ones = N % 10 thus {0...9}

21...29, 31...39, .... 81...89, 91...99
Using the ones (skipping NULL for zero)
"eins", "zwei", "drei", vier", "f:unf", "sechs", "sieben","acht", "neun",
UND
then the 20,30,40, 90 list using the tens

thus 21
eins und zwanzig ->>> einsundzwanzig

What the hell do you mean with that stuff

this is practically the same code I posted earlier that you rejected!
Only this time I used the German words with altered umlauts such as :u and B for German B or ss.

const char *vw[] = {
"null", "eins", "zwei", "drei", "vier", "f:unf", "sechs", "sieben","acht", "neun", "zehn", "elf", "zw:olf", "dreizen", "vierzehn", "f:unfzehn", "sechzehn","siebsehn", "achtzehn", "neunzehn","zwanzig", "dreiBig", "vierzig", "f:unfzig", "sechzig", "siebzig","achzig", "neunzig" };

void PrintNum( int eingabe )
{
    int tens, ones;

    if ((eingabe >= 100)  || (eingabe < 0))
    {
          return; // not handled yet!
    }

    if (eingabe>=20)
   {
        tens =eingabe/10;            // tens {0...9}
        ones=eingabe%10;          // ones {0...9}

        if (ones != 0)           // {21..29,31..39, etc.} 
                 printf( "%sund%s", vw[ ones ], vw[ tens + 18 ] );
         else                    // {20,30...80,90} 
                 printf( "%s", vw[ tens + 18 ];  
     }
     else 
     { 
            printf( "%s", vw[ eingabe ] );       // 0...19 
      }
}

so this is the whole code?

#include <iostream>
using namespace std;

int main()
{
const char *vw[] = {
"null", "eins", "zwei", "drei", vier", "f:unf", "sechs", "sieben","acht", "neun", "zehn", "elf", "zw:olf", "dreizen", "vierzehn", "f:unfzehn", "sechzehn""siebsehn", "achtzehn", "neunzehn","zwanzig", "dreiBig", vierzig", "f:unfzig", "sechzig", "siebzig","achzig", "neunzig" };
 
void PrintNum( int eingabe )
{
    int tens, ones;
 
    if (eingabe>=20)
   {
        tens =eingabe/10;            // tens
        ones=eingabe%10;          // ones
 
        if (y != 0)           // {21..29,31..39, etc.} 
                 printf( "%sund%s", vw[ ones ], vw[ tens + 18 ] );
         else                    // {20,30...80,90} 
                 printf( "%s", vw[ tens + 18 ];  
     }
     else 
     { 
            printf( "%s", vw[ eingabe ] );       // 0...19 
      }
getchar();
return 0;
}

Grab it again. I've been twidling Post 25 several times in the last couple minutes!
It's untested but looks about right!

const char * vw[] = "       ....... "

void PrintNum( int eingabe )
{
           the function I wrote
}

void main( void )
{
        PrintNum( 78 );
}

it says here is something wrong at 9

#include <iostream>
using namespace std;

int main()
{
const char * vw[] = {"null", "eins", "zwei", "drei", "vier", "f:unf", "sechs", "sieben","acht", "neun", "zehn", "elf", "zw:olf", "dreizen", "vierzehn", "f:unfzehn", "sechzehn""siebsehn", "achtzehn", "neunzehn","zwanzig", "dreiBig", "vierzig", "f:unfzig", "sechzig", "siebzig","achzig", "neunzig" };
 
void PrintNum( int eingabe )
{
    int tens, ones;
 
    if (eingabe>=20)
   {
        tens =eingabe/10;            // tens
        ones=eingabe%10;          // ones
 
        if (y != 0)           // {21..29,31..39, etc.} 
                 printf( "%sund%s", vw[ ones ], vw[ tens + 18 ] );
         else                    // {20,30...80,90} 
                 printf( "%s", vw[ tens + 18 ];  
     }
     else 
     { 
            printf( "%s", vw[ eingabe ] );       // 0...19 
      }
}
void main( void )
{
PrintNum( 78 );
}

get rid of that main declaration at the top of your code!

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.