I made a program in c that uses malloc function. Code:
#include<stdio.h>
#include<stdbool.h>
#include<malloc.h>
int main(){
int n;
int *ptr,i,sum;
sum = 0;
printf("Enter the number = ");
scanf("%d",&n);
ptr = (int *)(malloc(10));
for(i=0;i<n;i++){
scanf("%d",ptr+i);
sum += *(ptr+i);
}
printf("The sum of the numbers is = %i",sum);
}
I have used malloc function to allocate a memory of 10 bytes .How is it possible that 10 integers are stored in 10 bytes....