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...
Linked List Course Outcome: CLO3    Build computer programs to implement appropriate data structures for solving computing...
Linked List Course Outcome: CLO3    Build computer programs to implement appropriate data structures for solving computing problems in a time frame given. (P3, PLO3) Task Write a complete program by applying linked list data structure that will perform the following operation on any records: Add record Delete record View record Find record Your program also should be able to display the number of record in the linked list. Put your creativity to produce the program. Your Submission should have the...
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?
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...
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...
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.
use C++ You will implement the following encryption and decryption functions/programs for the Caesar cipher. Provide...
use C++ You will implement the following encryption and decryption functions/programs for the Caesar cipher. Provide the following inputs and outputs for each function/program: EncryptCaesar Two inputs: A string of the plaintext to encrypt A key (a number) ▪ For the Caesar cipher: This will indicate how many characters to shift (e.g. for a key=3, A=>D, B=>E, ..., X=>A, Y=>B, Z=>C). Note that the shift is circular. One output: ◦ A string of the ciphertext or codeword DecryptCaesar Two inputs:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT