One such program that uses a wait function like this is this one:
#include<stdio.h> 
#include<stdlib.h> 
int main() 
{ 
 int pid,fd[2]; int n; char line[20];  
 if(pipe(fd)<0) { 
  printf("Error creating pipe"); 
 } else { 
  pid=fork(); 
  if(pid<0) { 
   printf("Error while forking"); 
  } else { 
   if(pid>0) { 
    close(fd[0]); 
    write(fd[1],"Hello\n",6); 
    while(wait((int *)0)!=pid);
   } else { 
    close(fd[1]); 
    n=read(fd[0],line,20); 
    if(n<0) 
    printf("Error reading a file"); 
    write(1,line,n); 
   } 
  } 
 } 
 return 0; 
}