Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int print_menu()
- {
- int valid=0,opt;
- printf("1. Optiune 1\n2. Optiune 2\n3. Optiune 3\n4. Iesire\n\n");
- while (!valid) {
- printf("Introdu optiunea: ");
- scanf("%d",&opt);
- if (opt>0 && opt <5)
- valid=1;
- else
- printf("Optiune invalida!\n");
- }
- return opt;
- }
- void optiune1()
- {
- printf("Ai selectat optiunea 1!\n\n");
- }
- void optiune2()
- {
- printf("Ai selectat optiunea 2!\n\n");
- }
- void optiune3()
- {
- printf("Ai selectat optiunea 3!\n\n");
- }
- int main()
- {
- int nr;
- while ((nr=print_menu())!=4){
- switch (nr) {
- case 1:
- optiune1();break;
- case 2:
- optiune2();break;
- default:
- optiune3();break;
- }
- }
- printf("Bye");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement