Video není dostupné.
Omlouváme se.
Call by Value & Call By Reference In C: C Tutorial In Hindi #31
Vložit
- čas přidán 14. 05. 2019
- In this series of C programming tutorial videos, I have explained you everything you need to know about C language. I hope you are enjoying this C course in Hindi.
►This C Lecture is a part of this C Programming Course: • C Language Tutorials I...
►Source Code + Notes: codewithharry....
►Click here to subscribe - / @codewithharry
Best Hindi Videos For Learning Programming:
►Learn Python In One Video - • Learn Python In Hindi ...
►Learn JavaScript in One Video - • JavaScript Tutorial
►Learn PHP In One Video - • Learn Php In One Video...
►Machine Learning Using Python - • Machine Learning Tutor...
►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
►Advanced Python Tutorials - • Intermediate/Advanced ...
►Object Oriented Programming In Python - • Object Oriented Progra...
►Python Data Science and Big Data Tutorials - • Python Data Science an...
Follow Me On Social Media
►Website (created using Flask) - www.codewithha...
►Facebook - / codewithharry
►Instagram - / codewithharry
►Personal Facebook A/c - / geekyharis
Twitter - / haris_is_here
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.
/*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);
}
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😡🤬
@@tablalife-oy2ic ab tu kaun h bc
@@tablalife-oy2ic ab tu kaun h be
😅😅@@priyanshuganatra
//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
//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???😮
Kya baat hai bro itne acche se explain karte ho aap ekdam top notch
#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
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
#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.👍
#include
void fun(int *a,int *b)
{
int temp;
temp=*a;
*a=(*a+*b);
*b=(temp-*b);
}
int main()
{
int a,b;
printf("enter the values of a and b: ");
scanf("%d%d",&a,&b);
fun(&a,&b);
printf("the value of a is %d and b is %d",a,b);
}
thanks bhaiya for teaching this concept so easily to make us understand
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;
}
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;
}
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.
#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;
}
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);
}
Hello Mr. Harry Sir.. I am impressed after watching 31 C programming Tutorial... Your skills are very impressive.... Thank You Sir.....❤️❤️
// Quick exercise
#include
int add(int *a, int *b)
{
*a = *a + *b;
*b = *a - *b;
}
int main()
{
int a, b;
a = 4;
b = 3;
add(&a, &b);
printf("The value of a is %d
", a);
printf("The value of b is %d", b);
return 0;
}
Thanks sir.. Belkul asan tareke se ap samjate hai
Accepted sir Abhi tkk saare accept or done karta hua aa rha hu 🥰You are Awesome..😍
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);
}
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;
}
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
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;
}
Your are my favourite teacher,
and my inspiration too.
#include
using namespace std;
void calc(int *x, int *y){
*x = *x + *y;
*y = *x - *y - *y;
}
int main(){
// cout
#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;
}
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;
}
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 ,,,
@codewithharry your way of telling and understanding C language is very good and nice.
thanks for videos.
// 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
#include
void add_sub(int *add_a, int *add_b)
{
int temp1, temp2;
temp1 = *add_a + *add_b;
temp2 = *add_a - *add_b;
*add_a = temp1;
*add_b = temp2;
}
int main()
{
int a = 66, b = 95;
printf("The value of a is %d and b is %d
", a, b);
add_sub(&a, &b);
printf("After addition and substraction the value of a is %d and b is %d ", a, b);
return 0;
}
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;
}
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
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
int main() {
printf("hello harry,nice explanation");
return 0;
}
You are such a amazing teacher......lot of love and blessings from all cs students
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);
}
// 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;
}
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;
}
// Challenge accepted.
// Author name; Sandeep Pareek
//Question:- Given two numbers a and b, add them then subtract them to a and b using call by reference.
#include
int assign(int *x, int *y)
{
int h, s;
h = *x;
s = *y;
*x = h + s;
*y = h - s;
}
int main()
{
int a, b;
printf("Enter the value of a
");
scanf("%d", &a);
printf("Enter the value of b
");
scanf("%d", &b);
assign(&a, &b);
printf("Value of a is %d and b is %d", a, b);
return 0;
}
Good , helpful
Is code me sirf output hi aa raha hai value ka
Sir app bhot acha smjhate ho apki vjeh se mujhe 5 % to smjh aa gya
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;
}
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.
Challenge💪
#include
void as(int *a, int *b) {
int add = *a + *b;
int sub = *a - *b;
*a = add;
*b = sub;
}
int main() {
int num1, num2;
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
as(&num1, &num2);
printf("add= %d
", num1);
printf("sub= %d
", num2);
return 0;
}
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!
// challenge accepted, please see the two successful exercise below.
/*
#include
void interesting(int *add , int *subtract);
int main()
{
int a=99,b=88;
printf("The sum of %d and %d is %d
",a,b,a+b);
interesting(&a, &b);
printf("The new value of a and b is %d and %d respectively.",a,b);
return 0;
}
void interesting(int *add, int *subtract)
{
int temp= *add;
*add = *add + *subtract;
*subtract = temp - *subtract;
return;
} */
//example II
#include
void magic(int *x, int *y)
{
int temp = *x;
*x = (*x + *y);
*y = (temp * *y);
return;
}
main()
{
int add, multiply;
printf("Enter the value you want to see as add and multiply.
");
printf("Enter the first number
");
scanf("%d",&add);
printf("Enter the second number
");
scanf("%d",&multiply);
printf("the Entered numbers are %d and %d
",add, multiply);
magic(&add, &multiply);
printf("Add is %d and Multiply is %d",add,multiply);
}
your comment is so much underrated
Ek no sirrr. Challenge accepted
Challenge accepted
#include
int challenge (int *x,int *y);
int main()
{
int a=10,b=7;
printf("The value of a : %d
",a);
printf("The value of b : %d
",b);
challenge (&a,&b);
printf("
The value of a : %d
",a);
printf("
The value of b : %d
",b);
return 0;
}
int challenge (int *x,int *y){
int temp = *x;
*x = *x+*y;
*y = temp - (*y);
return 0;
}
Hats off to u Harry bhaiya for your immense efforts!!
Herry bhai your way of explaining the actual perameter and formal perameter is really superb .
#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.
Radhe Radhe Harry Bhaiya
here is my quick quiz code:-
#include
void afterprogramme(int *A, int *B)
{
int x = 4, y = 3;
*A = x + y;
*B = x - y;
return;
}
int main()
{
int a = 4, b = 3;
printf("The value of a is %d and The value of b is %d
", a, b);
afterprogramme(&a, &b);
printf("The value of a after programme is %d and The value of b after programm is %d
", a, b);
return 0;
}
void quiz(int* a, int* b){
int sum = *a + *b;
int diff = *a - *b;
*a = sum;
*b = diff;
}
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!
/* Harry bhaiya's assignment*/
#include
int sum(int *c,int *d)
{
int s=*c+*d;
}
int difference(int*e,int*f)
{
int d=*e-*f;
}
int main()
{
int a,b;
scanf("%d%d",&a,&b);
printf("%d and %d",a,b);
a=sum(&a,&b);
b=difference(&a,&b);
printf("%d and %d",a,b);
return 0;
}
Harry bhai it is very easy.
Btw challenge accepted.
challenge accepted
solved:
#include
int sum(int *a, int *b)
{
int sum;
sum = *a + *b;
return sum;
}
int subtract(int *a, int *b)
{
int result;
result = *a - *b;
return result;
}
int assign(int *a, int *b)
{
int result;
result = *a *= *b;
}
int main()
{
int a = 4, b = 3;
printf("The value of a is %d and b is %d
", a, b);
printf("After adding a and b the sum is %d
", sum(&a, &b));
printf("After subtracting them the value is %d
", subtract(&a, &b));
printf("After assigning the value is %d
", assign(&a, &b));
return 0;
}
subse jyada easy way
#include
void changevalue(int *a)
{
*a = 4;
}
int main()
{
int a = 4, b = 3;
printf("The value of is now %d
", a);
changevalue(&a);
printf("The value of is now %d
", b);
printf("a+b=%d
", a + b);
printf("a+b=%d
", a - b);
return 0;
}
25:31 very important quiz
quick quiz answer=
int change_the_value (int *ptra,int*ptrb){
int c= *ptra+*ptrb;
int d=*ptra-*ptrb;
*ptra=c;
*ptrb=d;
return 0;
}
#include
int main()
{
int a,b;
printf("Enter the first number
");
scanf("%d",&a);
printf("Enter the second number
");
scanf("%d",&b);
change_the_value(&a,&b);
printf("%d ,%d
",a,b);
return 0;
}
Bro tumare jessa koi nahi!!!YOU ARE THE BEST!!!!
using call by reference
#include
void addition(int*a,int*b)
{
int temp;
temp=*a;
*a=*a+*b;
}
void subtraction(int*a,int*b)
{
int temp;
temp=*b;
*b=*b-*a;
}
int main()//programm start for the main function .
{
int x=8,y=9; //this is global variable declaration.
printf("Before running the function, the value of x = %d and value of y = %d
", x, y);
addition(&x,&y);//function call
subtraction(&x,&y); //function call
printf("After running the function, the value of x = %d and value of y = %d
", x,y);
return 0;
}
Nice please JavaScript ka course kijiye
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
int assign(int*a, int*b)
{
*a= *a+*b;
*b= *a-*b-*b;
printf("The value of a now is %d.
", *a);
printf("The value of b now is %d.
", *b);
}
int main()
{
int a = 56, b =43;
printf("The value of addition is %d.
", a+b);
printf("The value of subtraction is %d.
", a-b);
assign(&a,&b);
return 0;
}
Quick quiz ans;
/* Given two no. a and b, add them and then subtract them and assign them to a and b resp using call by reference. */
//a =5
//b =4
//after running the function the values of a and b should be:
//a = 9
//b = 1
#include
void func( int *x, int *y)
{
int temp = *x;
*x = *x + *y;
*y = temp - *y;
}
int main()
{
int a,b;
printf("enter a = ");
scanf("%d",&a);
printf("enter b = ");
scanf("%d",&b);
func(&a, &b);
printf("after using function the valyes are
");
printf("a = %d
b =%d",a,b);
return 0;
}
Challenge accepted sir
CODE :-
/* Question :- Given two numbers a and b, add them then subtract them to a and b
using call by reference.
Date: 25/02/2022 */
#include
// Fucntion call by reference Quiz
void arith(int *x,int *y){
int temp;
temp = *x; // to temporary store the value of *x
*x = *x + *y;
*y = temp - *y;
}
int main()
{
int a = 20;
int b = 12;
printf("
Before function calling
");
printf("a = %d
",a);
printf("b = %d
",b);
arith(&a,&b);
printf("
After function calling
");
printf("a = %d
",a);
printf("b = %d
",b);
return 0;
}
OUTPUT :-
Before function calling
a = 20
b = 12
After function calling
a = 32
b = 8
Challenge accepted sir:
#include
int func(int *x, int *y)
{
*x=*x+*y;
*y=*x-2*(*y);
}
int main()
{
int a,b;
scanf("%d %d",&a,&b);
func(&a,&b);
printf("a is %d, b is %d", a,b);
return 0;
}
Nice drawing sir ❤️❤️❤️
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);
}
Quick Quiz Solution:-
#include
void swap(int *x,int *y){
int sum=*x+*y;
*y=*x-*y;
*x=sum;
}
int main()
{
int a=10,b=40;
printf("Before=> a: %d, b: %d
",a,b);
swap(&a,&b);
printf("After=> a: %d, b: %d
",a,b);
return 0;
}
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 🤍🤍
Quick quiz solution
#include
int assign(int* ptra ,int*ptrb){
int x,y;
x = *ptra;
y = *ptrb;
*ptra = x + y;
*ptrb = x - y;
}
int main(){
int a,b;
printf("Enter a :
");
scanf("%d",&a);
printf("Enter b :
");
scanf("%d",&b);
printf("The value of a is %d
",a);
printf("The value of b is %d
",b);
assign(&a,&b);
printf("The value of addition is %d
",a);
printf("The value of subtraction is %d
",b);
}
// given 2 numbers a and b, add them then subtract them
// and assign them to a and b using call by reference
// make a = abs(a-b) and b = a+b
#include
void modify(int *x, int *y)
{
if (*x > *y)
{
int m;
m = *x; // stored a copy of the value of a in a variable m
*x = *x - *y;
*y = m + *y;
}
else if (*x < *y)
{
int n;
n = *x; // stored a copy of the value of a in a variable n
*x = *y - *x;
*y = *y + n;
}
}
int main()
{
int a = 16, b = 20;
printf("The value of a before modification is %d and the value of b before modification is %d
", a, b);
modify(&a, &b);
printf("The new value of a after modification is %d and the new value of b after modification is %d
", 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;
}
Apne Talent se banaye hai sir jii, plzz check kr lijiye. :-)
#include
void changeValue(int* x, int* y)
{
*x = *x + *y;
*y = *x - *y;
}
int main()
{
int a=4, b=3;
changeValue(&a, &b);
printf("the value of a is now %d
", a);
printf("the value of b is now %d
", b);
return 0;
}
ye b ka value 4 dikha raha ha ....
@@shaharslan3372 chagevalue function mai x ka value first expression mai update hoga x=7
Then in next line y=7-3 hoga
Isce acha hai ki add sub do variable declare karo aur usme addition subtraction perform karna
Add=*x+*y;
Sub=*x-*y;
Ab ans of add and sub 7 and 1
Assign values to x and y now
*X=add
*Y=sub
To a and b ka value 7 and 1 ayega
# include
void swap(int*a, int*b){
int temp = *a+*b;
int temp2 = *a-*b;
*a = temp;
*b = temp2;
return;
}
int main(){
int x=5, y=3;
// printf("the addition of x and y is %d
",add(x,y));
printf("the swap of x and y is %d and %d
", x,y);
swap(&x,&y);
printf("the swap of x and y is %d and %d
", x,y);
return 0;
}
// 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
#include
void ar(int* x,int*y)
{
int temp=*x;
*x=*x+*y;
*y=temp-*y;
}
int main()
{
int a=4,b=3;
printf("The value of a is %d and b is %d
",a,b);
ar(&a,&b);
printf("The value a now is %d and b now is %d
",a,b);
return 0;
}
/*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
*/
#include
void add_sub(int *a1 ,int *b1)
{
int temp;
temp=*a1;
*a1= *a1 + *b1;
*b1 = temp - *b1;
}
int main()
{
int a = 4, b =3 ;
printf("the value of a is %d and the value of b is %d
",a,b);
add_sub(&a,&b);
printf("the value of a and b now is %d and %d
",a,b);
return 0;
}
Yes bhaiya smjh m aya. N challenge accepted
Challenge accepted
#include
void swp(int *x,int *y)
{
int temp;
temp = *x - *y;
*x = *x + *y;
*y =temp;
}
int main()
{
int a = 5;
int b = 10;
printf("
The value of a is %d and b is %d",a,b);
swp(&a,&b);
printf("
Now value of a is %d and b is %d",a,b);
return 0;
}
#include
// write a function which will add two numbers and subtract it and assign the value to same variables
void addsubtract(int *a, int *b)
{
int sum = *a + *b;
int difference = *a -*b;
*a = sum;
*b = difference;
}
int main()
{
int a = 80, b = 200;
printf("a:%d and b:%d
", a, b);
addsubtract(&a, &b);
printf("a(added):%d and b(subracted):%d", a, b);
return 0;
}
Bro ek java ka complete course plz
hello sir me na c programming coures ap se shero keya hai lakin installation me kuch samj me nahi aya ab ne jess tara hello word program lika hai me isaye tara na hai lek sakta hu buhat differenc hai apke aur mera programm writting me plzz help me
#include
void swap(int *x, int *y)
{
int temp;
temp = *x;
*x = *y + *x;
*y = temp - *y;
return;
}
#include
int main()
{
int a=4, b = 3;
printf("the velue of %d and %d
", a,b);
swap(&a, &b);
printf("new valuea are %d and %d", a, b);
return 0;
}
challenge accepted
input:-
#include
int functionsum(int *x, int *y)
{
int sum;
sum = *x + *y;
}
int functionsub(int *x, int *y)
{
int sum;
sum = *x - *y;
}
int functionmul(int *x, int *y)
{
int sum;
sum = *x * *y;
}
int functiondiv(int *x, int *y)
{
int sum;
sum = *x / *y;
}
int main()
{
int a;
printf("0. Exit
");
printf("1. Addition
");
printf("2. Substraction
");
printf("3. Multiplication
");
printf("4. Division
");
printf("Entre your number
");
scanf("%d", &a);
switch (a)
{
int mun1, mun2, c;
case 0:
printf("Exit from programe
");
break;
case 1:
printf("enter your first number=
");
scanf("%d", &mun1);
printf("enter your second number=
");
scanf("%d", &mun2);
c = functionsum(&mun1, &mun2);
printf("the answer is=%d
", c);
break;
case 2:
printf("enter your first number=
");
scanf("%d", &mun1);
printf("enter your second number=
");
scanf("%d", &mun2);
c = functionsub(&mun1, &mun2);
printf("the answer is=%d
", c);
break;
case 3:
printf("enter your first number=
");
scanf("%d", &mun1);
printf("enter your second number=
");
scanf("%d", &mun2);
c = functionmul(&mun1, &mun2);
printf("the answer is=%d
", c);
break;
case 4:
printf("enter your first number=
");
scanf("%d", &mun1);
printf("enter your second number=
");
scanf("%d", &mun2);
c = functiondiv(&mun1, &mun2);
printf("the answer is=%d
", c);
break;
default:
printf("you have entered a wrong number
");
}
return 0;
}
#include
void callbyref(int *a,int*b)
{
int one=*a;
int two=*b;
*a=one+two;
*b=one-two;
}
int main()
{
int a=4,b=3;
printf("The origional value is:
%d and %d
",a,b);
callbyref(&a,&b);
printf("The origional value is:
%d and %d
",a,b);
return 0;
}
Challange acepted and completed
quick quiz sloved
#include
void changevalue(int *a,int *b)
{
int add = *a + *b;
int subtrac = *a - *b;
*a = add;
*b = subtrac;
}
int main()
{
int a = 4,b = 3;
printf("the value of a now is %d
",a);
printf("the value of b now is %d
",b);
changevalue(&a,&b);
printf("add is %d
",a);
printf("subtrac is %d
",b);
return 0;
}
// Quick Quiz - changing values of variables using call by reference
#include
void sum_sub(int* address_of_a, int* address_of_b)
{
int temp_a = *address_of_a, temp_b = *address_of_b;
*address_of_a = temp_a + temp_b;
*address_of_b = temp_a - temp_b;
}
int main()
{
int a = 4, b = 3;
printf("
Befor running the function:-
Value of a = %d
Value of b = %d", a, b);
sum_sub(&a, &b);
printf("
After running the function:-
Value of a = %d
Value of b = %d", a, b);
return 0;
}
Harry bhai thank you for your efforts
is this the correct one?
Please replay.
#include
void add(int* a,int* b);
int main()
{
int a = 4;
int b = 3;
printf("values are %d %d %d %d",a,b,a+b,a-b);
add(&a, &b);
printf("values are %d %d %d %d",a,b,a+b,a-b);
return 0;
}
void add(int* a,int* b){
*a = 7;
*b = 1;
}
// Online C compiler to run C program online
#include
void change(int *x,int *y){
*x=*x+*y;
*y=*x-2*(*y);
}
int main() {
int a=4,b=3;
printf("the value of a=%d and b=%d
",a,b);
change(&a,&b);
printf("the value of a=%d and b=%d",a,b);
return 0;
}
#include
int operation(int *n1,int *n2){
int temp=*n1+*n2;
*n2=*n1-*n2;
*n1=temp;
}
int main(){
int a=4;
int b=3;
printf("before operation value of a and b is %d,%d
",a,b);
operation(&a,&b);
printf("after operation value of a and b is %d,%d",a,b);
return 0;
}
This course is perfect harry bhai ❣❣
Challenge accepted!
#include
void swap(int *a1, int *b1){
int temp;
temp = *a1;
*a1 = *a1 + *b1;
*b1 = temp - *b1;
}
int main()
{
int a=7,b=2;
printf("addition of the numbers is %d + %d = %d
",a,b,a+b);
printf("subtraction of the number is %d - %d = %d
",a,b,a-b);
swap(&a,&b);
printf("the value of a after swapping the addition result is %d
",a);
printf("the value of b after swapping the subtraction result is %d
",b);
return 0;
}
Thank you so much sir😊
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;
}
QUIZ ANSWER:
#include
int arithmetic(int *a, int *b)
{
int sum = *a + *b;
int sub = *a - *b;
*a = sum;
*b = sub;
return *a, *b;
}
int main()
{
int a, b;
printf("Enter the values for a and b:
");
scanf("%d %d", &a, &b);
arithmetic(&a, &b);
printf("Number1 + Number2 = %d
Number1 - Number2 = %d
", a, b);
return 0;
}
Thanks a lot bhaiya, your teaching skills are off the charts.
quick quiz
#include
void add_subtract(int*a,int*b){
if(*a>*b){
int temp;
temp=*a;
*a=*a+*b;
*b=temp-*b;
}
else{
int temp;
temp=*a;
*a=*a+*b;
*b=*b-temp;
}
}
int main(){
int a=4,b=3;
printf("a=%d and b=%d
",a,b);
add_subtract(&a,&b);
printf("a=%d and b=%d
",a,b);
return 0;
}