Welcome to my blog this is test

28 June 2012

write a C program to PRINT SUBSTRING of an original string


//Code:
#include
#include
#include
 void main()
  {
   char ch[50];
   int i=0,j,n,a,b;
   clrscr();
   printf("\n Enter a string : ");
    gets(ch);
    n=strlen(ch);
   printf("\n Enter lower and upper limit between %d to %d : ",i,n-1);
    scanf("%d%d",&a,&b);
   printf("\n The extracted string is : ");
    for(i=a;i<=b;i++)
    printf("%c",ch[i]);
    getch();
  }

/*Output:
Enter a string : my name is .............
Enter lower and upper limit between 0 to 26 : .......
The extracted string is : ...........

No comments:

Post a Comment