Print From a Position
In this program we n characters from the position specified in the right direction. We find out a substring of given length.
/*
http://www.ProbCOMP.com
In this program we n characters from the position specified in the right direction. We find out a substring of given length.
*/
#include<stdio.h>
void main()
{
char arr[12]="hello world";
printf("String is: %s",arr);
int n;
printf("\nenter the number of characters to be printed from right\nless than or equal to 11: ");
scanf("%d",&n);
if(n<11 && n>0)
{
for(int j=11-n;j<=11;j++)
printf("%c",arr[j]);
}
else
printf("the length given %d is incorrect",n);
}
Download Program


