Professional Documents
Culture Documents
Program 10.1: WAP to store a character string in block of memory space created by
malloc and then modify the same to store a large string.
FLOWCHART/ ALGORITHM
#include<stdio.h>
#include<stdlib.h>
int main()
int n,i;
scanf("%d",&n);
char *p = (char*)malloc(n*sizeof(char));
if(p==NULL)
exit(0);
for(i=0;i<n;i++)
scanf("%c",p+i);
*(p+i)= '\0';
scanf("%d",&n);
p= realloc(p,n*sizeof(char));
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%c",p+i);
*(p+i)= '\0';
free(p);
return 0;
OUTPUT
• Apply various constructs, loops, functions to solve mathematical and scientific problem.
• Design and develop modular programs for real world problems using control structure
and selection structure.