Thread: Program menu

  1. #1
    Registered User
    Join Date
    May 2016
    Posts
    4

    Program menu

    Can someone help me with program menu I need help


    Code:
    #include<stdio.h>
     #include<string.h>
     #include<conio.h>
     #include<iostream>
     #include<stdlib.h>
    
    
    
        float rad,pie=3.141,ac,l,b,ar,s1,s2,s3,s,p,at;
    
    
        int choice;
    
    
        char ch;
    
    
    
    
    
    
    
        clrscr();
    
    
      do
    
    
      {
    
    
        printf("\n Select an Option : ");
    
    
        printf("\n 1.Area of Circle :");
    
    
        printf("\n 2.Area of Rectangle :");
    
    
        printf("\n 3.Area of Triangle :");
    
    
        printf("\n 4.EXIT :");
    
    
        printf("\n Enter Your Choice :");
    
    
        scanf("%d",&choice);
    
    
    
    
    
    
    
        switch(choice)
    
    
          {
    
    
                    case 1:
    
    
                      clrscr();
    
    
                      printf("\n Enter Radius of Circle :");
    
    
                      scanf("%f",&rad);
    
    
                      ar=pie*rad*rad;
    
    
                      printf("\n Area of Circle : %f",ar);
    
    
                      break;
    
    
                    case 2:
    
    
                      clrscr();
    
    
                      printf("\n Enter Length : ");
    
    
                      scanf("%f",&l);
    
    
                      printf("\n Enter Breadth : ");
    
    
                      scanf("%f",&b);
    
    
                      ar=l*b;
    
    
                      printf("\n Area of Rectangle : %f",ar);
    
    
                      break;
    
    
                    case 3:
    
    
                      clrscr();
    
    
                      printf("\n Enter side 1 : ");
    
    
                      scanf("%f",&s1);
    
    
                      printf("\n Enter side 2 :");
    
    
                      scanf("%f",&s2);
    
    
                      printf("\n Enter side 3 :");
    
    
                      scanf("%f",&s3);
    
    
                      s=(s1+s2+s3)/3;
    
    
                      p=s*(s-s1)*(s-s2)*(s-s3);
    
    
                      at=sqrt(p);
    
    
                      printf("\n Area of Triangle : %f",at);
    
    
                      break;
    
    
                    case 4:
    
    
                      exit(0);
    
    
                    default:
    
    
                      printf("Please Enter a Valid Choice [1-4] :");
    
    
          }
    
    
    
    
    
    
    
                      scanf("%c",&ch);
    
    
        }while(ch!='N');
    
    
         getch();
    
    
    
    
    
    
    
          }
    
    
     int main()
     {
     {
    
    
        float rad,pie=3.141,ac,l,b,ar,s1,s2,s3,s,p,at;
    
    
        int choice;
    
    
        char ch;
    
    
    
    
    
    
    
        clrscr();
    
    
      do
    
    
      {
    
    
        printf("\n Select an Option : ");
    
    
        printf("\n 1.Area of Circle :");
    
    
        printf("\n 2.Area of Rectangle :");
    
    
        printf("\n 3.Area of Triangle :");
    
    
        printf("\n 4.EXIT :");
    
    
        printf("\n Enter Your Choice :");
    
    
        scanf("%d",&choice);
    
    
    
    
    
    
    
        switch(choice)
    
    
          {
    
    
                    case 1:
    
    
                      clrscr();
    
    
                      printf("\n Enter Radius of Circle :");
    
    
                      scanf("%f",&rad);
    
    
                      ar=pie*rad*rad;
    
    
                      printf("\n Area of Circle : %f",ar);
    
    
                      break;
    
    
                    case 2:
    
    
                      clrscr();
    
    
                      printf("\n Enter Length : ");
    
    
                      scanf("%f",&l);
    
    
                      printf("\n Enter Breadth : ");
    
    
                      scanf("%f",&b);
    
    
                      ar=l*b;
    
    
                      printf("\n Area of Rectangle : %f",ar);
    
    
                      break;
    
    
                    case 3:
    
    
                      clrscr();
    
    
                      printf("\n Enter side 1 : ");
    
    
                      scanf("%f",&s1);
    
    
                      printf("\n Enter side 2 :");
    
    
                      scanf("%f",&s2);
    
    
                      printf("\n Enter side 3 :");
    
    
                      scanf("%f",&s3);
    
    
                      s=(s1+s2+s3)/3;
    
    
                      p=s*(s-s1)*(s-s2)*(s-s3);
    
    
    
                      printf("\n Area of Triangle : %f",at);
    
    
                      break;
    
    
                    case 4:
    
    
                      exit(0);
    
    
                    default:
    
    
                      printf("Please Enter a Valid Choice [1-4] :");
    
    
          }
    
    
    
    
    
    
    
                      scanf("%c",&ch);
    
    
        }while(ch!='N');
    
    
         getch();
    
    
    
    
    
    
    
          }
        char userId[10],passwrd[10];
        char uoid[] = "Zaid",opasswrd[] = "Vodka123";
        int chances = 3;
    
    
    
        while (chances)
        {
            printf("Enter User ID -> ");
            scanf("%s", userId);
            printf("\n");
            printf("Enter Your Password -> ");
            scanf("%s", passwrd);
    
    
            if (strcmp(uoid, userId) == 0 && strcmp(passwrd, opasswrd) == 0)
            {
                printf("Correct User Id And Password\n");
                break;
            }
            else
            {
                printf("Invalid User Id And Password\n\n");
                chances--;
    
                if(!chances)
                {
                    printf("You have no more chances...\n");
                    printf("Do you want to register y/n -> ");
    
    
                    printf("\n");
    
    
    
                    {
                        printf("Enter your new ID -> ");
                        scanf("%s",uoid);
                        printf("Enter your new PW -> ");
                        scanf("%s",opasswrd);
    
                        chances = 3;
                    }
                }
            }
        }
    
    
        clrscr();
    
    
    
    
    
    
    
    
    
    
        char choice;
        char c[50];
        char id[50];
        char age[50];
        char last[100];
        char first[100];
        char dep[50];
        char add[50];
    
    
     b:
        clrscr();
        printf("=====PROGRAM MENU=====");
        printf("\n\n[1] = CIRCLE AREA");
        printf("\n[2] = RECTANGLE AREA");
        printf("\n[3] = TRIANGLE AREA");
        printf("\n[4] = LAST GRADE");
        printf("\n[5] = LETTER GRADE");
        printf("\n[6] = FACTORIAL");
        printf("\n[7] = PRINTING");
       printf("\n[8] = Exit Program");
        printf("\n\nChoice : ");
        scanf("%d",&choice);
        switch (choice)
        {
        case 1:
            clrscr();
            FILE * f;
    
    
            f=fopen("test.txt","r+");
            if(f==NULL){
                printf("No Database");
                exit(1);
     }
     }
        getch();
     }
    Last edited by Zaid Mashni; 05-15-2016 at 05:04 AM.

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    With what do you need help with? What does it do that you don't want it to? Or, what doesn't it do that you do want it to?

    Also, could you please fix the indentation? It added a bunch of extra empty lines for some reason.

    This seems to be entirely a C program, not C++. Just saiyan...
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    May 2016
    Posts
    4
    all I need is help in lines 440 - 446 for calculate grades I don't know how

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    As GReaper said, fix your formatting and indentation so your code is easier (for us and yourself) to read.

    Quote Originally Posted by Zaid Mashni View Post
    all I need is help in lines 440 - 446 for calculate grades I don't know how
    In the code you posted, lines 440 - 446 correspond to a menu, there are no calculations taking place there. You really need to be sure your question is clear and correctly stated if you want people to take time out to help you.

    Additionally, this code will not even compile, as there is code present outside of any function.

    You really need to put in some effort when seeking help from forums such as these.

    How To Ask Questions The Smart Way



    What material are you using to learn C++? The only C++-specific code I see is the iostream include.

    • If you're learning C++, why the C headers and C-specific functions?
    • conio.h is a non-standard (and outdated) header.
    • Avoid using global variables - pass values to, and receive values from, functions instead.
    • Don't use "goto". I don't see "goto" in your code, but I see a random label on line 437 that indicates you may have been using this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu program help
    By Andrew Gaupp in forum C++ Programming
    Replies: 1
    Last Post: 01-03-2014, 09:33 PM
  2. Menu program.
    By Andrew Gaupp in forum C++ Programming
    Replies: 2
    Last Post: 08-20-2013, 07:08 AM
  3. Help with menu program
    By leroyjenkens in forum C Programming
    Replies: 1
    Last Post: 06-15-2012, 03:21 PM
  4. Need big help with a menu program
    By angelofmyst in forum C Programming
    Replies: 7
    Last Post: 12-18-2010, 07:34 PM
  5. Menu program
    By DerrickakaDRoC in forum C Programming
    Replies: 7
    Last Post: 12-12-2010, 05:09 PM

Tags for this Thread