Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bsp für eine goto-Anweisung
- #include <stdio.h>
- int main(void)
- {
- int n;
- start:
- puts("Geben Sie eine Zahl zwischen 0 und 10 ein: ");
- scanf_s("%d", &n);
- if(n < 0 || n > 10)
- goto start;
- else if(n==0)
- goto location0;
- else if(n==1)
- goto location1;
- else if(n==2)
- goto location2;
- else
- goto location3;
- location0:
- puts("Ihre Eingabe lautete 0.\n");
- goto ende;
- location1:
- puts("Ihre Eingabe lautete 1.\n");
- goto ende;
- location2:
- puts("Ihre Eingabe lautete 2.\n");
- goto ende;
- location3:
- puts("Sie haben einen wert zwischen 3 und 10 eingegeben.\n");
- ende:
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement