Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C++ Programming Help?

So, I'm stuck on these questions. I don't what statement I'm going to use. Help please?

[1] Write a C++ program that accepts 120 input characters. Determine and display the number of digits, vowels, consonants, and special characters.

[2] Write a C++ program that accepts 100 integers using any looping statement. Determine and display the number of even integers that are divisible by 3.

[3] Write a C++ program that generates the first 100 positive integers. Compute and display the sum of all even integers that are divisible by 3.

Update:

ADDED: I only want to know what statements should I use. I don't need the program for it. ONLY THE STATEMENTS.

Update 2:

EDIT: "know" should be added before "what" on the second sentence.

5 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    Even though I dislike doing people's homeworks, I will do 2 and 3 for you, 1 is for yourself. Also no guarantee's as I do not have time to test it, just make it.

    2.

    #include <iostream>

    #include <math.h>

    using namespace std;

    int main()

    {

    int count; //number of even integers divisible by 3

    for (int x = 0; x < 100; x++)

    {

    int currInt; //current integer of the session

    cout << "Enter integer: ";

    cin >> currInt;

    if (currInt % 2 == 0 && currInt % 3 == 0)

    count++;

    }

    cout << "\nThere have been " << count << " number of even integers divisible by 3."

    return 0;

    }

    3. Looks like I dont have enough time to do #3, as I have to leave for work, look at the above example, then learn from it and do #3.

    Source(s): Brain.
  • 1 decade ago

    For most of these, you want to use a for loop to get your number of inputs.

    [1] you want to cast each character entered to int, ie:

    asciival = (int)inputchar

    and compare those to the appropriate ranges from an ascii table

    (digit is 48 to 57, capital letters 65 to 90, lower case 97 to 122, etc). determine what falls into the appropriate range (or specific value for vowels) and add to the correct sum.

    [2] use the modulus operator (%) if input % 2 = 0 and input % 3 = 0, its even and divisible by 3.

    [3] use the for loop to count your control variable up to 100, if it passes the test from question 2, add it to an overall sum.

  • 1 decade ago

    Please, get real. Do you REALLY expect someone to write three programs for you so that YOU can get credit for their work?

    Why not show what you've done so far, and ask for help in completing the task, rather than dump all three homework problems and expect someone to do it for you?

  • 1 decade ago

    LOL funny i got the same questions from my reviewer gave by my prof for my exam xD

  • Anonymous
    1 decade ago

    i have answer for third question u asked:

    #include <stdio.h>

    #include<iostream.h>

    void main()

    {

    int s;

    for(int i=1;i<=100;i++)

    {s+=i;

    }

    cout<<s;

    getchar();

    }

Still have questions? Get your answers by asking now.