#25 C Pointers and Functions | C Programming For Beginners

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 83

  • @programizstudios
    @programizstudios  2 роки тому +7

    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

    • @laurenzwegler7141
      @laurenzwegler7141 4 місяці тому

      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!

    • @SagarCherry
      @SagarCherry 3 місяці тому +1

      @@laurenzwegler7141 ,its tea good with out sugar like that only we want the more informatiomn for thisss

  • @mansigupta6214
    @mansigupta6214 Рік тому +6

    your teaching is justtttt magic😍.........may god bless you

  • @deogracious8113
    @deogracious8113 Рік тому +1

    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

  • @Noir762
    @Noir762 4 місяці тому +1

    Short , simple and easy to understand. ❤

  • @user-nt4nm4fb3u
    @user-nt4nm4fb3u 10 місяців тому +3

    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!

  • @zuko8023
    @zuko8023 6 місяців тому +6

    answer is D

  • @manishbasnet1605
    @manishbasnet1605 2 роки тому +2

    Enjoyed watching!

  • @b7sh_b7sh
    @b7sh_b7sh Рік тому +2

    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;
    }

  • @054vijayakumark4
    @054vijayakumark4 2 роки тому +6

    Option D

  • @SeventeenDistinctRacoons
    @SeventeenDistinctRacoons Рік тому +9

    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;
    }

    • @yourgray303
      @yourgray303 Рік тому +2

      she prob just wanna make us get used to returning smth from function

  • @thomasguerra633
    @thomasguerra633 5 місяців тому

    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*'

  • @programizstudios
    @programizstudios  2 роки тому +9

    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

  • @_scars_
    @_scars_ 2 роки тому +23

    please use dark mode for coding, it attracts the viewers.

    • @nandishnandish7436
      @nandishnandish7436 Рік тому +1

      Yes iam also thinking about that

    • @hcar4203
      @hcar4203 2 місяці тому

      Thought it was bugs that attract bs...

  • @aguywithoutaname
    @aguywithoutaname Рік тому +1

    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;
    }

  • @atharavjadhav9624
    @atharavjadhav9624 2 роки тому

    Finally am par with the video speed

  • @DK-dp1pt
    @DK-dp1pt 2 роки тому

  • @rhydon-2767
    @rhydon-2767 5 місяців тому

    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);

    • @yashjewdhun7689
      @yashjewdhun7689 13 днів тому

      that would return the value of sum whereas in the video it return the address. shouldnt it be (return &sum)?

  • @allproduct341
    @allproduct341 2 роки тому

    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

    • @atharavjadhav9624
      @atharavjadhav9624 2 роки тому

      @Slash it nice..

    • @mohingupta1103
      @mohingupta1103 2 роки тому

      #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();
      }

    • @hristijanp.8500
      @hristijanp.8500 Рік тому

      #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;
      }

  • @geraldheng6976
    @geraldheng6976 Рік тому +1

    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;
    }

  • @dcpowered
    @dcpowered 2 місяці тому

    Please add timestamps to this video! It is missing compared to your earlier videos! 😢

  • @jonathanmawuena9081
    @jonathanmawuena9081 7 місяців тому

    Thank you Ma'am

  • @BenjaminPommer
    @BenjaminPommer Рік тому

    Very helpful

  • @Athena_101
    @Athena_101 6 місяців тому

    thank you mam.

  • @evildarkside829
    @evildarkside829 Рік тому

    How come the function square is set as void ? Shouldn't it be int?

    • @2ndtwoarray934
      @2ndtwoarray934 Рік тому +1

      because we are not returning anything. We are changing the value by pointer. Btw sorry for late reply

  • @deshanjayasinghe4316
    @deshanjayasinghe4316 5 місяців тому

    Whats the use of this, we can do the same without pointers, right?

  • @yadlaaravind811
    @yadlaaravind811 Рік тому +2

    Answer:d

  • @PrashantSingh-kh4wo
    @PrashantSingh-kh4wo 2 роки тому

    i am confused table par tel gira hai ki sira🤔🤔🤔🤔

  • @yourgray303
    @yourgray303 Рік тому

    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
    }

  • @Eileen-in-the-coding-maschine
    @Eileen-in-the-coding-maschine 10 місяців тому

    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.

  • @yogithabale
    @yogithabale 4 місяці тому

    opt d

  • @bryanbalantes6486
    @bryanbalantes6486 Рік тому

    /*
    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;
    }

  • @freehug071
    @freehug071 Рік тому

    #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;
    }

  • @TheHeraldOfSpring
    @TheHeraldOfSpring 3 місяці тому

    #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;
    }

  • @formodapk
    @formodapk Місяць тому

    hello

  • @aritradey7189
    @aritradey7189 2 роки тому +1

    #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);
    }

    • @collinshagembe7852
      @collinshagembe7852 Рік тому

      your program does not run bro

    • @aritradey7189
      @aritradey7189 Рік тому

      @@collinshagembe7852 I have already run that code , in their compiler

  • @naomywitherwhy129
    @naomywitherwhy129 Рік тому

    #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;
    }

  • @abdirahmaanabdirashiid
    @abdirahmaanabdirashiid 3 місяці тому

    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;
    }

  • @charanjitkaur5212
    @charanjitkaur5212 2 роки тому

    #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;
    }

  • @OMNI_INFINITY
    @OMNI_INFINITY Рік тому

    How much skin lightening filter was used in that video?

  • @fateemahamosuro4788
    @fateemahamosuro4788 10 місяців тому

    D

  • @Hakim_fz
    @Hakim_fz 2 роки тому

    #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);
    }

  • @thelegendarysummersky3189
    @thelegendarysummersky3189 9 місяців тому +1

    #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;
    }

  • @huseynmalshev7073
    @huseynmalshev7073 Рік тому

    #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;
    }

  • @Ckjohn77kg
    @Ckjohn77kg Рік тому

    #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;
    }

  • @behailus-tube5024
    @behailus-tube5024 7 місяців тому

    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;
    }

  • @niku0101
    @niku0101 Рік тому

    #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;
    }

  • @vinayakpotadar4907
    @vinayakpotadar4907 5 місяців тому

    #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;
    }

  • @hunter9544
    @hunter9544 7 місяців тому

    #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!

  • @madinaabduganiyeva9249
    @madinaabduganiyeva9249 10 місяців тому

    #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;
    }

  • @countrysideshowyaigrock4689
    @countrysideshowyaigrock4689 Рік тому +6

    #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;
    }

  • @shootingstartsukasa
    @shootingstartsukasa 3 місяці тому +1

    #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;
    }

  • @dnwint2
    @dnwint2 6 місяців тому

    D

  • @red1iteee
    @red1iteee Рік тому

    #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);
    }

  • @yusifabbasov9219
    @yusifabbasov9219 Рік тому

    #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;
    }

  • @bullshit485
    @bullshit485 23 дні тому

    D

  • @JeongWoonKim-i4j
    @JeongWoonKim-i4j Рік тому

    #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;
    }

  • @philipmathewbobis624
    @philipmathewbobis624 Рік тому

    #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;
    }