🔒 Closed C++ Array Help po please rush mga master huhu

Status
Not open for further replies.

Welcome Guest

Established
Mga ka ts, pa help ako d ko talaga alam paano to. E sa submitt ko na mamaya need your help please

Question 1: C++ Write a program that lets the user input a word(any length) then changes all the vowels into 'o' . Ask if the user wants to retry the program or not (loop)
Input: Array
Output: Orroy

Question 2: C++ Write a program that lets the user input how many numbers/digits he wants to enter then enters a random numbers... Then calculates the average. Ask if the user wants to retry the program or not (loop)

Input:
Enter how many numbers: 8
Enter numbers: 2 3 4 8 9 10 15 17

Output:
Average is : 8.5

Using array po lahat ng problem ...
 
Simple:
Question 1.
C++:
#include <iostream>

int main(void) {
    std::cout << "Program that replaces the vowel character into 'o'\n" << std::endl;
    std::cout << "Enter input: ";
    std::string my_input;
    std::cin >> my_input;

    for (char &c : my_input) {
        switch (c) {
            case 'A':
            case 'E':
            case 'I':
            case 'U': {
                c='O';
                break;
            }
            case 'a':
            case 'e':
            case 'i':
            case 'u': {
                c='o';
                break;
            }
            default: {
                break;
            }
        }
        std::cout << c;
    }
    std::cout << "\n" << std::endl;

    return 0;
}

Ikaw na bahala sa question 2 at baka ako pa bigyan ng grades ng prof mo.
 
eto paps pa try nalang

Problem #1

C++:
#include<iostream>
using namespace std;
//Method to determine if the character is vowel or not
bool isVowel(char c){
    switch(tolower(c)){
        case 'a': case 'e': case 'i': case 'o': case 'u':
            return true;
    }
    return false;
}
int main(void){
    //Initialize the choice
    char choice = 'n';
    do {
    cout<<"Input: ";
    string input; cin>>input;
    cout<<"Output: ";
        for(int i = 0; i < input.length(); i++){
            char c = input[i];
            if(isVowel(c))
                cout<<"o";
            else
                cout<<c;
        }
        cout<<endl;
        cout<<"Do you want to continue? (Y/N): ";
        cin>>choice;
    }while(choice == 'y' || choice == 'Y');
}

Probelm #2
C++:
#include<iostream>
using namespace std;
int main(void){
    //Initialize the continue choice
    char choice = 'n';
    do {
    double sum = 0;
    cout<<"Enter how many numbers: ";
    int count; cin>>count;
    int numberArr[count];
    //get the numbers and get the sum at the same time
    cout<<"Enter numbers: ";
    for(int i = 0; i < count; i++){
    cin>>numberArr[i];
    sum += numberArr[i];
    }
    //Output the average in float form
    cout<<"Output: ";
    cout<<"Average: "<<(float)sum / count;
        cout<<endl;
    //Determine if user desire to continue
        cout<<"Do you want to continue? (Y/N): ";
        cin>>choice;
    }while(choice == 'y' || choice == 'Y');
}
 
Status
Not open for further replies.

About this Thread

  • 2
    Replies
  • 574
    Views
  • 3
    Participants
Last reply from:
Arcturus

Trending Topics

Online now

Members online
949
Guests online
1,073
Total visitors
2,022

Forum statistics

Threads
2,273,869
Posts
28,952,155
Members
1,234,981
Latest member
AprilSiading
Back
Top