C_testat_2
Home Nach oben

 

Home
Nach oben
C_testat_1
C_testat_2
C_testat_3
C_testat_4
C_testat_5
C_testat_6
C_testat_7
C_testat_8

Aufgabenstellung von Herren Grams

Lexiklische Elemente von C und einfache Datentypen

2.1 Schreiben Sie ein Programm, das sämtliche Zeichen der Codetabell zusammen mit Ihrer Ordnungszahl ausgibt. In Pascal sieht der Kern des Programms so aus:

for c:= cher(0) to char(255) do
writeln('Buchstabe = ',c,' Ordnungszahl = ' ord(c);

Deklarieren Sie die Laufvariable einmal als char und ein anderes mal als unsigned char. Experimentieren Sie mit weiteren ganzzahligen Typen.

Lösungsansätze:

/*Ausgabe der ASCII Tabelle als char*/
#include <stdio>
void main ()
{
    char =-1;
    printf("ASCCII Zeichentabelle von Guido Moser\n");
    do
    {
        i++
        printf("%4.d = %c %c",i,i,124);
    }
    while (i!=-128);
}

 

/*Ausgabe der ASCII Tabelle als char*/
#include <stdio>
void main ()
{
    unsigned char =255;
    printf("ASCCII Zeichentabelle von Guido Moser\n");
    do
    {
        i++
        printf("%3.d = %c %c",i,i,124);
    }
    while (i!=255);
}

 

/*Ausgabe der ASCII Tabelle als char*/
#include <stdio>
void main ()
{
    unsigned char =-1;
    printf("ASCCII Zeichentabelle von Guido Moser\n");
    do
    {
        i++
        printf("%3.d = %c %c",i,i,124);
    }
    while (i>255);
}

 

/*Ausgabe der ASCII Tabelle als char*/
#include <stdio>
void main ()
{
    unsigned char =-1;
    printf("ASCCII Zeichentabelle von Guido Moser\n");
    do
    {
        i++
        printf("%3.d = %c %c",i,i,124);
    }
    while (i!=511);
}