Thursday, November 2, 2017

Number Occurrence in C++

In this article I would like to share with you a sample program that I wrote in C++ a long time ago to count the number of occurrence of the given number by the user.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.


Program Listing


#include <iostream>

using namespace std;


main(void) {
 int items[5];
    int search=0;
    int occur=0,x=0;


    for (int x=0; x<5; x++) {
        cout << "Enter Item No."
            << x+1 << " : ";
        cin >> x[items];
    }

     cout << "\n\n";
     cout <<"Enter Item to search :";
     cin >> search;
    for (x=0; x<5; x++) {
     if (search == x[items]) {
         occur++;

     }

    }
 cout << "\n\n";
     cout << "Number occurence of is "
         << occur << ".";




     if (search != x[items]) {
         cout << "Not Found in the List.";

     }


     cout << "\n\n";
     system("pause");
}

No comments:

Post a Comment