Finding C programming hard? We’ve got you! 🚀Get 60% off on Programiz PRO Lifetime Plan this Black Friday-pay once for skills that last forever. Don’t miss out, it’s a limited-time offer! 👉Grab your discount now: bit.ly/blkfriday-24-yt
I have a question! I'm not confused by pointers at all, but I simply don't understand why we need them. It seems like we're just converting variables into pointers -and then converting the pointers back into variables. Why can't we just use the variables, without refering to their memory addresses? PS: AMAZING playlist btw!!! You're very good at explaining!
i love the fact that u use English as the medium of communication and your soo good at explaining but i can see that very clearly when executing those codes or functions
It made me bit confusing at the beginning, but by the last example of adding two numbers is made me clear of this topic. Thank you very much Programiz!
programing task // Online C compiler to run C program online #include #include int* multipliedNumber (int* num1, int* num2, int* multiplied){ *multiplied = *num1 * *num2; return multiplied; } int main() { // Write C code here int num1 = 15; int num2 = 25; int multiplied; multipliedNumber(&num1, &num2, &multiplied); printf("result is: %d", multiplied); return 0; }
Why do you need to make the function return a pointer and not simply void? If you pass three pointers to it you can just say *sum = *num1 * num2; then you call the function in main after you create your variables and print the sum in a printf like below: void multiply(int* num1, int* num2, int* sum); int main() { int num1 = 13; int num2 = 9; int sum; multiply(&num1, &num2, &sum); printf("sum = %d", sum); return 0; } void multiply(int* num1, int* num2, int* sum){ *sum = *num1 * *num2; }
wonderful video! im so glad to have some of this information and clarification, pointers are so unusual for me right now, here is the task: #include int* multNumbers(int* num1, int* num2, int* sum){ *sum = *num1 * *num2; return sum; } int main() { // Write C code here int number1 = 13; int number2 = 9; int sum; int* result = multNumbers(&number1,&number2,&sum); printf("Result is: %d", *result); return 0; } and for the quiz i believe it is D. Address of a double variable, i say this because the return type shown is 'double*'
Q. What type of value does the following function return? double* func(int* a) { ... } A. Integer value B. Address of integer variable C. Double value D. Address of double variable
Programiz Task // Online C compiler to run C program online #include #include int* multiply(int* num1, int* num2, int* product) { *product = *num1 * *num2; return product; } int main() { // Write C code here int num1 = 13; int num2 = 9; int product; multiply(&num1, &num2, &product); printf("Product is: %d", product); return 0; }
Mam please answer this question. Write a C program to print "True" if the given number's right most digit is even and second last right most digit is odd otherwise "False". i.e. “True” for number like 12354, 798 etc
answer is D #include int* findMultiplication(int* num1, int* num2, int* multiplication){ *multiplication = (*num1) * (*num2); return multiplication; } int main() { // Write C code here int number1 = 13; int number2 = 9; int multiplication; int* result = findMultiplication(&number1, &number2, &multiplication); printf("result is: %d", *result); return 0; }
ans: (deff didnt look at instructions) int* multi(int* num1, int* num2, int* sum); int main(void) { int n1=5;//ints int n2=10; int sum; int* result = multi(&n1,&n2,&sum);//start function with pointer params, put pointer result(sum) in pointer "result" printf("%d ", *result); // * to de refrence result, printf it } int* multi(int* num1, int* num2, int* sum)//declare param(int pointers) name { *sum = *num1 * *num2;// :o return sum;//since program alr declared int* , no need to &sum }
/* Create a program to find the multiplication of two numbers using a function and pointers. * Create a function that accepts three pointers. * Inside the function multiply values of two pointers and assign the result to the address of the third pointer.
* Inside the main function, create three variables, two variables with values 13 and 9 and the third variable to store their product. * Call the function with addresses of the 3 variables as arguments. * Store the returned value inside a pointer and print the value pointed by the returned address. */ #include int* multiplyNumbers(int* num1, int* num2, int* product); int main(){ int number1 = 9; int number2 = 13; int product; int* result = multiplyNumbers(&number1, &number2, &product); printf("The product is: %d ", *result);
#include int factorial(int* a, int* b) { int* c = *a * *b; return c; } int main() { int h = 22; int j = 33; int result = factorial(&h, &j); printf("%d", result); return 0; }
Madam,how is this, #include int multiblication(int* num1,int* num2) { int mult =*num1*(*num2); return mult; } int main() { int x,y; printf("ENTER NUM1: "); scanf("%d",&x); printf("ENTER NUM2: "); scanf("%d",&y); int result=multiblication(&x,&y); printf("%d",result); return 0; }
#include int*multiplyNumbers(int *num1, int *num2, int *product){ *product= *num1* *num2; return product; } int main(){ int number1=13; int number2=9; int product; int*result=multiplyNumbers(&number1, &number2, &product); printf("product of 13 and 19=%d", *result); return 0; }
#include int fi (int* num1,int* num2,int*sum){ *sum = *num1 * *num2; return *sum; } int main() { int sum; int num =13; int num2 = 9; fi(&num,&num2,&sum); printf("%d",sum); }
#include int threeNums(int* num1, int* num2, int* product){
*product = *num1 * *num2; return product; } int main() { int no1; int no2; int product; printf("Please Enter num 1: "); scanf("%d", &no1); printf("Please Enter num 2: "); scanf("%d", &no2);
int* result = threeNums(&no1, &no2, &product);
printf("The product of the two numbers is: %d", *result); return 0; }
Finding C programming hard? We’ve got you!
🚀Get 60% off on Programiz PRO Lifetime Plan this Black Friday-pay once for skills that last forever. Don’t miss out, it’s a limited-time offer!
👉Grab your discount now: bit.ly/blkfriday-24-yt
I have a question! I'm not confused by pointers at all, but I simply don't understand why we need them. It seems like we're just converting variables into pointers -and then converting the pointers back into variables. Why can't we just use the variables, without refering to their memory addresses?
PS: AMAZING playlist btw!!! You're very good at explaining!
@@laurenzwegler7141 ,its tea good with out sugar like that only we want the more informatiomn for thisss
your teaching is justtttt magic😍.........may god bless you
i love the fact that u use English as the medium of communication and your soo good at explaining but i can see that very clearly when executing those codes or functions
Short , simple and easy to understand. ❤
It made me bit confusing at the beginning, but by the last example of adding two numbers is made me clear of this topic. Thank you very much Programiz!
answer is D
Enjoyed watching!
programing task
// Online C compiler to run C program online
#include
#include
int* multipliedNumber (int* num1, int* num2, int* multiplied){
*multiplied = *num1 * *num2;
return multiplied;
}
int main() {
// Write C code here
int num1 = 15;
int num2 = 25;
int multiplied;
multipliedNumber(&num1, &num2, &multiplied);
printf("result is: %d", multiplied);
return 0;
}
Option D
Why do you need to make the function return a pointer and not simply void? If you pass three pointers to it you can just say *sum = *num1 * num2;
then you call the function in main after you create your variables and print the sum in a printf like below:
void multiply(int* num1, int* num2, int* sum);
int main()
{
int num1 = 13;
int num2 = 9;
int sum;
multiply(&num1, &num2, &sum);
printf("sum = %d", sum);
return 0;
}
void multiply(int* num1, int* num2, int* sum){
*sum = *num1 * *num2;
}
she prob just wanna make us get used to returning smth from function
wonderful video! im so glad to have some of this information and clarification, pointers are so unusual for me right now, here is the task:
#include
int* multNumbers(int* num1, int* num2, int* sum){
*sum = *num1 * *num2;
return sum;
}
int main() {
// Write C code here
int number1 = 13;
int number2 = 9;
int sum;
int* result = multNumbers(&number1,&number2,&sum);
printf("Result is: %d", *result);
return 0;
}
and for the quiz i believe it is D. Address of a double variable, i say this because the return type shown is 'double*'
Q. What type of value does the following function return?
double* func(int* a) {
...
}
A. Integer value
B. Address of integer variable
C. Double value
D. Address of double variable
D
B
D
D. Address of Double variable
D
please use dark mode for coding, it attracts the viewers.
Yes iam also thinking about that
Thought it was bugs that attract bs...
Programiz Task
// Online C compiler to run C program online
#include
#include
int* multiply(int* num1, int* num2, int* product)
{
*product = *num1 * *num2;
return product;
}
int main() {
// Write C code here
int num1 = 13;
int num2 = 9;
int product;
multiply(&num1, &num2, &product);
printf("Product is: %d", product);
return 0;
}
Finally am par with the video speed
My compiler gives a warning error if the return on the function is not with a pointer, i recommend some to return with a pointer for eg (return *sum);
that would return the value of sum whereas in the video it return the address. shouldnt it be (return &sum)?
Mam please answer this question.
Write a C program to print "True" if the given number's right most digit is even and second last right most digit is odd otherwise "False".
i.e. “True” for number like 12354, 798 etc
@Slash it nice..
#include
int main(){
int number;
scanf("%d", &number);
int x=number%10;
int y = (number-x)/10;
int z = y%10;
if(x%2==0 && z%2!=0){
printf("TRUE
");
}
else{
printf("FALSE
");
}
main();
}
#include
int main(){
int number, lastDigit, penultimateDigit;
scanf("%d", &number);
lastDigit = number%10;
penultimateDigit = number%100/10;
if(lastDigit%2==0 && penultimateDigit%2!=0){
printf("True
");
}
else{
printf("False
");
}
return 0;
}
answer is D
#include
int* findMultiplication(int* num1, int* num2, int* multiplication){
*multiplication = (*num1) * (*num2);
return multiplication;
}
int main() {
// Write C code here
int number1 = 13;
int number2 = 9;
int multiplication;
int* result = findMultiplication(&number1, &number2, &multiplication);
printf("result is: %d", *result);
return 0;
}
Please add timestamps to this video! It is missing compared to your earlier videos! 😢
Thank you Ma'am
Very helpful
thank you mam.
How come the function square is set as void ? Shouldn't it be int?
because we are not returning anything. We are changing the value by pointer. Btw sorry for late reply
Whats the use of this, we can do the same without pointers, right?
Answer:d
i am confused table par tel gira hai ki sira🤔🤔🤔🤔
ans: (deff didnt look at instructions)
int* multi(int* num1, int* num2, int* sum);
int main(void)
{
int n1=5;//ints
int n2=10;
int sum;
int* result = multi(&n1,&n2,&sum);//start function with pointer params, put pointer result(sum) in pointer "result"
printf("%d
", *result); // * to de refrence result, printf it
}
int* multi(int* num1, int* num2, int* sum)//declare param(int pointers) name
{
*sum = *num1 * *num2;// :o
return sum;//since program alr declared int* , no need to &sum
}
TASK:
int* multNumbers(int* num1, int* num2, int* mult) {
*mult = *num1 * *num2;
return mult;
}
int main() {
int num1 = 13;
int num2 = 9;
int mult;
int* product = multNumbers(&num1, &num2, &mult);
printf("Multiplication: %d
", *product);
return 0;
}
D is the correct answer.
opt d
/*
Create a program to find the multiplication of
two numbers using a function and pointers.
* Create a function that accepts three
pointers.
* Inside the function multiply values of two
pointers and assign the result to the address
of the third pointer.
* Inside the main function, create three
variables, two variables with values 13 and 9
and the third variable to store their product.
* Call the function with addresses of the 3
variables as arguments.
* Store the returned value inside a pointer and
print the value pointed by the returned
address.
*/
#include
int* multiplyNumbers(int* num1, int* num2, int* product);
int main(){
int number1 = 9;
int number2 = 13;
int product;
int* result = multiplyNumbers(&number1, &number2, &product);
printf("The product is: %d ", *result);
return 0;
}
int* multiplyNumbers(int* num1, int* num2, int* product){
*product = *num1 * *num2;
return product;
}
#include
int* multi(int* num1, int* num2, int* sum){
*sum = *num1 * *num2;
return sum;
}
int main()
{
int numd = 13;
int numb = 19;
int sum;
int* result = multi(&numd, &numb, &sum);
printf("the result is %d", *result);
return 0;
}
#include
double* multNums (double* num1, double* num2, double* product) {
*product = *num1 * *num2;
return product;
}
int main(){
double number1 = 13, number2 = 9, product1;
double* product2;
product2 = multNums(&number1, &number2, &product1);
printf("The result = %lf", *product2);
return 0;
}
hello
#include
int* mulNumbers(int* number1,int* number2,int* product){
*product=* number1 * * number2;
return product;
}
int main(){
int number1=13;
int number2=9;
int product;
int* result=mulNumbers(&number1,&number2,&product);
printf("product=%d",* result);
}
your program does not run bro
@@collinshagembe7852 I have already run that code , in their compiler
#include
int factorial(int* a, int* b) {
int* c = *a * *b;
return c;
}
int main() {
int h = 22;
int j = 33;
int result = factorial(&h, &j);
printf("%d", result);
return 0;
}
Madam,how is this,
#include
int multiblication(int* num1,int* num2)
{
int mult =*num1*(*num2);
return mult;
}
int main()
{
int x,y;
printf("ENTER NUM1: ");
scanf("%d",&x);
printf("ENTER NUM2: ");
scanf("%d",&y);
int result=multiblication(&x,&y);
printf("%d",result);
return 0;
}
#include
int*multiplyNumbers(int *num1, int *num2, int *product){
*product= *num1* *num2;
return product;
}
int main(){
int number1=13;
int number2=9;
int product;
int*result=multiplyNumbers(&number1, &number2, &product);
printf("product of 13 and 19=%d", *result);
return 0;
}
How much skin lightening filter was used in that video?
D
#include
int fi (int* num1,int* num2,int*sum){
*sum = *num1 * *num2;
return *sum;
}
int main()
{
int sum;
int num =13;
int num2 = 9;
fi(&num,&num2,&sum);
printf("%d",sum);
}
#include
int* productNumbers(int* num1, int* num2, int* product){
*product = *num1 * *num2;
return product;
}
int main(){
int num1 = 3;
int num2 = 4;
int product;
int* result = productNumbers(&num1,&num2,&product);
printf("Result = %d", *result);
return 0;
}
#include
int* multi ( int* num1, int* num2, int* result){
*result= *num1 * *num2;
return result;
}
int main(){
int number1=6;
int number2= 9;
int result;
multi(&number1, &number2, &result);
printf("Sum is %d", result);
return 0;
}
#include
//25.3 Prog.Task//
//Defining function//
int* multi25 (int* num25, int* num25a, int* num25b) {
*num25 = *num25a * *num25b;
return num25;
}
//Main stage//
int main(){
int n25 = 13;
int j25 = 9;
int product ;
//Call the function with addresses of the 3 variables as arguments.//
int *result25 = multi25(&product, &n25, &j25);
printf("the product is: %d
",product);
printf("the address is: %p
",result25);
return 0;
}
task programming
#include
int* multiplynumber(int* number1, int* number2, int* multiply) {
*multiply = *number1 * *number2;
return multiply;
}
int main() {
int number1 = 5;
int number2 = 4;
int multiply;
int resulte = *multiplynumber(&number1,&number2, &multiply);
printf("rusulte: %d", resulte);
return 0;
}
#include
int threeNums(int* num1, int* num2, int* product){
*product = *num1 * *num2;
return product;
}
int main() {
int no1;
int no2;
int product;
printf("Please Enter num 1: ");
scanf("%d", &no1);
printf("Please Enter num 2: ");
scanf("%d", &no2);
int* result = threeNums(&no1, &no2, &product);
printf("The product of the two numbers is: %d", *result);
return 0;
}
#include
int* multi(int *num1, int* num2, int* mul)
{
*mul= *num1 * *num2;
return mul;
}
int main()
{
int val1,val2,mul;
printf("Enter the 2 variables: ");
scanf("%d%d", &val1,&val2);
int* res= multi(&val1,&val2,&mul);
printf("The multiplication is %d",*res);
return 0;
}
#include
int* addnumbers(int* num1, int* num2,int* product) {
*product= *num1 * *num2;
return product;
}
int main() {
int number1=13;
int number2=9;
int product;
int* answer= addnumbers(&number1, &number2, &product);
printf("%d", *answer);
return 0;
}
Arise!
#include
void* findProduct (int* num1, int* num2, int* productOF);
int main () {
int number1 = 9;
int number2 = 13;
int products;
int* result = findProduct(&number1, &number2, &products);
printf("The product is %d", *result);
return 0;
}
void* findProduct (int* num1, int* num2, int* productOF){
int product = *num1 * *num2;
*productOF = product;
return productOF;
}
#include
int* Multiplication(int* num1, int* num2, int* result) {
*result = *num1 * *num2;
return result;
}
int main() {
int number1 = 13;
int number2 = 9;
int thirdPointer;
int* result = Multiplication(&number1, &number2, &thirdPointer);
printf("Multiplication is %d", *result);
return 0;
}
#include
int multiply(int* num1, int* num2, int* product) {
*product = *num1 * *num2;
return* product;
}
int main() {
int num1 = 13, num2 = 19, product;
int result = multiply(&num1, &num2, &product);
printf("Everything is equal to %d", result);
return 0;
}
D
#include
int* multiplyNumbers(int* num1, int* num2, int* product)
{
*product = *num1 * *num2;
return product;
}
int main()
{
int number1 = 13;
int number2 = 9;
int product;
int* result = multiplyNumbers(&number1, &number2, &product);
printf("Product is: %d", *result);
}
#include
int *f(int* num, int* num2, int* sum) {
int add = *num + *num2;
*sum = add;
return sum;
}
int main() {
int number = 5;
int number2 = 10;
int sum;
int* res = f(&number, &number2, &sum);
printf("
%d", *res);
return 0;
}
D
#include
int* multiplyNumbers(int* num1, int* num2, int* product) {
*product = *num1 * *num2;
return product;
}
int main() {
int number1 = 13;
int number2 = 9;
int product;
int* result = multiplyNumbers(&number1, &number2, &product);
printf("Product is %d", *result);
return 0;
}
#include
int* multiplyNumbers(int* num1,int* num2, int* product){
*product = *num1 * *num2;
return product;
}
int main(){
int number1 = 13;
int number2 = 9;
int product;
int* result = multiplyNumbers(&number1, &number2, &product);
printf("The product is %d", *result);
return 0;
}