Passing Array as an Argument to a Function

preview_player
Показать описание
C Programming: Passing the Array Name as an Argument to a Function in C Programming.
Topic discussed:
1) C program to demonstrate how an array is passed as an argument to a function.

Music:
Axol x Alex Skrindo - You [NCS Release]

#CProgrammingByNeso #CProgramming #Pointers #ArrayAsArgument #PointersInC
Рекомендации по теме
Комментарии
Автор

Sir, you are the best! I like how slowly and clearly you explain the codes.

mabenyjohnson
Автор

tip 2: But we cannot perform the operation b++ in the function add(). In the add function, if the parameter b is declared as int b[], you cannot perform pointer arithmetic operations like b++ directly on the array parameter itself. This is because, in the function signature int add(int b[], int len), b is treated as a pointer to the first element of the array, and not as an actual array.

If you need to perform pointer arithmetic or modify the pointer itself within the function, you should declare the parameter as int *b instead. This allows you to manipulate the pointer b using operations like b++, b+1, etc., which would not be possible if b is declared as int b[].

Aabara_ka_dabara
Автор

This is by far the most concise and precise mind blowing answer.
(blows away all clouds of doubts in arrays..) Searched the whole youtube couldn't find one like yours!
Godbless you !!!

RandomBoy_o
Автор

tip: when you define a function parameter as an array, like int b[], it is treated as a pointer to the first element of the array. So, int b[] and int *b in the function definition are interchangeable.

Aabara_ka_dabara
Автор

This academy make the perfect vedio on every topic not wasting the time even for a moments

funnyanimation
Автор

thank you for keeping it short, it was exactly what I needed

ayushroy
Автор

usually i dont comment, but the effort and the way your explaining is OP . lots of love and I wish you have a beatufil and lovely life with all the blessings of your family(subscribers)😍

achiever
Автор

Thank you so much sir.
I had confusion in this topic since a while but now you cleared my head out of confusion.

SadiqKhan-rfoy
Автор

Thanks for the video . It's Soo easy ❤️❤️

shivp
Автор

Thank u so much sir
Mujhe y concept samajh nhi aa raha tha but ab aa gya

ayushipriya
Автор

awsm explanation on the topic its such a complex topic but we all got it

prajwal_bagewadi
Автор

Sir your video are nice and to the point

KGLEGENDS
Автор

int add(int b[], int len)

above is same as below

int add(int *b, int len)

chamahge
Автор

How can we declare (int b[], int len) in the main function and how we write anything in the barces

gunashankar
Автор

Why doesn't a have an * or & associated with it, also why don;t you declare a pointer variable? thanks

Ray-ejjb
Автор

This video does not support subtitles. How do I turn it on?

worldshello
Автор

Sir, Could you please make a tutorial on javascript, Thank you!

SadiqKhan-rfoy
Автор

0:59 - You said you didn't pass the whole array to b but only the base address. This is because "a" actually stores the base address of the array.
But what if we need to pass the whole array? How do we do that? How do we pass the whole of array?

nSackStyles
Автор

// passing array as argument and receive as pointer
#include <iostream>
using namespace std;
int add(int *a, int len)
{
int sum=0;
for(int *q=a;q<a+len;q++)
sum+=*q;
return sum;
}
int main() {
int a[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int len=sizeof(a)/sizeof(a[0]);
cout<<"sum : "<<add(a, len);
return 0;
}

mr.knight
Автор

Sir can u plz upload same course for C++ as well

rudrasingh