Write a program to create menu for following operators : a. Arithmetic operator b. Modulo operator c. Relational operator d. Logical operator (switch case)

 




#include<stdio.h>
#include<conio.h>
main()
{
      int a,b,c,choice;
    
      printf("\n 1 arthemetic operater ");
      printf("\n 2 modulo operater ");
      printf("\n 3 relational operater ");
      printf("\n 4 logical operater ");

      printf("\n select an option :");
      scanf("%d",&choice);


      switch (choice)
      {
         case 1 : printf("enter the value of a and b is :");
                  scanf("%d %d",&a,&b);
                  c=a+b;
                  printf("the value of a+b is : %d",c);
                  break;

         case 2 : printf("enter the value of a and b is :");
                  scanf("%d %d",&a,&b);
                  c=a%b;
                  printf("the value of a%b is : %d",c);
                  break;

         case 3 : printf("two no. is a and b is ");
                  scanf("%d%d",&a,&b);
                  if(a>b)       {
                  printf("\n max. = %d",a);
                  printf("\n min. = %d",b);}
                  else  
                  {
                     printf("\n max. = %d",b);
                     printf("\n min. = %d",a); 
                  }
                  break;

         case 4 :   int lower ,upper;
                    char ch;
    
                   printf("enter any character ");
                   scanf(" %c",&ch);

                   lower=(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u');

                   upper=(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U');

                   if ( lower||upper )
                   printf("\nit is a vowel");

                   else
                   printf("\nit is consonent");
                   break;

         default : printf("u choose wrong ");


    }

    
}

output 1 :
1 arthemetic operater 2 modulo operater 3 relational operater 4 logical operater select an option :1 enter the value of a and b is :2 67 the value of a+b is : 69

output 2:
 1 arthemetic operater
 2 modulo operater
 3 relational operater
 4 logical operater
 select an option :2
enter the value of a and b is :2
5
the value of ab is : 2

output 3: 1 arthemetic operater 2 modulo operater 3 relational operater 4 logical operater select an option :3 two no. is a and b is 23 45 max. = 45 min. = 23

output 4:
1 arthemetic operater 2 modulo operater 3 relational operater 4 logical operater select an option :4 enter any character s it is consonent

Comments

Popular Post

Write the definition for a class called complex that has floating point data members for storing real and imaginary parts. The class has the following member functions: void set(float, float) to set the specified value in object void disp() to display complex number object complex sum(complex) to sum two complex numbers & return complex number 1. Write the definitions for each of the above member functions. 2. Write main function to create three complex number objects. Set the value in two objects and call sum() to calculate sum and assign it in third object. Display all complex numbers.

Assume that a bank maintains two kinds of accounts, are called as saving account and current account. The saving account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below the level, a service charge is imposed. Create a class account that stores customer name, account number and type of account. From this derive the classes cur_acct and sav_acct to make them more specific to their requirements. Include necessary member functions in order to achieve the following tasks: a.Include constructor for all the three classes. b.Accept deposit amount from the customer and update the balance. c.Display the balance. d.Compute and deposit interest. e.Permit withdrawal and update the balance. f. Check for minimum balance, impose penalty, necessary and update the balance.