Substring
In this program we n characters from the position specified. We find out a substring of given length.
/*
http://www.ProbCOMP.com
In this program we n characters from the position specified. We find out a substring of given length.
*/
#include<stdio.h>
void main()
{
char arr[12]="Hello world";
int n,pos;
printf("String is: %s",arr);
printf("\nenter number of characters to be printed: ");
scanf("%d",&n);
printf("\nenter the position to begin from: ");
scanf("%d",&pos);
for(int i=pos-1;i<pos-1+n;i++)
printf("%c",arr[i]);
}
Download Program


