#include <stdio.h>
void aeins(){
int x;
unsigned int y;
double z;
printf("Geben sie einen ganze Zahl ein: ");
scanf("%d", &x);
printf("Geben sie eine natürliche Zahl ein: ");
scanf("%u", &y);
printf("Geben sie eine reelle Zahl ein: ");
scanf("%lf", &z);
printf("Die dritte Potenz von %d ist %d", x, x*x*x);
printf("Die dritte Potenz von %u ist %u", y, y*y*y);
printf("Die dritte Potenz von %lf ist %lf", z, z*z*z);
}
void azwei(){
printf("Geben sie einen Character ein: ");
char c = getchar();
printf("Das nachfolgende Zeichen lautet: %c und der ASCII-Wert ist: ", c+1, c+1);
}
int main (void){
int a;
int b = 1;
while(b){
printf("Welche Aufgabe soll gezeigt werden? ");
printf("\n(1) Aufgabe 1 \n(2) Aufgabe 2\n");
scanf("%d", &a);
switch(a){
case 1: aeins();
b = 0; break;
case 2: azwei();
b = 0; break;
default: printf("Falsche Eingabe!\n"); break;
}
}
}
This is my Program and this is my output:
Welche Aufgabe soll gezeigt werden?
(1) Aufgabe 1
(2) Aufgabe 2
2
Geben sie einen Character ein: Das nachfolgende Zeichen lautet: und der ASCII-Wert ist:
Process returned 0 (0x0) execution time : 2.172 s
Press any key to continue.
As you can see my program is ignoring the getchar
command. I have tried it with a scanf
command, but it won't work too. In the function aeins
works everything. I would say I am a beginner to intermediate c programmer if this helps you.