In: Computer Science
Can you please write a pseudocode for the following:
#include <stdio.h>
int main(){
printf("Welcome to my Command-Line Calculator
(CLC)\n");
printf("Developer: Your name will come here\n");
printf("Version: 1\n");
printf("Date: Development data Will come
here\n");
printf("----------------------------------------------------------\n\n");
//choice stores users input
char choice;
//to store numbers
int val1,val2;
//to store operator
char operation;
//flag which leths the loop iterate
//the loop will break once the flag is set to 0
int flag=1;
printf("Select one of the following items: \n");
printf("B) - Binary Mathematical Operations, such as
addition and subtraction.\n");
printf("U) - Unary Mathematical operations, such as
square root, and log.\n");
printf("A) - Advances Mathematical Operations, using
variables, arrays.\n");
printf("V) - Define variables and assign them
values.\n");
printf("E) - Exit\n");
//taking user input for choice
scanf(" %c",&choice);
//do while loop
do{
//switch case
switch(choice){
case 'B':
printf("Please
enter the first number:\n");
scanf("%d",&val1);
printf("Please
enter the operation (+ , - , * , / ):\n");
scanf("
%c",&operation);
printf("Please
enter the second number:\n");
scanf("%d",&val2);
switch
(operation){
case '+':
printf("The result is %d
\n",(val1+val2));
break;
case '-':
printf("The result is %d
\n",(val1-val2));
break;
case '*':
printf("The result is %d
\n",(val1*val2));
break;
case '/':
printf("The result is %d
\n",(val1/val2));
break;
//if any other input is entered
default:
printf("Invalid
operator\n");
}
//asking the
user for input as the operation ended
printf("Please
select your option ( B , U , A , E , V)\n");
scanf("
%c",&choice);
break;
case 'U':
printf("Sorry,
at this time I don't have enough knowledge to serve you in this
category\n");
//asking the
user for input as the operation ended
printf("Please
select your option ( B , U , A , E , V)\n");
scanf("
%c",&choice);
break;
case 'A':
printf("Sorry,
at this time I don't have enough knowledge to serve you in this
category\n");
//asking the
user for input as the operation ended
printf("Please
select your option ( B , U , A , E , V)\n");
scanf("
%c",&choice);
break;
case 'V':
printf("Sorry,
at this time I don't have enough knowledge to serve you in this
category\n");
//asking the
user for input as the operation ended
printf("Please
select your option ( B , U , A , E , V)\n");
scanf("
%c",&choice);
break;
case 'E':
//if user enters
E flag is set to 0, so that the loop will break
flag=0;
printf("Thanks
for using my Simple Calculator. Hope o see you soon again,
Goodbye!\n");
break;
default:
printf("Invalid
input");
printf("Please
select your option ( B , U , A , E , V)\n");
scanf("
%c",&choice);
}
}while(flag);
}
PseudoCode:
PseudoCode is an artificial and informal language that helps programmers develop algorithms.It is a "text-based" detail design tool.It is intended for human reading rather than machine.
PseudoCode for the given program is: