Can we pass direct values in the function without using myarr[] if yes then how ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can we pass direct values in the function without using myarr[] if yes then how ?

void printArray(int arr[], int size) { for(int x=0; x<size; x++) { cout <<arr[x]<< endl; } } int main() { int myArr[3]= {42, 33, 88}; printArray(myArr, 3); }

16th Mar 2017, 5:34 AM
Saiyyed aman ali
Saiyyed aman ali - avatar
1 Answer
0
You could just declare a lot of arguments type int or something for the function, but often that's just waste of time and you are more likely to get lost with all the variables.
20th Mar 2017, 1:56 AM
Jan Kliszcz
Jan Kliszcz - avatar