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

#include <stdio.h> int sum(int n); //prototype int main() {     int number, result;     printf("Enter a positive integer:...
#include <stdio.h> int sum(int n); //prototype int main() {     int number, result;     printf("Enter a positive integer: ");     scanf("%d", &number);     result = sum(number);     printf("sum = %d", result);     return 0; } int sum(int n) {     if (n != 0)         return n + sum(n-1);     else         return n; } What does the code above do?
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;   ...
What’s the output of following code fragment: #include<stdio.h> #include<signal.h> void response (int sig_no) { printf("25"); }...
What’s the output of following code fragment: #include<stdio.h> #include<signal.h> void response (int sig_no) { printf("25"); } void response2 (int sig_no) { printf("43"); }     int main() {      int id = getpid();      signal(SIGUSR1, response); signal(SIGKILL, response2); for(int i=0; i<4; i++) { sleep(1); if (i % 3 == 0) { kill(id, SIGUSR1); } else { kill(id, SIGKILL); } } return 0; }
#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); }
Please comment, exactly how this program works? #include <stdio.h> int main() { int i,j; int a[1000];...
Please comment, exactly how this program works? #include <stdio.h> int main() { int i,j; int a[1000]; for(i=0;i<1000;i++) a[i]=1;    for(i=2;i<1000;i++) { if(a[i]==1){ for(j=i+1;j<1000;j++) {if(j%(i)==0) a[j]=0; } } } printf("print numbers are:\n"); for(i=2;i<=1000;i++) if(a[i]==1) printf("%d, ",i); }
#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...
What is the output of the following C program? #include<stdio.h> int fac (int x); void main(...
What is the output of the following C program? #include<stdio.h> int fac (int x); void main( ) {                         for (int i=1; i<=2; i++)                                     printf("%d", fac(i)); } int fac(int x) {                         x = (x>1) ? x + fac(x-1) : 100);                         return x; }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT