/*C program to create memory for int, char and float variable at run time.*/ #include <stdio.h> #include <stdlib.h> int main() { int *iVar; char *cVar; float *fVar; /*allocating memory dynamically*/ iVar=(int*)malloc(1*sizeof(int)); cVar=(char*)malloc(1*sizeof(char)); fVar=(float*)malloc(1*sizeof(float)); printf("Enter integer value: "); scanf("%d",iVar); printf("Enter character value: "); scanf(" %c",cVar); printf("Enter float value: "); scanf("%f",fVar); printf("Inputted value are: %d, %c, %.2f\n",*iVar,*cVar,*fVar); /*free allocated memory*/ free(iVar); free(cVar); free(fVar); return 0; }
Enter integer value: 100 Enter character value: x Enter float value: 123.45 Inputted value are: 100, x, 123.45
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Enter integer value: 100 Enter character value: x Enter float value: 123.45 Inputted value are: 100, x, 123.45
need an explanation for this answer? contact us directly to get an explanation for this answer