Question

In: Computer Science

Can you please write a pseudocode for the following: #include <stdio.h> int main(){    printf("Welcome to...

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);
  
  
}

Solutions

Expert Solution

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:


Related Solutions

CODE A #include<stdio.h> #include<math.h> #include<stdlib.h> #define PI 3.14159265358979323846 int main(){ int diameter; printf("Enter value of diameter...
CODE A #include<stdio.h> #include<math.h> #include<stdlib.h> #define PI 3.14159265358979323846 int main(){ int diameter; printf("Enter value of diameter between 8 to 60 inches: "); scanf("%d",&diameter); // if(diameter>60 || diameter<=8){ // printf("Error! invalid input"); // exit(0); // } // else{ // float radius = diameter/2; // float volume = (4/3)*PI*radius*radius*radius; // printf("%.2f",volume); // } //check through the while loop if it is valid or in valid while(diameter>60 || diameter<=8){ printf("Invalid input Enter again: "); scanf("%d",&diameter); }    //caluclate the volume of sphere float...
#include <stdio.h> int main() { int i, j; printf("Enter two positive integers: "); scanf("%d%d", &i, &j);...
#include <stdio.h> int main() { int i, j; printf("Enter two positive integers: "); scanf("%d%d", &i, &j); // need to validate both being positive while (i != j) { i > j ? (i -= j) : (j -= i); } printf("GCD: %d\n", i); return 0; } The above code returns a GCD from two numbers entered. Use the above program to design a C program to compute of integer coefficients a and b such that gcd(i, j) = a xi...
Can anyone translate this to flowgorith. #include<stdio.h> int main()    {    int seatingChart[10];       //array...
Can anyone translate this to flowgorith. #include<stdio.h> int main()    {    int seatingChart[10];       //array for seating chart       int fc = 0, ec = 5,i;       //starting positions for first class and economy class       printf("Welcome to the Airline Reservation System (ARS)\n\n");       for(i=0;i<10;i++)       //initializing the array with zero        {        seatingChart[i] = 0;        }    char choice;       do        {        int ch;   ...
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x...
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x = 3;     i = fun(x);     printf("%d\n", i);     return 0; } int fun(int i) {      int res = 0;      res = pow (i , 3.0);      return ( res); }
#include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { int count; if ((argc...
#include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { int count; if ((argc != 2) || (sscanf(argv[1],"%d",&count) != 1)) { fprintf(stderr,"Usage: %s <integer>\n", argv[0]); exit(1); } pid_t pid1, pid2; while (count > 0) { pid1 = fork(); if (pid1 > 0) { pid2 = fork(); count = count - 2; } else if (pid1 == 0) { count = count - 1; } } exit(0); } Question #1 [2 pts] If the command-line argument passed to this...
Please implement the 5 questions in source code: #include <stdio.h> #include <stdlib.h> #include <math.h> int main(...
Please implement the 5 questions in source code: #include <stdio.h> #include <stdlib.h> #include <math.h> int main( int argc, char* argv[] ) { // Size of vectors int n = 10000; // Input vectors double *restrict a; double *restrict b; // Output vector double *restrict c; // Size, in bytes, of each vector size_t bytes = n*sizeof(double); /* Q1: Allocate memory for vector a (10 points)*/ /* Q2: Allocate memory for vector b (10 points)*/ /* Q3: Allocate memory for vector...
Please convert the following C program into the RISC-V assembly code 1) #include <stdio.h> int main()...
Please convert the following C program into the RISC-V assembly code 1) #include <stdio.h> int main() { int i = 2, j = 2 + i, k; k = i * j; printf("%d\n", k + j); return 0; } 2) #include <stdio.h> int main() { int i = 2, j = 2 + i, k = j / 2; if (k == 1) { printf("%d\n", j) k = k * 2; if ( k == j) { printf("%d\n|, j); }...
#include<stdio.h> #include<stdlib.h> int main() {     //Q1) Note: You can use only pointer based operations while...
#include<stdio.h> #include<stdlib.h> int main() {     //Q1) Note: You can use only pointer based operations while implementing each of the functionalities below    // zero points will be given if pointer operations are not used in implementing    // each of the operations below.    // Also, use C code only in visual studio or GCC in general.asu.edu server    /* i.) Create a 2 - D array of integers using pointers (use dynamic memory allocation).            Assume that...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc, char *argv[]) {     FILE *myFile;...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc, char *argv[]) {     FILE *myFile;     char fname[20];     //int sum = 0;     int i, j, k, tmp =0;     int num = 0;     int mass = 0;     int count = 0;     int fuel = 0;     int total = 0;     int M[1000];     char ch;     char buffer[32];     printf(" Input the filename to be opened : ");     scanf("%s",fname);     myFile = fopen(fname, "r");     if(myFile == NULL)     {         printf("Can't open file\n");     } while(1)     {         ch =...
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number;...
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number; Scanf (“%d”, & number); if (number % 2 ==0) { printf (“Even\n”); } else { printf(“Odd\n”); } Return 0; }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT