Hi harry, I am 3 years late to find you on youtube. I am preparing for competitive exams. Your teaching language is straightforward I can understand every word in your videos. anyway, today I accepted you as my programming teacher.
/*Author: Md Shoaib Purpose: Quiz(Given two numbers a and b, add them then subtract them to a and b using call by reference.) Date: 09/07/2019 */ #include //fuction(Call by reference) for add or subtract void addSub(int *a1, int *b1) { int temp; temp = *a1; *a1 = *a1 + *b1; *b1 = temp - *b1; return; } int main() { //variable declaration int a = 8, b = 6; //print to user printf("Before running the function, the value of a = %d and value of b = %d ", a, b); //function call for change the values addSub(&a, &b); //after using function print to user printf("After running the function, the value of a = %d and value of b = %d ", a, b); return 0; }
Harry bro ans. of your challenge, I am late but not wrong #include int change(int *a,int *b) { *a=*a+*b,*b=*a-*b*2; } int main() {int x=10,y=7; printf("two values %d %d ",x,y); change(&x,&y); printf("%d %d",x,y); }
Actually you are wrong you are changing the value of a before b so when you perform b=b-a it will minus the updated value of a not previous value of a edit(to solve this you need to store a's value in temp variable and then you have to perform b=b-temp. Hope you got this)
Harry bhai you are awesome... #include int sum(int *a , int *b) { *a = 67+55; *b = 67-55; } int main() { int a , b; a = 67; b = 55; printf("The value of a is %d " , a); printf("And the value of b is %d " , b); sum(&a , &b); printf("Now the value of a is %d " , a); printf("And The value of b is %d" , b); return 0; }
//CALL BY REFERENCE(Quick quiz) #include int cbr(int *x, int *y){ *x= *x+ *y; *y= *x- *y- *y; } int main() { int a=4, b=3; printf("The values of a and b are %d and %d respectively ", a, b); cbr(&a, &b); printf("The values of a and b are %d and %d respectively", a, b); return 0; }
Sir your teaching style is awesome. All I want to say is I am very lucky to find this channel. Sir, if possible , can you make playlist on competitive coding, I will be very thankful to you
Quiz(Given two numbers a and b, add them then subtract them to a and b using call by reference.) #include void ADDSUB(int *a,int *b) { int temp; temp = *a; *a = *a + *b; *b = temp - *b; return ; } int main () { int a=4,b=3; printf("tha value of a is %d and the value of b is %d ",a,b); ADDSUB(&a,&b); printf("now thw value of a is %d and the value of b is %d",a,b); return 0; }
#include int operation(int* x, int* y){ int c;// declaring a local variable. c= *x + *y; // adding the value of pointers and assigning them into c. int d; // declaring a local variable. d = *x - *y; // subtracting the value of pointers and assigning them into d. *x = c; // assigning the value of c into pointer x. *y = d; // assigning the value of d into pointer y. } int main() { int a=4, b=3; printf("The values of a and b before calling the function are: %d and %d ", a, b); operation(&a, &b); printf("The values of a and b after using the operation function are: %d and %d ", a, b); return 0; } //Love you Harry Bhai.
@@rockygaming3663 return 0 means program has successfully executed. Because a function has to return a value if it doesn't returns then it is interpreted that the program is incomplete so we write return 0 to return a value to the program.😊✌️ Hope you get it and good luck on your learning journey, I learned from this course now I'm studying java from Harry Sir.👍
Thankyou sir for providing such a great knowledge ..... solved all problems till lec 31.. all challange accepted ...lets move to another lec and solve all problems.. Thank you sir
I can say surely no one can teach as much best provramming as harry dude he is like bro and what a anolgy he gives amazing yaar aasu aagaye aasu 😒😒and also one thing for c laguage may be this is the best playlist ever
//Given two no's, add them and subtract them and reassign them using call by reference approach #include int operations( int *x, int *y) { int c,d; c= *x + *y; d= *x - *y; *x=c; *y=d; return 0; } int main() { int a, b; printf("Enter the two numbers:
"); scanf("%d%d",&a,&b); printf("You entered %d and %d
", a, b); operations(&a,&b); printf("After doing required operations using call by reference,the numbers are: %d and %d\t",a,b); printf("
Thanks harry bhai mere college ke assignment me tha ye question #include int interchange(int *x,int*y){ int z; z = *x; //stores num1 value in another variable *x = *y; //stores num2 value in num1 *y = z; // stores num1 value in num2 } int main(){ int a,b; printf("Enter the value of num1 : "); scanf("%d",&a); printf("Enter the value of num2 : "); scanf("%d",&b); printf("num1 = %d num2 = %d ",a,b); interchange(&a,&b); printf("After interchanging "); printf("num1 = %d num2 = %d ",a,b); }
Call by reference example in this i changed actual value of x and y by using pointer #include float func1(float *a,float *b){ *a = 1.6; *b = 1.0; } int main(){ float x = 12.0,y=6.0; printf(" x before calling %f y before calling %f ",x,y); float d = func1(&x,&y); printf(" x after calling %f y after calling %f ",x,y); }
wah sir what's explanation, maja aa gaya, i am watching this video before one hour of my c language exam BCA(S.S JAIN SUBODH PG COLLEGE JAIPUR) THANK YOU SIR, LOVE YOU 🤍🤍
26:09 quiz solution: #include void func(int *a,int * b) { int temp; temp=*a; *a=*a+*b; *b=temp-*b; } int main() { int a,b; printf("enter a and b:"); scanf("%d %d",&a,&b); printf("The values of a and b are %d and %d ! ",a,b); func(&a,&b); printf("New a and b are %d and %d ! ",a,b); }
Challenge accepted Harry Bhai. //QUICK QUIZ:Given two numbers a and b, add them then subtract them and assign them to a and b using call by //reference. #include void call_by_reference(int*x,int*y) { *x=*x+*y; *y=(*x-*y)-*y; } int main() { int a=4,b=3; printf("The present value of a and b is %d,%d ",a,b); call_by_reference(&a,&b); printf("After running the function,the updated value of a and b is %d,%d ",a,b); return 0; }
Call by value : copy of value in different variable; then they operate on diffrent values Call by reference : address of an variable copied & both function have same address so they can change the original value
#include /* Quick Quiz: Given two numbers a and b, add them then subtract them and assign them to a and b using call by reference. a = 4 b = 3 after running the function, the values of a and b should be: a = 7 b = 1 */ void callbyref(int *x, int *y) { *x=*x+*y; *y=(*x-*y)-*y; } int main() { int a,b; printf("Enter value of a and b: "); scanf("%d%d",&a,&b); callbyref(&a,&b); printf("The values of a=%d and b=%d",a,b); return 0; }
Sir I completed your challenge for printing triangle and reversed triangle now. It was awesome how I was able to find the solution eventually by making mistakes and then learning from my mistakes. It was trial and error again and again and after three hours I made it! I also found it interesting how many times my intuition works faster than my brain reaches the logic behind the intuition. It helps a lot in programming.
@@ravineemkarolijoshinainital well you might have experience in some other kind of logical things but for a beginner to solve without looking anywhere is a good thing because in the try and error we come across different errors and learn something new
challage accepted !!!!!!! #include void quiz(int *a, int *b) { int temp; temp = *a; *a = *a + *b; *b = temp - *b; } int main() { int a = 4, b = 3; printf("a = %d ", a); printf("b = %d ", b); quiz(&a, &b); printf("Now the value of a = %d ", a); printf("Now the value of b = %d ", b); return 0; }
#include int adder(int *a , int *b){ // call by refrence means we change the value of the values by taking their adress and modifying them . int temp = *a ; *a = *a + *b ; *b = temp - *b ; } int main(void) { int a =6 ,b = 4; printf("The value of a is : %d And Value of b is : %d " , a ,b); adder(&a , &b); printf("Changed value of a is : %d And Changed Value of b is : %d " , a ,b); return 0; }
Thank you for uploading this excellent video, Harry. Let me briefly add by saying, there are two most popular ways to call functions for parameter passing. *Call by Value:* This method copies the value of an actual parameter or argument into the formal parameter of the function. Both actual and formal parameters are stored in different memory locations (in RAM). So, any changes that are made to the formal parameters in the called function are not reflected in the actual parameters in the calling function. Okay? By default, C programming uses call by value to pass parameters. *Call by Reference:* In this approach, the address of an actual parameter is copied into the formal parameter. Both actual and formal parameters refer to the same memory location. So, any changes that are made to the formal parameters in the called function are actually reflected in the actual parameters of the caller function. In C, we can use pointers to get the effect of call by reference or pass by reference, whatever you call it. Hope it helps!
// Wap a program ,given two numbers a and b.Add them then subtract them and assign them to a nd b by using call by reference. #include void operation(int* x,int* y) { int sum,difference; sum= *x+*y; difference= *x-*y; *x=sum; *y=difference; } int main(int argc, char const *argv[]) { int a=4 ,b=3; operation(&a,&b); printf("The value of a is %d and the value of b is %d.",a,b);
Challenge accepted now I understood this but I think it would have been better if formal and actual parameters was taught in a separate video... P.S. will write a solution to this someday soon...
challange accepted #include void func(int *a,int *b){ int temp1 = *a+*b; int temp2 = *a-*b; printf("The values after execution are : %d, %d ",temp1 ,temp2); } int main(){ int a,b; printf("Enter first no. "); scanf("%d",&a); printf("Enter second no. "); scanf("%d",&b); printf("The values of before execution are : %d, %d ", a, b); func(&a,&b); }
its absolutely wrong bro ..if you print the values of a and b it should be 7 and 1,,,whereas u are printing temp1 and temp2....the actual arguments a,b should be changed ,,,
#include void sow(int *a ,int *b){ int temp; temp = *a+*b; *b=*a-*b; *a=temp; } int main(int argc, char const *argv[]) { int a = 4 ,b= 3; printf("%d and %d ",a,b); sow(&a,&b); printf("%d and Secend %d",a,b); return 0; } OutPut: 4 and 3 7 and Secend 1. ans is : a= 7 and b= 1.
Quiz Taking two integers after initializing them. And, after adding and subtracting the value in such a way, its value is changed into 7 and 1 by using call by reference.
challenge accepted and here is my solution to the quick quiz #include int func(int*a,int*b){ int temp; temp = *a; *a = *a+*b; *b = temp-*b; } int main() { int a =4 , b =3; printf("The value of a and b are %d %d " ,a,b); func(&a,&b); printf("The value of a and b are now %d %d ",a,b); return 0; }
I did this code by myself and with your help ofcourse.. Thnakyou Thankyou thankyou #include int addition(int a, int b) { return a + b; } int sub(int x, int y) { return x - y; } int main() { int num; int a , b , c; int x, y, z; while (1) {
printf("ENTER 1 FOR ADDITION AND 2 FOR SUBTRACTION "); scanf("%d", &num); switch (num) { case 1: printf("enter the value of a "); scanf("%d", &a); printf("enter the value of b "); scanf("%d", &b); printf("the value of a is %d and the value of b is %d ", a, b); c = addition(a, b); printf("the sum is %d ", c); break; case 2: printf("enter the value of x "); scanf("%d", &x); printf("enter the value of y "); scanf("%d", &y); printf("the value of x and y is %d, %d ", x, y); z = sub(x, y); printf("the subtraction is %d ", z); break; default: break; } } return 0; }
Quiz Solution: #include int add(int* x, int* y) { return *x + *y; } int sub(int* d, int* c) { return *d - *c; } int main() { int a=4, b=3; printf("%d and %d are two Numbers. ", a, b); int s = add(&a, &b); printf("Addition of Two Numbers is: %d ",s); int m = sub(&a, &b); printf("Subtraction of Two Numbers is: %d ",m); return 0; }
challenge excepted...... #include void additionsubtraction function(int* x,int*y); { int temp=*x; *x=*x+*y; *y=temp-*y; return; } int main() { int a=4,int b=3; printf(" the value of a is %d and the value of b is %d ",a,b); additionsubtraction function(&a,&b); printf(" the value of a now is %d and the value of b now is %d ",a,b); return 0; }
Thanks you so much bhai because of you i am far away from my college c programming once again thank you so much or ye raha program :- #include int sum(int *num1, int *num2) { return *num1+*num2; } int sub(int *num1, int *num2) { return *num1-*num2; } int main() { int a,b; printf("Enter a number :"); scanf("%d",&a); printf("Enter another number : "); scanf("%d",&b); printf("The sum(+) of %d and %d is %d ",a,b,sum(&a,&b)); printf("The sub(-) of %d and %d is %d ",a,b,sub(&a,&b)); return 0; }
#include void sumdiff(int *x, int *y) { int temp; temp= *x; *x = *x + *y; *y = temp - *y; } int main() { int a, b; printf("Enter the value of a "); scanf("%d", &a); printf("Enter the value of b "); scanf("%d", &b); sumdiff(&a, &b); printf("The sum is %d and differnce is %d ", a, b); return 0; }
Harry while explaining Rocket Science: Isme koi rocket science nahin hai!
🤣🤣🤣
Bhai sahi main koi rocket science nhi h
😂😂😂
😂😂😂
Are bhai Harry bhai ne sahi bola isme koi rocket science nahi he.
Kya baat hai bro itne acche se explain karte ho aap ekdam top notch
Hi harry, I am 3 years late to find you on youtube. I am preparing for competitive exams. Your teaching language is straightforward I can understand every word in your videos. anyway, today I accepted you as my programming teacher.
which exam? GATE?
@@priyanshuganatratu apna kaam kar😡🤬
@@VIRALMEMES_YT ab tu kaun h bc
@@VIRALMEMES_YT ab tu kaun h be
😅😅@@priyanshuganatra
/*Author: Md Shoaib
Purpose: Quiz(Given two numbers a and b, add them then subtract them to a and b using call by reference.)
Date: 09/07/2019 */
#include
//fuction(Call by reference) for add or subtract
void addSub(int *a1, int *b1)
{
int temp;
temp = *a1;
*a1 = *a1 + *b1;
*b1 = temp - *b1;
return;
}
int main()
{
//variable declaration
int a = 8, b = 6;
//print to user
printf("Before running the function, the value of a = %d and value of b = %d
", a, b);
//function call for change the values
addSub(&a, &b);
//after using function print to user
printf("After running the function, the value of a = %d and value of b = %d
", a, b);
return 0;
}
bhai tum to heavy coder nikle 😂😂😂😉😉😉😉😉😉😉
niceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
bhai ek number code likha h mene VS code me run kiya , or yeh code run bhi hua
@@alkalinelife6110 ✌🏾
👍👍👍👍
Harry bro ans. of your challenge,
I am late but not wrong
#include
int change(int *a,int *b)
{
*a=*a+*b,*b=*a-*b*2;
}
int main()
{int x=10,y=7;
printf("two values %d %d
",x,y);
change(&x,&y);
printf("%d %d",x,y);
}
Actually you are wrong you are changing the value of a before b so when you perform b=b-a it will minus the updated value of a not previous value of a
edit(to solve this you need to store a's value in temp variable and then you have to perform b=b-temp. Hope you got this)
Exactly@@Devwork-dz3er
Harry bhai you are awesome...
#include
int sum(int *a , int *b)
{
*a = 67+55;
*b = 67-55;
}
int main()
{
int a , b;
a = 67;
b = 55;
printf("The value of a is %d
" , a);
printf("And the value of b is %d
" , b);
sum(&a , &b);
printf("Now the value of a is %d
" , a);
printf("And The value of b is %d" , b);
return 0;
}
//CALL BY REFERENCE(Quick quiz)
#include
int cbr(int *x, int *y){
*x= *x+ *y;
*y= *x- *y- *y;
}
int main()
{
int a=4, b=3;
printf("The values of a and b are %d and %d respectively
", a, b);
cbr(&a, &b);
printf("The values of a and b are %d and %d respectively", a, b);
return 0;
}
//CALL BY REFERENCE(Quick quiz)
#include
int cbr(int *x, int *y){
int temp = *x;
*x= *x+ *y;
*y= temp- *y;
}
You can also do this
Why do you subtracted y 2 times???😮
Accepted sir Abhi tkk saare accept or done karta hua aa rha hu 🥰You are Awesome..😍
Your are my favourite teacher,
and my inspiration too.
Sir your teaching style is awesome.
All I want to say is I am very lucky to find this channel.
Sir, if possible , can you make playlist on competitive coding, I will be very thankful to you
Bro tumare jessa koi nahi!!!YOU ARE THE BEST!!!!
Thanks sir.. Belkul asan tareke se ap samjate hai
You are such a amazing teacher......lot of love and blessings from all cs students
Quiz(Given two numbers a and b, add them then subtract them to a and b using call by reference.)
#include
void ADDSUB(int *a,int *b)
{
int temp;
temp = *a;
*a = *a + *b;
*b = temp - *b;
return ;
}
int main ()
{
int a=4,b=3;
printf("tha value of a is %d and the value of b is %d
",a,b);
ADDSUB(&a,&b);
printf("now thw value of a is %d and the value of b is %d",a,b);
return 0;
}
Hello Mr. Harry Sir.. I am impressed after watching 31 C programming Tutorial... Your skills are very impressive.... Thank You Sir.....❤️❤️
#include
int operation(int* x, int* y){
int c;// declaring a local variable.
c= *x + *y; // adding the value of pointers and assigning them into c.
int d; // declaring a local variable.
d = *x - *y; // subtracting the value of pointers and assigning them into d.
*x = c; // assigning the value of c into pointer x.
*y = d; // assigning the value of d into pointer y.
}
int main()
{
int a=4, b=3;
printf("The values of a and b before calling the function are: %d and %d
", a, b);
operation(&a, &b);
printf("The values of a and b after using the operation function are: %d and %d
", a, b);
return 0;
}
//Love you Harry Bhai.
//Bro can u explain what does return 0 indicate
//if it doesn't return anything what's the purpose of writing it??;
@@rockygaming3663 return 0 means program has successfully executed. Because a function has to return a value if it doesn't returns then it is interpreted that the program is incomplete so we write return 0 to return a value to the program.😊✌️ Hope you get it and good luck on your learning journey, I learned from this course now I'm studying java from Harry Sir.👍
@codewithharry your way of telling and understanding C language is very good and nice.
thanks for videos.
Ek no sirrr. Challenge accepted
Thankyou sir for providing such a great knowledge ..... solved all problems till lec 31.. all challange accepted ...lets move to another lec and solve all problems.. Thank you sir
I can say surely no one can teach as much best provramming as harry dude he is like bro and what a anolgy he gives amazing yaar aasu aagaye aasu 😒😒and also one thing for c laguage may be this is the best playlist ever
//Given two no's, add them and subtract them and reassign them using call by reference approach
#include
int operations( int *x, int *y)
{
int c,d;
c= *x + *y;
d= *x - *y;
*x=c;
*y=d;
return 0;
}
int main()
{
int a, b;
printf("Enter the two numbers:
");
scanf("%d%d",&a,&b);
printf("You entered %d and %d
", a, b);
operations(&a,&b);
printf("After doing required operations using call by reference,the numbers are: %d and %d\t",a,b);
printf("
");
return 0;
}
Hoo
Galat h
Sir app bhot acha smjhate ho apki vjeh se mujhe 5 % to smjh aa gya
This course is perfect harry bhai ❣❣
Harry bhai it is very easy.
Btw challenge accepted.
Herry bhai your way of explaining the actual perameter and formal perameter is really superb .
Yes bhaiya smjh m aya. N challenge accepted
Hats off to u Harry bhaiya for your immense efforts!!
No doubt,it's the best video on this topic.The examples which you gave made it even more simpler and easier to understand. Thank you!
Harry bhaiya thanks a lot course bohat bohat bohat accha hai sab aaram se samaj aa jata hai teaching skills op
Thanks harry bhai mere college ke assignment me tha ye question
#include
int interchange(int *x,int*y){
int z;
z = *x; //stores num1 value in another variable
*x = *y; //stores num2 value in num1
*y = z; // stores num1 value in num2
}
int main(){
int a,b;
printf("Enter the value of num1 :
");
scanf("%d",&a);
printf("Enter the value of num2 :
");
scanf("%d",&b);
printf("num1 = %d
num2 = %d
",a,b);
interchange(&a,&b);
printf("After interchanging
");
printf("num1 = %d
num2 = %d
",a,b);
}
Harry bhai thank you for your efforts
Call by reference example in this i changed actual value of x and y by using pointer
#include
float func1(float *a,float *b){
*a = 1.6;
*b = 1.0;
}
int main(){
float x = 12.0,y=6.0;
printf(" x before calling %f
y before calling %f
",x,y);
float d = func1(&x,&y);
printf(" x after calling %f
y after calling %f
",x,y);
}
wah sir what's explanation, maja aa gaya, i am watching this video before one hour of my c language exam BCA(S.S JAIN SUBODH PG COLLEGE JAIPUR)
THANK YOU SIR, LOVE YOU 🤍🤍
26:09
quiz solution:
#include
void func(int *a,int * b)
{
int temp;
temp=*a;
*a=*a+*b;
*b=temp-*b;
}
int main()
{
int a,b;
printf("enter a and b:");
scanf("%d %d",&a,&b);
printf("The values of a and b are %d and %d !
",a,b);
func(&a,&b);
printf("New a and b are %d and %d !
",a,b);
}
void addsub(int* x, int* y)
{
int temp1=*x+*y;
int temp2=*x-*y;
printf("The value of a is %d
",temp1);
printf("The valuebif b is %d ",temp2);
}
int main()
{
int a=4;
int b=3;
addsub(&a, &b);
return 0;
}
Challenge accepted Harry Bhai.
//QUICK QUIZ:Given two numbers a and b, add them then subtract them and assign them to a and b using call by
//reference.
#include
void call_by_reference(int*x,int*y)
{
*x=*x+*y;
*y=(*x-*y)-*y;
}
int main()
{
int a=4,b=3;
printf("The present value of a and b is %d,%d
",a,b);
call_by_reference(&a,&b);
printf("After running the function,the updated value of a and b is %d,%d
",a,b);
return 0;
}
25:31 very important quiz
Call by value : copy of value in different variable; then they operate on diffrent values
Call by reference : address of an variable copied & both function have same address so they can change the original value
I Love The Way you EXPLAIN!!!!!
Pointers made simple 😃🔥🔥
Thanks harry bhau
#include
/* Quick Quiz:
Given two numbers a and b, add them then subtract them and assign them to a and b using call by reference.
a = 4
b = 3
after running the function, the values of a and b should be:
a = 7
b = 1
*/
void callbyref(int *x, int *y)
{
*x=*x+*y;
*y=(*x-*y)-*y;
}
int main()
{
int a,b;
printf("Enter value of a and b: ");
scanf("%d%d",&a,&b);
callbyref(&a,&b);
printf("The values of a=%d and b=%d",a,b);
return 0;
}
Nice programme ☺
@@santilalsarkar9995 ya
you have to print the gvien values i.e a = 4 & b = 3
all clear and challenge accepted
#include
int main() {
printf("hello harry,nice explanation");
return 0;
}
Harry bhai aap ko bhut bhut bhut thanks....muje c language aalb smj aa rahi heyy
Thank you so much sir😊
Bhaiya you are the best!!!😁
Sir I completed your challenge for printing triangle and reversed triangle now. It was awesome how I was able to find the solution eventually by making mistakes and then learning from my mistakes. It was trial and error again and again and after three hours I made it! I also found it interesting how many times my intuition works faster than my brain reaches the logic behind the intuition. It helps a lot in programming.
I have written the code and posted it in the previous video, please check and correct me if I am wrong anywhere
@@gayatriyadav3766 I can't find your code in the previous video, paste it here.
It's probably late. Not to brag but my code was done in around 5 mins.
I would think that some concepts were not clear at the time.
@@ravineemkarolijoshinainital well you might have experience in some other kind of logical things but for a beginner to solve without looking anywhere is a good thing because in the try and error we come across different errors and learn something new
@@namansharma8515 looking back at the comment after a year, ironically I was probably bragging about it.
I was just a dumb kid I guess.
Thanks a lot bhaiya, your teaching skills are off the charts.
Nice drawing sir ❤️❤️❤️
challage accepted !!!!!!!
#include
void quiz(int *a, int *b)
{
int temp;
temp = *a;
*a = *a + *b;
*b = temp - *b;
}
int main()
{
int a = 4, b = 3;
printf("a = %d
", a);
printf("b = %d
", b);
quiz(&a, &b);
printf("Now the value of a = %d
", a);
printf("Now the value of b = %d
", b);
return 0;
}
Harry bhai best teacher
#include
int sum(int a, int b);
int main()
{
int a,b;
a=4;
b=3;
printf("the sum is %d
", a+b);
printf("the mines is %d
", a-b);
return 0;
}
int sum(int a, int b)
{
return a+b;
}
#include
int adder(int *a , int *b){
// call by refrence means we change the value of the values by taking their adress and modifying them .
int temp = *a ;
*a = *a + *b ;
*b = temp - *b ;
}
int main(void) {
int a =6 ,b = 4;
printf("The value of a is : %d
And Value of b is : %d
" , a ,b);
adder(&a , &b);
printf("Changed value of a is : %d
And Changed Value of b is : %d
" , a ,b);
return 0;
}
Thank you for uploading this excellent video, Harry. Let me briefly add by saying, there are two most popular ways to call functions for parameter passing.
*Call by Value:* This method copies the value of an actual parameter or argument into the formal parameter of the function. Both actual and formal parameters are stored in different memory locations (in RAM). So, any changes that are made to the formal parameters in the called function are not reflected in the actual parameters in the calling function. Okay? By default, C programming uses call by value to pass parameters.
*Call by Reference:* In this approach, the address of an actual parameter is copied into the formal parameter. Both actual and formal parameters refer to the same memory location. So, any changes that are made to the formal parameters in the called function are actually reflected in the actual parameters of the caller function. In C, we can use pointers to get the effect of call by reference or pass by reference, whatever you call it.
Hope it helps!
Thnx it for making it so simple to understand.i couldn't understand it before.
Nice please JavaScript ka course kijiye
Bhai next level explanation tha..Mazaa agaya.
harry bhai app bahut aacha padhate ho..
and keep it up mere bhai
// Wap a program ,given two numbers a and b.Add them then subtract them and assign them to a nd b by using call by reference.
#include
void operation(int* x,int* y)
{
int sum,difference;
sum= *x+*y;
difference= *x-*y;
*x=sum;
*y=difference;
}
int main(int argc, char const *argv[])
{
int a=4 ,b=3;
operation(&a,&b);
printf("The value of a is %d and the value of b is %d.",a,b);
return 0;
}
Best c programming 👍👍👍
accepted!! samajh aagya
Challenge accepted now I understood this but I think it would have been better if formal and actual parameters was taught in a separate video... P.S. will write a solution to this someday soon...
challange accepted
#include
void func(int *a,int *b){
int temp1 = *a+*b;
int temp2 = *a-*b;
printf("The values after execution are : %d, %d
",temp1 ,temp2);
}
int main(){
int a,b;
printf("Enter first no.
");
scanf("%d",&a);
printf("Enter second no.
");
scanf("%d",&b);
printf("The values of before execution are : %d, %d
", a, b);
func(&a,&b);
}
Good
its absolutely wrong bro ..if you print the values of a and b it should be 7 and 1,,,whereas u are printing temp1 and temp2....the actual arguments a,b should be changed ,,,
Thank you so much man! I had a hard time trying to understand this in class but you made it very clear now ❤
Call by value
#include
int multiply(float a,float b){
return a*b;
}
int main() {
float x =5,y=4.5;
float m = multiply(x,y);
printf("%f",m);
}
Harry bhai ki drawing is op ✨✨
great explanation thank you
Thanks Harry Bhaiya
Wow sir aap ne acchha example Diya paper Wala
thnku harry bhai aapne kya samjhaya hai
Great sir 🎉🎉🎉🎉❤❤❤❤
thank you so much sir ki aapne courses ko dale ho due this i feel very helpful and confident also so thank you so much for doing this.
#include
void sow(int *a ,int *b){
int temp;
temp = *a+*b;
*b=*a-*b;
*a=temp;
}
int main(int argc, char const *argv[])
{
int a = 4 ,b= 3;
printf("%d and %d
",a,b);
sow(&a,&b);
printf("%d and Secend %d",a,b);
return 0;
}
OutPut:
4 and 3
7 and Secend 1.
ans is :
a= 7 and b= 1.
Marvelous One Bro 👌
Bhai app awesome ho.. Ek baar apsee milna chahunga......
CHALLEGE ACCEPTED SIR 👍JI
Quiz Taking two integers after initializing them. And, after adding and subtracting the value in such a way, its value is changed into 7 and 1 by using call by reference.
Thank you so much Harry sir for amazing explanation
Love you sir
outstanding class sir
challenge accepted and here is my solution to the quick quiz
#include
int func(int*a,int*b){
int temp;
temp = *a;
*a = *a+*b;
*b = temp-*b;
}
int main()
{
int a =4 , b =3;
printf("The value of a and b are %d %d
" ,a,b);
func(&a,&b);
printf("The value of a and b are now %d %d
",a,b);
return 0;
}
bhai mene Quiz solve kr diya haj tq janu❤️
Bhaiya bohut ache se samaj mai aah rha hh
6:52 kya hi example bhai 😂🔥
I did this code by myself and with your help ofcourse.. Thnakyou Thankyou thankyou
#include
int addition(int a, int b)
{
return a + b;
}
int sub(int x, int y)
{
return x - y;
}
int main()
{
int num;
int a , b , c;
int x, y, z;
while (1)
{
printf("ENTER 1 FOR ADDITION AND 2 FOR SUBTRACTION
");
scanf("%d", &num);
switch (num)
{
case 1:
printf("enter the value of a
");
scanf("%d", &a);
printf("enter the value of b
");
scanf("%d", &b);
printf("the value of a is %d and the value of b is %d
", a, b);
c = addition(a, b);
printf("the sum is %d
", c);
break;
case 2:
printf("enter the value of x
");
scanf("%d", &x);
printf("enter the value of y
");
scanf("%d", &y);
printf("the value of x and y is %d, %d
", x, y);
z = sub(x, y);
printf("the subtraction is %d
", z);
break;
default:
break;
}
}
return 0;
}
#include
using namespace std;
void calc(int *x, int *y){
*x = *x + *y;
*y = *x - *y - *y;
}
int main(){
// cout
I lv u bhaiya ❤❤❤
veryyyyyyy gooooodddd lecture !!!!!!!!
Quiz Solution:
#include
int add(int* x, int* y)
{
return *x + *y;
}
int sub(int* d, int* c)
{
return *d - *c;
}
int main()
{
int a=4, b=3;
printf("%d and %d are two Numbers.
", a, b);
int s = add(&a, &b);
printf("Addition of Two Numbers is: %d
",s);
int m = sub(&a, &b);
printf("Subtraction of Two Numbers is: %d
",m);
return 0;
}
void quiz(int* a, int* b){
int sum = *a + *b;
int diff = *a - *b;
*a = sum;
*b = diff;
}
thank you bhaiya i love you alot ❤❤❤❤❤❤❤
challenge excepted......
#include
void additionsubtraction function(int* x,int*y);
{
int temp=*x;
*x=*x+*y;
*y=temp-*y;
return;
}
int main()
{
int a=4,int b=3;
printf(" the value of a is %d and the value of b is %d
",a,b);
additionsubtraction function(&a,&b);
printf(" the value of a now is %d and the value of b now is %d
",a,b);
return 0;
}
bakki sbb ko sorho, harry bhai ki danchu example🤣🤣👌🏻
learning and enjoying. challenge accepted.
Awesome👏✊👍👏✊👍👏✊👍 bro i got it
Thanks you so much bhai because of you i am far away from my college c programming once again thank you so much or ye raha program :-
#include
int sum(int *num1, int *num2)
{
return *num1+*num2;
}
int sub(int *num1, int *num2)
{
return *num1-*num2;
}
int main()
{
int a,b;
printf("Enter a number :");
scanf("%d",&a);
printf("Enter another number : ");
scanf("%d",&b);
printf("The sum(+) of %d and %d is %d
",a,b,sum(&a,&b));
printf("The sub(-) of %d and %d is %d
",a,b,sub(&a,&b));
return 0;
}
Challenged accepted.. 🔥🤝😃
#include
void sumdiff(int *x, int *y)
{ int temp;
temp= *x;
*x = *x + *y;
*y = temp - *y;
}
int main()
{
int a, b;
printf("Enter the value of a
");
scanf("%d", &a);
printf("Enter the value of b
");
scanf("%d", &b);
sumdiff(&a, &b);
printf("The sum is %d and differnce is %d
", a, b);
return 0;
}
awesome video bhaiya thanks a lot for your help
Bro ek java ka complete course plz
Accepted 💪💪💪💪