/* Programming to Read the text and Print the N-th Line
   Hint: a[i]!='\0' can be written as a[i]
*/
#include<stdio.h>
main()
{
        int i,j,n,b[50];
        char a[150];
        clrscr();
        for(i=0;(a[i]=getchar())!='$';i++);
        a[i]='\0';
        j=0;
        b[j]=0;
        j++;

        for(i=0;a[i];i++)
            if (a[i]=='\n')
            {
               b[j++]=i+1;
               printf("b's value =%d",j);
            }
               b[j]=-1;
               printf("b's value =%d",j);

        printf("Enter the N-th Line to Print\n");
        scanf("%d",&n);
        for(i=b[n-1];a[i]!='\n';i++)
        printf ("%c",a[i]);


        getch();
}

/* Exercise: 1. To read a text from KB until $ and print N-th line to M-th line
  input:Taj is beautiful
        Welcome to India$
  output:
        the starting position of the 1 line : 0
        the starting position of the 2 line : 17
*/