#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; }
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
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); }
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 ,,,
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; }
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
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; }
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; }
bhai abhi one week se apko dekh rehe hu samj me b sab aa raha hai becouse i am a b.c.a student bhai pushna ye hai agar bi app ko ik sal ho gya is serise ko kiy app abhi hare comment read kar k answer do gye agar koi confiusion hou to comment isi liye nhi kar raha mai ki app ise chod chuke ho gye old seires ki vjha se
#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; }
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; }
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; }
# 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);
// 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; }
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; }
// 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 int quickquiz(int* a,int* b){ *a=*a+*b; *b=*a-*b-*b; } int main(){ int a=4,b=3; printf("the value of a and b is %d and %d ",a,b); quickquiz(&a,&b); printf("value after function call a= %d and b= %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 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; }
#include Void changevalue(int *x, int *y) { return ; } Int main() { Int a = 4, b= 5; Int s = a+b; Int k = a-b; Changevalue(&s,&k); Printf("The value is %d and %d", s,k); return 0; } _______________________________________ OUTPUT -> The value is 9 and -1
/*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);
chalenge accept :- #include void changeformat(int* x, int* y){ int temp; 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); changeformat(&a,&b); printf("the addition of a and b is: %d and the subtraction of a and b is: %d " ,a,b); return 0; }
#include void adding(int* add1, int* add2) { int temp; temp = *add1; *add1 = *add1 + *add2; *add2 = temp - *add2; return; } int main() { int a = 4, b=3; printf("before running the program a is %d and b is %d ",a,b); adding(&a,&b); printf("after running the program a is %d and b is %d ",a,b); return 0; }
#include //Author : Eshita Das //QUIZ:Given two numbers a and b, add them, subtract them and assign them to a and b void opr(int *a,int *b) { int add,sub; add=*a+*b; sub=*a-*b; *a=add; *b=sub; } void main() { int a=78,b=24; printf("The value of a is %d and of b is %d ",a,b); //The value of a is 78 and of b is 24 opr(&a,&b); printf("The new value of a is %d and of b is %d ",a,b); //The new value of a is 102 and of b is 54 }
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; }
Challenge accepted... #include void changeValue(int*x,int*y){ int add = *x + *y; int sub = *x - *y; *x = add; *y = sub; return;
} int main() { int a = 4 , b = 3; printf("Current value of a and b are: %d and %d ",a,b); changeValue(&a , &b); printf("Current value of a and b are: %d and %d ",a,b); return 0; }
#include void addsubtractreference(int* p,int*q)//int* p and int *p are same { int sum=*p + *q; int subtract=*p -*q; *p=sum; *q=subtract; } int main() { int x=10; int y=2; printf("x is %d and y is %d ",x,y);//x is 10 and y is 2 addsubtractreference(&x,&y);//call by reference printf("x is %d and y is %d ",x,y);//x is 12 and y is 8 return 0; }
#include int add(int a, int b){ return a+b; } int minus(int a, int b){ return a-b; } int main(int argc, char const *argv[]) { int a=6, b=5, c, d; c=add(a,b); d=minus(a,b); printf("The value of a is %d ", a); printf("The value of b is %d ", b); printf("The substraction of a is %d ", c); printf("The value of b is now %d ", d); return 0; }
#include #include void addsub( int *x, int *y,int *z ,int *l,int *n,int *o) { *z = *x + *y; printf("the value of *x is now %d ",*x); printf("the value of *y is now %d
",*y); printf("the value of *z is now %d
",*z); *o = *l-*n; printf("the value of *l is now %d
",*l); printf("the value of *o is now %d
",*o); printf("the value of *n is now %d
",*n); } int main() { int a = 12, b = 5,c,l=20,n=15,o; printf("the value of a is now %d
", a); printf("the value of b is now %d
", b); addsub(&a,&b,&c,&l,&n,&o); printf("the value of c now is %d
",c); printf("the value of o now is %d
",o); return 0; } ###output:-the value of a is now 12 the value of b is now 5 the value of *x is now 12 the value of *y is now 5 the value of *z is now 17 the value of *l is now 20 the value of *o is now 5 the value of *n is now 15 the value of c now is 17 the value of o now is 5
#include void add(int *a1,int *b1) { int temp; temp = *a1; *a1 = *a1 + *b1; *b1 = temp - *b1; return; } int main() { int a=34,b=33; printf("The value of a and b are %d and %d ",a,b); add(&a,&b); printf("After runnning the function the value of a and b are: %d,%d",a,b); return 0; }
challenge accepted . i know i am very late . quick quiz amswer is : #include void interchange(int *A,int*B) { int sum,substract; sum=*A+*B; substract=*A-*B; *A=sum; *B=substract; return ; } int main() { int a,b; printf("Enter the number of a and b "); scanf("%d ",&a); scanf("%d",&b); printf("The value of a and b is now %d and %d ",a,b); printf("The sum of a and b is %d ",a+b); printf("The substract of this value of a and b is %d ",a-b);
interchange(&a,&b); printf("The value Of a =%d ",a); printf("The value Of b =%d ",b); printf("THE SUM OF THIS NEW VALUE OF a AND b IS %d ",a+b ); printf("THE SUBSTRACT OF THIS NEW VALUE OF a AND b IS %d ",a-b );
challenge accepted! #include int performOpsandAssign(int *num1, int *num2) { int add, subtract; add = *num1 + *num2; subtract = *num1 - *num2; *num1 = add; *num2 = subtract; return 0; } int main() { int a, b; printf("Enter two integers: "); scanf("%d %d", &a, &b); printf("Entered numbers: %d and %d ", a, b); performOpsandAssign(&a, &b); printf("Assigned values after addition and substraction of a and b:%d and %d", a, b); return 0; }
#include void swap(int *a, int *b) { int temp; temp=*a-*b; *a=*a+*b; *b=temp; } int main() { int a,b; printf("Enter a number a "); scanf("%d", &a); printf("Enter a number b "); scanf("%d", &b); printf("a+b=%d ", a+b); printf("a-b=%d ", a-b); swap(&a,&b); printf("After swapping the values of a and b with their sums and difference , the values assign will be %d and %d respectively ", a,b); }
#include int function(int *x, int *y) // x is equal to &a (bcoz at downwards i had mentioned the first thing is &a) // then *x is *&a is equal to value of a { 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); function(&a, &b); printf("The new values of a & b now are %d, %d ", a, b); return 0; }
#include int call(*a,*b); int main() { int a,b; printf("Enter value of a ="); scanf("%d",&a); printf(" Enter value of b ="); scanf(" %d",&b); printf("a=%d b=%d",a,b); call(&a,&b); printf(" a=%d b=%d",a,b); return 0; } int call(int *a,int *b) { int x,y; x=*a+*b; y=*a-*b; *a=x; *b=y; }
//Quick quiz #include void fun(int *first, int *second) { int sum,sub; sum = *first + *second; sub = *first - *second; *first = sum; *second = sub; return ; } int main() { int a,b; printf("Give the values of a and b "); scanf("%d %d" , &a,&b); printf("The values of a and b are %d and %d respectively ", a , b); fun(&a , &b); printf("The values of a and b now are %d and %d respectively ",a , b); return 0; }
ARMSTRONG NUMBER using CALL BY VALUE: #include int armstrong (int a); //function declaration int main() { int n; printf("enter the number: "); scanf("%d", &n); printf("the number is %d ",n); if(n==armstrong(n)) //call by value { printf("It is an Armstrong no ");
} else { printf("It is NOT an Armstrong no "); }
return 0; }
int armstrong (int a) //function definition { int digit, sum = 0; while (a != 0) { digit = a % 10; a = a / 10; printf("the digits are: %d ", digit); sum = sum + (digit * digit * digit); } return(sum); }
#include void add_subtract(int* a, int* b) { int temp=*a; *a=*a+*b; *b=temp-*b; } int main() { int a,b; printf("Enter two numbers "); scanf("%d",&a); scanf("%d",&b); printf("The value of a is %d and the value of b is %d ",a,b); add_subtract(&a,&b); printf("The value of a is %d and the value of b is %d ",a,b); return 0; }
#include void rd(int* x, int* y) { int temp; int tempe; temp = *x; tempe = *y; *x = temp + tempe; *y = temp - tempe; } int main() { int a = 4, b = 3; rd(&a, &b); printf("value of a is %d and b is %d", a, b);
#include int develope(int* a,int* b) { *a=*a+*b; *b=*a-*b; return; } void main() { int x=84,y=99; printf("x is now %d and y is now %d ",x,y); develope(&x,&y); printf("x is now %d and y is now %d ",x,y); }
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.
#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;
}
#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
Herry bhai your way of explaining the actual perameter and formal perameter is really superb .
#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;
}
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);
}
Thank you so much sir😊
25:31 very important quiz
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 ,,,
all clear and challenge accepted
smjh toh ache se aa rha bs 2din baad concept ke sath sath example bhi bhul jaa rha hu ab mai iska koi solutuion bta do
Great sir 🎉🎉🎉🎉❤❤❤❤
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;
}
Thanks a lot bhaiya, your teaching skills are off the charts.
I Love The Way you EXPLAIN!!!!!
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;
}
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
Thnx it for making it so simple to understand.i couldn't understand it before.
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;
}
Excuse me harry bhaiya can u bring a video of the same in java
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;
}
Bhaiya bohut ache se samaj mai aah rha hh
bhai abhi one week se apko dekh rehe hu samj me b sab aa raha hai becouse i am a b.c.a student
bhai pushna ye hai agar bi app ko ik sal ho gya is serise ko kiy app abhi hare comment read kar k answer do gye agar koi confiusion hou to
comment isi liye nhi kar raha mai ki app ise chod chuke ho gye old seires ki vjha se
Bhai app awesome ho.. Ek baar apsee milna chahunga......
#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;
}
Harry bhai ki drawing is op ✨✨
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;
}
Sir why *x = *y changes their values
Because *x work as a value operator
veryyyyyyy gooooodddd lecture !!!!!!!!
Thanks Harry Bhaiya
thnku harry bhai aapne kya samjhaya hai
Thanks
I lv u bhaiya ❤❤❤
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;
}
hi sir esme muje array elements ko sum karvana ho to kese kare
Can I change the value of ram blocks used by other running programs?
# 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;
}
// 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;
}
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;
}
Marvelous One Bro 👌
// 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;
}
Nice
#include
int quickquiz(int* a,int* b){
*a=*a+*b;
*b=*a-*b-*b;
}
int main(){
int a=4,b=3;
printf("the value of a and b is %d and %d
",a,b);
quickquiz(&a,&b);
printf("value after function call a= %d and b= %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 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;
}
#include
Void changevalue(int *x, int *y) {
return ;
}
Int main() {
Int a = 4, b= 5;
Int s = a+b;
Int k = a-b;
Changevalue(&s,&k);
Printf("The value is %d and %d", s,k);
return 0;
}
_______________________________________
OUTPUT ->
The value is 9 and -1
thank you bhaiya i love you alot ❤❤❤❤❤❤❤
dada love from bangladesh
/*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;
}
challenge accepted
sir!
Challenge accepted and done successfully after 2 yrs
#include
int sumandsub(int *a, int *b)
{
int temp;
temp = *a;
*a = temp + *b;
*b = *b - temp;
printf("sum of a=%d
", *a);
printf("subtraction of b=%d
", *b);
return 0;
}
int main()
{
int a, b;
printf("the numbers are
");
scanf("%d%d", &a, &b);
sumandsub(&a, &b);
}
chalenge accept :-
#include
void changeformat(int* x, int* y){
int temp;
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);
changeformat(&a,&b);
printf("the addition of a and b is: %d and the subtraction of a and b is: %d
" ,a,b);
return 0;
}
#include
void adding(int* add1, int* add2)
{
int temp;
temp = *add1;
*add1 = *add1 + *add2;
*add2 = temp - *add2;
return;
}
int main()
{
int a = 4, b=3;
printf("before running the program a is %d and b is %d
",a,b);
adding(&a,&b);
printf("after running the program a is %d and b is %d
",a,b);
return 0;
}
#include
//Author : Eshita Das
//QUIZ:Given two numbers a and b, add them, subtract them and assign them to a and b
void opr(int *a,int *b)
{
int add,sub;
add=*a+*b;
sub=*a-*b;
*a=add;
*b=sub;
}
void main()
{
int a=78,b=24;
printf("The value of a is %d and of b is %d
",a,b); //The value of a is 78 and of b is 24
opr(&a,&b);
printf("The new value of a is %d and of b is %d
",a,b); //The new value of a is 102 and of b is 54
}
Challange accepted 😮
Change complete 💯
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;
}
i have copy of my code bro from tuts 1
challege accecpted
Katai jehar
Awwwwesomme❤❤
7:01 is our childhood memories!! XD
AGREE?
Apna to abhi bhi same h🙄
#include
void changedValue(int *A, int *B)
{
*A = *A + *B;
*B = *A - *B;
}
int main()
{
int a, b;
a = 4;
b = 3;
printf("Before calling function:
");
printf("a = %d
", a);
printf("b = %d
", b);
changedValue(&a, &b);
printf("After calling function:
");
printf("a = %d
", a);
printf("b = %d
", b);
return 0;
}
OUTPUT:
Before calling function:
a = 4
b = 3
After calling function:
a = 7
b = 4
Challenge accepted ! ❤👍
Challenge accepted...
#include
void changeValue(int*x,int*y){
int add = *x + *y;
int sub = *x - *y;
*x = add;
*y = sub;
return;
}
int main()
{
int a = 4 , b = 3;
printf("Current value of a and b are: %d and %d
",a,b);
changeValue(&a , &b);
printf("Current value of a and b are: %d and %d
",a,b);
return 0;
}
Challenge accepted ❤️
Sub samj a rha hai bro
#include
void addsubtractreference(int* p,int*q)//int* p and int *p are same
{
int sum=*p + *q;
int subtract=*p -*q;
*p=sum;
*q=subtract;
}
int main()
{
int x=10;
int y=2;
printf("x is %d and y is %d
",x,y);//x is 10 and y is 2
addsubtractreference(&x,&y);//call by reference
printf("x is %d and y is %d
",x,y);//x is 12 and y is 8
return 0;
}
👍🏻👍🏻
#include
int add(int a, int b){
return a+b;
}
int minus(int a, int b){
return a-b;
}
int main(int argc, char const *argv[])
{
int a=6, b=5, c, d;
c=add(a,b);
d=minus(a,b);
printf("The value of a is %d
", a);
printf("The value of b is %d
", b);
printf("The substraction of a is %d
", c);
printf("The value of b is now %d
", d);
return 0;
}
Challenge excerpted 😎😎
#challenege accepted by#suraj kudale
#include
#include
void addsub( int *x, int *y,int *z ,int *l,int *n,int *o)
{
*z = *x + *y;
printf("the value of *x is now %d
",*x);
printf("the value of *y is now %d
",*y);
printf("the value of *z is now %d
",*z);
*o = *l-*n;
printf("the value of *l is now %d
",*l);
printf("the value of *o is now %d
",*o);
printf("the value of *n is now %d
",*n);
}
int main()
{
int a = 12, b = 5,c,l=20,n=15,o;
printf("the value of a is now %d
", a);
printf("the value of b is now %d
", b);
addsub(&a,&b,&c,&l,&n,&o);
printf("the value of c now is %d
",c);
printf("the value of o now is %d
",o);
return 0;
}
###output:-the value of a is now 12
the value of b is now 5
the value of *x is now 12
the value of *y is now 5
the value of *z is now 17
the value of *l is now 20
the value of *o is now 5
the value of *n is now 15
the value of c now is 17
the value of o now is 5
bhai mene A=b = c aur A- b = d fir c and d value ko x and y me dia
#include
void add(int *a1,int *b1)
{
int temp;
temp = *a1;
*a1 = *a1 + *b1;
*b1 = temp - *b1;
return;
}
int main()
{
int a=34,b=33;
printf("The value of a and b are %d and %d
",a,b);
add(&a,&b);
printf("After runnning the function the value of a and b are: %d,%d",a,b);
return 0;
}
challenge accepted 😀!!!
challenge accepted .
i know i am very late .
quick quiz amswer is :
#include
void interchange(int *A,int*B)
{
int sum,substract;
sum=*A+*B;
substract=*A-*B;
*A=sum;
*B=substract;
return ;
}
int main()
{
int a,b;
printf("Enter the number of a and b
");
scanf("%d
",&a);
scanf("%d",&b);
printf("The value of a and b is now %d and %d
",a,b);
printf("The sum of a and b is %d
",a+b);
printf("The substract of this value of a and b is %d
",a-b);
interchange(&a,&b);
printf("The value Of a =%d
",a);
printf("The value Of b =%d
",b);
printf("THE SUM OF THIS NEW VALUE OF a AND b IS %d
",a+b );
printf("THE SUBSTRACT OF THIS NEW VALUE OF a AND b IS %d
",a-b );
return 0;
}
challenge accepted!
#include
int performOpsandAssign(int *num1, int *num2)
{
int add, subtract;
add = *num1 + *num2;
subtract = *num1 - *num2;
*num1 = add;
*num2 = subtract;
return 0;
}
int main()
{
int a, b;
printf("Enter two integers: ");
scanf("%d %d", &a, &b);
printf("Entered numbers: %d and %d
", a, b);
performOpsandAssign(&a, &b);
printf("Assigned values after addition and substraction of a and b:%d and %d", a, b);
return 0;
}
Best explanation in the entire youtube🤗😘
#include
void swap(int *a, int *b)
{
int temp;
temp=*a-*b;
*a=*a+*b;
*b=temp;
}
int main()
{
int a,b;
printf("Enter a number a
");
scanf("%d", &a);
printf("Enter a number b
");
scanf("%d", &b);
printf("a+b=%d
", a+b);
printf("a-b=%d
", a-b);
swap(&a,&b);
printf("After swapping the values of a and b with their sums and difference , the values assign will be %d and %d respectively
", a,b);
}
challenge accepted bhai
Alright guyz 🔥
I am perfectly comfortable
#include
void swap(int* x,int* y);
{
int temp;
temp=*x-*y;
*x=*x+*y;
*y=temp;
return 0;
}
int main()
{
int a=4,b=3;
printf("%d"and"%d
",a,b);
swap(&a,&b);
printf("%d"and"%d
",a,b);
return 0;
}
challeneg accepted
#include
int function(int *x, int *y) // x is equal to &a (bcoz at downwards i had mentioned the first thing is &a)
// then *x is *&a is equal to value of a
{
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);
function(&a, &b);
printf("The new values of a & b now are %d, %d
", a, b);
return 0;
}
#include
int call(*a,*b);
int main()
{
int a,b;
printf("Enter value of a =");
scanf("%d",&a);
printf("
Enter value of b =");
scanf("
%d",&b);
printf("a=%d
b=%d",a,b);
call(&a,&b);
printf("
a=%d
b=%d",a,b);
return 0;
}
int call(int *a,int *b)
{
int x,y;
x=*a+*b;
y=*a-*b;
*a=x;
*b=y;
}
//Quick quiz
#include
void fun(int *first, int *second)
{
int sum,sub;
sum = *first + *second;
sub = *first - *second;
*first = sum;
*second = sub;
return ;
}
int main()
{
int a,b;
printf("Give the values of a and b
");
scanf("%d %d" , &a,&b);
printf("The values of a and b are %d and %d respectively
", a , b);
fun(&a , &b);
printf("The values of a and b now are %d and %d respectively
",a , b);
return 0;
}
Challenge accepted 🎉🎉
accepted
#Challenge Accepted
#include
void sum(int*a, int*b)
{
int rar1, rar2;
rar1 = *a + *b;
rar2 = *a - *b;
*a = rar1;
*b = rar2;
}
int main()
{
int x = 4, y = 3;
printf("The value of x=%d and y=%d
",x,y);
sum(&x, &y);
printf("The value is now:x=%d y=%d
", x,y);
return 0;
}
#include
void swapper(int* a, int* b){
int temp_add = *a + *b;
int temp_sub = *a - *b;
*a = temp_add;
*b = temp_sub;
printf("%d, %d", *a,*b);
return;
}
int main(int argc, char const *argv[])
{
int a = 4;
int b = 3;
swapper(&a, &b);
return 0;
}
quiz:
#include
void ads(int a , int b,int *add,int *sub){
*add = a+b;
*sub = a-b;
}
int main(){
int a=3,b=4;
int add,sub;
ads(a,b,&add,&sub);
printf("SUM:%d
",add);
printf("DIFFERENCE:%d
",sub);
return 0;
}
Bhai mujhe ek chij nahi samajh me nahi aa raha hai ki
Call by value or call by refrence dono ke kya writing difference hai
By reference mai address use krte hai isliye usme pointers aur address dene ke liye & use krte hai
ARMSTRONG NUMBER using CALL BY VALUE:
#include
int armstrong (int a); //function declaration
int main()
{
int n;
printf("enter the number: ");
scanf("%d", &n);
printf("the number is %d
",n);
if(n==armstrong(n)) //call by value
{
printf("It is an Armstrong no
");
}
else
{
printf("It is NOT an Armstrong no
");
}
return 0;
}
int armstrong (int a) //function definition
{
int digit, sum = 0;
while (a != 0)
{
digit = a % 10;
a = a / 10;
printf("the digits are: %d
", digit);
sum = sum + (digit * digit * digit);
}
return(sum);
}
what is your real name bro?
Haris Ali khan
Printf("challenge accepted");
#include
void add_subtract(int* a, int* b)
{
int temp=*a;
*a=*a+*b;
*b=temp-*b;
}
int main()
{
int a,b;
printf("Enter two numbers
");
scanf("%d",&a);
scanf("%d",&b);
printf("The value of a is %d and the value of b is %d
",a,b);
add_subtract(&a,&b);
printf("The value of a is %d and the value of b is %d
",a,b);
return 0;
}
#include
void rd(int* x, int* y)
{
int temp;
int tempe;
temp = *x;
tempe = *y;
*x = temp + tempe;
*y = temp - tempe;
}
int main()
{
int a = 4, b = 3;
rd(&a, &b);
printf("value of a is %d and b is %d", a, b);
return 0;
}
#include
int develope(int* a,int* b)
{
*a=*a+*b;
*b=*a-*b;
return;
}
void main()
{
int x=84,y=99;
printf("x is now %d and y is now %d
",x,y);
develope(&x,&y);
printf("x is now %d and y is now %d
",x,y);
}