@BroCodez

#include<iostream>

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 << "Enter element to search for: " << '\n';
    std::getline(std::cin, myFood);

    index = searchArray(foods, size, myFood);

    if(index != -1){
        std::cout << myFood << " is at index " << index;
    }
    else{
        std::cout << myFood << " is not in the array";
    }

    return 0;
}
int searchArray(std::string array[], int size, std::string element){

    for(int i = 0; i < size; i++){
        if(array[i] == element){
            return i;
        }
    }
    return -1;
}

@lue224

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

@criminalx7099

well explained bro

@artemzakharchuk2842

Great explanation,brooooooooo)

@Yousif_Maksabo

My Assignment:

#include <iostream>

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 << "Average Grade: " << averageGrade << "\n";

    return 0;
}


double average(double grades[],int numGrades) {
double averageGrade;
double total=0;    
    for (int i = 0; i < numGrades; i++){
        total += grades[i];
    } 
    averageGrade = total/numGrades;

    return averageGrade;
}

@maxwong1768

Search for existence and index of a specific element in array of any data type

template <typename T>
int SearchArr(T arr[], int arrSize, T targ){
    for (int i = 0 ; i <= arrSize-1 ; i++){
        if (arr[i] == targ){
            return i;
        }
    }
    return -1;
}

@hupmitom5509

very nice

@MainulHossainAnik

πŸ”₯πŸ”₯❀❀DONEπŸ”₯πŸ”₯❀❀

@iteaahorma

β€β€πŸŽ‰πŸŽ‰πŸŽ‰

@miumiu124

What if I want a -1 in my array?

@iteaahorma

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

@Boogie-wi7hd

not working for me :(

@Dazza_Doo

sizeof(a)   // 
typeid(a) // #include <typeinfo>