C Programming Tutorial - 55: Passing Arrays To Functions

preview_player
Показать описание
In this tutorial we will see how we can pass an array as an argument to a function. Pretty simple it is!

I hope you guys enjoy watching the video.
Рекомендации по теме
Комментарии
Автор

I could not figure out why void func(int arr[], int val);" shown as "func(array, power);" and then "void func(int arr[], int val)". The power in function became int val is difficult to connect.

manamahalo
Автор

can you please explain y have wrote pow(arr[i], val) in the function...how is it different from arr[i], val?

rakeshk
Автор

thank you so much! you are really good at teaching! better thn our professor!!

ruifangzhang
Автор

thank u sir for help .my basic concept are almost clear

kajalpisal
Автор

I actually answered myself. Every math function returns a double, so it MUST be %f in order to work :)

nikolaygeorgiev
Автор

Can you tell me why we wrote i+1 in the printf statement ?

kartikaykumar
Автор

I understood the program however I don't understand why the last row has %f, and there is no floating point number declared anywhere. Furthermore the program works with %f but if I change it to %d it doesn't work. Can you explain this please, thank you. Awesome tutorials btw!!

nikolaygeorgiev
Автор

what I do when we do not know the size of array i.e. the size of array in func function

divakarverma
Автор

I did not get why you declared int val?

oggy
Автор

nice video sir :).can you Please tell me how to copy array elements to a circular FIFO

vigneshbalaji
Автор

OR, in normal c++:


#include <iostream>
#include <cmath>
#include <string>

using namespace std;

void function(int array[], int val);

main ()
{

int array[5] = {2, 4, 5, 6, 7};
int power;

cout << endl << "Enter ^power: " << endl;
cin >> power;

function(array, power); //call
cout << endl;

return 0;
}

void function(int array[], int power)
{

for (int i = 0; i < 5; i++)
{

cout << "Position = " << i+1 << " Value = " << pow(array[i], power) << endl;

}

}

ulyssespicazo
Автор

I request to you please get subttiltle removed

more_shot
Автор

it would look simpler if you define the function before the main..

soumithpotturi
welcome to shbcf.ru