alloc q5

 

  1. Create an array of the multiplication table of 7 upto 10 (7x10=70). Use realloc to make it store 15 numbers(from 7x1 to 7x15).
  2. Attempt problem 4 using calloc().


#include <stdio.h>

#include<stdlib.h>


int main() {

    // Write C code here

    int n ;

    printf("Enter the mul table you want for : ");

    scanf("%d",&n);

    int*ptr;

    ptr=(int*) calloc( 10 ,sizeof(int));

    

    

    for (int i = 0 ; i<10;i++){

        printf(" %d X %d = %d \n", n , i+1 , (n*(i+1)));

    }

        

    

    printf("Now table of 7 till 15 is : \n");

    ptr=realloc(ptr , 15*sizeof(int));

    

    for (int i = 0 ; i<15;i++){

         printf(" %d X %d = %d \n", n , i+1 , (n*(i+1)));

    }

       


    return 0;


}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings