Question

In: Computer Science

SWITCH CASE, WHILE, DO WHILE STRUCTURES Implement the following programs, attach a flow chart, and photos...

SWITCH CASE, WHILE, DO WHILE STRUCTURES

Implement the following programs, attach a flow chart, and photos of its operation.
1. Read a number that represents the month and say what months it is.
2. Using the conditional "while" calculate the factorial of a number
3. Using the “do-while” conditional, make a program that prints all numbers from 1 up to a maximum number entered by the user.

Solutions

Expert Solution

PROGRAM 1:

#include <stdio.h>
int main()
{
   int mon_num;
   printf("Input Month No : ");
   scanf("%d",&mon_num);
   switch(mon_num)
   {
        case 1:
               printf("January\n");
               break;
        case 2:
               printf("February\n");
               break;
        case 3:
               printf("March\n");
               break;
        case 4:
               printf("April\n");
               break;
        case 5:
               printf("May\n");
               break;
        case 6:
               printf("June\n");
               break;
        case 7:
               printf("July\n");
               break;
        case 8:
               printf("August\n");
               break;
        case 9:
               printf("September\n");
               break;
        case 10:
               printf("October\n");
               break;
        case 11:
               printf("November\n");
               break;
        case 12:
               printf("December\n");
               break;
        default:
               printf("invalid Month number. \nPlease try again ....\n");
               break;
      }
      return 0;
}

OUTPUT:

FLOWCHART:

PROGRAM 2:

#include <iostream>
using namespace std;

int main() {
        int num;
        cout<<"\n ENTER A NUMBER:";
        cin>>num;
        int fact = 1;
        while(num>1)
        {
            fact=fact*num;
            num--;
        }
        cout<<"\nFACTORIAL = "<<fact;
        return 0;
}

OUTPUT:

FLOWCHART:

PROGRAM 3:

#include <iostream>
using namespace std;

int main() {
        int n;
        cout<<"\nEnter how many numbers you want to enter:";
        cin>>n;
        int arr[n];
        
        int max = -99999;
        int i = 0;
        do{
            cout<<"\nENTER NUMBER "<<i+1<<" :";
            cin>>arr[i];
            if(arr[i] > max)
            {
                max=arr[i];
            }
            i++;
        }while(i!=n);
        cout<<"\nLarger numbber = "<<max;;
        return 0;
}

OUTPUT:

FLOWCHART

DON'T FORGET TO GIVE A LIKE


Related Solutions

SWITCH CASE, WHILE, DO WHILE STRUCTURES, using ARDUINO. Urgent Please! Implement the following programs, attach a...
SWITCH CASE, WHILE, DO WHILE STRUCTURES, using ARDUINO. Urgent Please! Implement the following programs, attach a flow chart, and photos of its operation. 1. Read a number that represents the month and say what months it is. 2. Using the conditional "while" calculate the factorial of a number 3. Using the “do-while” conditional, make a program that prints all numbers from 1 up to a maximum number entered by the user.
The following is a set of tree-set test programs that show the following outputs: Switch to...
The following is a set of tree-set test programs that show the following outputs: Switch to ArrayList, LinkedList, Vector, TreeMap, and HashMap to display similar output results. Results: Tree set example! Treeset data: 12 34 45 63 Treeset Size: 4 First data: 12 Last Data: 63 Removing data from a tree set Current tree set elements: 12 34 63 Current tree set size :3 Tree set empty. Example code import java.util.Iterator; import java.util.TreeSet; public class TreeDemo2 { public static void...
Explain why dyes attach to natural fibers more readily than synthetic fibers. How do the structures relate?
Explain why dyes attach to natural fibers more readily than synthetic fibers. How do the structures relate?
write the PsuedoCode and the flow chart of the following: 1. draw a deck of cards...
write the PsuedoCode and the flow chart of the following: 1. draw a deck of cards from a standard deck of 52 cards until the queen of hearts is draw. how many cards did you draw?
Implement Heap Sort and Quick Sort in different programs with the following specifications: 1. The input...
Implement Heap Sort and Quick Sort in different programs with the following specifications: 1. The input to the programs should be ASCII characters 2. Your program should be able to handle upper and lower case letters both 3. The sort should be done in a descending manner 4.Note: Please use array-based representation for these sorting algorithms Please write comment n explain each step clearly as well your program should show what you are taking as input array and what your...
Refer to the following contingency chart comparing 3 college programs (criminal justice, business, culinary) with the...
Refer to the following contingency chart comparing 3 college programs (criminal justice, business, culinary) with the GPA of students graduating from those programs at a college.                                             2.0-2.5            2.5-3.0            3.0-3.5               3.5-4.0 criminal justice                     23                    18                     32                       47 business                               17                     26                    36                        31 culinary                                 28                     17                    41                       28 A. What is the overall total number of students in this contingency table? B. What is the observed value for business students with a GPA of 3.0-3.5? C. What is the expected value for criminal justice...
Why do we need to increase the flow rate of air-acetylene flame when we switch over...
Why do we need to increase the flow rate of air-acetylene flame when we switch over to nitrous oxide flame in AAS?
Make a flow chart of the purification scheme for the following scenario. 7. Benzaldehyde is used...
Make a flow chart of the purification scheme for the following scenario. 7. Benzaldehyde is used as the starting material for the synthesis of cinnamic acid. An organic chemistrystudent had made the mistake of stopping the reaction before it was complete and ended up with a mixture ofbenzaldehyde and cinnamic acid. Purify the cinnamic acid. Provide data to show your compound is pure.
Do the following lab by while or Do-while loop. question: Write a c++ program that asks...
Do the following lab by while or Do-while loop. question: Write a c++ program that asks students to enter 3 valid grades and then calculate the average and print it. if the user enters the invalid grade you should print the error message and get the new grade. Hint1: each time your program ask the following question: "Do you want to calculate another average?" and if the answer to this question is "Y" or "y" then you should continue. Hint2:...
Construct a flow chart for the following organisms listed below with all possible gram positive and...
Construct a flow chart for the following organisms listed below with all possible gram positive and gram negative unknowns using the biochemical test  of PR Glucose, PR Sucrose and PR Lactose, PEA P/G  Methyl red, Catalase, Oxidase, Citrate, EMB test, Mac Conkey Agar, Blood Agar etc. Following Organisms : Gram Negative-Cocci: N.sicca, B. cattarhalis Gram Negative Bacillus: E. coli, S. liquefaciens, E. aerogenes, C. fruendii, E. cloacae, P. stuartii, A. faecalis Gram Positive-Cocci M. luteus, S. epidermidis, M. roseus, Gram Positive Bacillus:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT