C Program#179 – To Develop an Area Calculator using if-elseif.

Program to Develop an Area Calculator using if-elseif.:

Program Logic :

  • First, Display a Menu System with Menu Options [C] – Circle , [R] – Rectangle , [T] – Triangle for Input of choice in char data type variable.
  • Test input using test condition – if(ch==’C’ || ch==’c’), else if( ch==’R’ || ch==’r’), else if ( ch==’R’ || ch==’r’) for Validation of Input, if ok/TRUE, then proceed to take related input such as Radius in case of Circle, Length & Breadth in case of Rectangle and Side1, Side2 and Side3 for Triangle (Heron’s Formula).
  • At-last, Calculate Area using corresponding Formula.
  • Still not understood ? See the proper working example in action below.

Full Well Commented, Self-Explanatory Example Program of the same given below.

Below Here are Six (6) different Outputs of the program.

Output of the Program (Run 1 ):

Output of the Program (Run 2 ):

Output of the Program (Run 3 ):

Output of the Program (Run 4 ):