What's new

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

Status
Not open for further replies.

Welcome Guest

Eternal Poster
Joined
Nov 29, 2015
Posts
1,000
Reaction
146
Points
509
Age
27
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 ...
 
Last edited:
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.
 
Last edited:
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');
}
 
Last edited:
Status
Not open for further replies.

Similar threads

Back
Top