WHAT'S NEW?
Loading...

Simple Menu Program in C



#include<stdio.h>
#include<stdlib.h>

void threeno();
int sumno(int);
int sumos(int);
int pro(int);
int a, b, c;

void main() {
    int ch, x;
    while (1) {
        printf("\nMENU");
        printf("\n1.Input three numbers");
        printf("\n2.Summation of the numbers\n3.Sum of squares");
        printf("\n4.Product of the three numbers");
        printf("\n5.Exit from program");
        printf("\n\nEnter your choice: ");
        scanf("%d", &ch);
        switch (ch) {
        case 1:
            threeno();
            break;
        case 2:
            printf("Summation of the numbers is: %d\n", sumno(x));
            break;
        case 3:
            printf("Sum of squares is: %d\n", sumos(x));
            break;
        case 4:
            printf("Product of the numbers is: %d\n", pro(x));
            break;
        case 5:
            exit(1);
        default:
            printf("Invalid choice\n");
        }
    }
}

void threeno() {
    printf("Enter the three numbers: \n");
    scanf("%d%d%d", &a, &b, &c);
}

int sumno(int sum) {
    threeno();
    sum = a + b + c;
    return (sum);
}

int sumos(int sum) {
    threeno();
    sum = a * a + b * b + c * c;
    return (sum);
}

int pro(int pro) {
    threeno();
    pro = a * b * c;
    return (pro);
}

0 comments:

Post a Comment