C++ search an array for an element 🔎

Поділитися
Вставка
  • Опубліковано 5 лют 2025
  • #array #search #element
    C++ linear search tutorial example explained

КОМЕНТАРІ • 21

  • @BroCodez
    @BroCodez  2 роки тому +13

    #include
    int searchArray(std::string array[], int size, std::string element);
    int main()
    {
    std::string foods[] = {"pizza", "hamburger", "hotdog"};
    int size = sizeof(foods)/sizeof(foods[0]);
    int index;
    std::string myFood;
    std::cout

  • @criminalx7099
    @criminalx7099 2 роки тому +5

    well explained bro

  • @artemzakharchuk2842
    @artemzakharchuk2842 Рік тому +1

    Great explanation,brooooooooo)

  • @lue224
    @lue224 2 роки тому +1

    A Multiplatform GUI with c++ tutorial would be really cool. For example, the qt framework

  • @hupmitom5509
    @hupmitom5509 Рік тому

    very nice

  • @Yousif_Maksabo
    @Yousif_Maksabo 6 місяців тому +3

    My Assignment:
    #include
    double average(double grades[], int numGrades);
    int main () {
    double grades[] = {93,100,98,100,100,100};
    int numGrades = sizeof(grades)/sizeof(grades[0]);
    double averageGrade = average(grades, numGrades);

    std::cout

  • @maxwong1768
    @maxwong1768 5 місяців тому

    Search for existence and index of a specific element in array of any data type
    template
    int SearchArr(T arr[], int arrSize, T targ){
    for (int i = 0 ; i

  • @MainulHossainAnik
    @MainulHossainAnik 5 днів тому +1

    🔥🔥❤❤DONE🔥🔥❤❤

  • @iteaahorma
    @iteaahorma Місяць тому

    ❤❤🎉🎉🎉

  • @miumiu124
    @miumiu124 7 місяців тому

    What if I want a -1 in my array?

    • @eternity-dh
      @eternity-dh 7 місяців тому

      Return another number or a text

    • @quartzisgames1496
      @quartzisgames1496 2 місяці тому

      It doesn't matter since the int returned is actually the index of your number. -1 could be the 6th integer but nver the -1st integer, that doesn't make sense

  • @iteaahorma
    @iteaahorma Місяць тому

    If you can use this in program example user searching any this ??

  • @Boogie-wi7hd
    @Boogie-wi7hd Рік тому +2

    not working for me :(

    • @studysti9232
      @studysti9232 11 місяців тому +1

      Hey, make sure your index = searchArray(numbers, size, myNum); line comes AFTER your user input prompt. I had this issue. I hope it solves yours.

    • @jonnyaiello6930
      @jonnyaiello6930 3 місяці тому

      Use libraries

  • @Dazza_Doo
    @Dazza_Doo 2 роки тому

    sizeof(a) //
    typeid(a) // #include