Consecutive String Copy

Description:

Write a program that will copy m consecutive characters from a string s1 beginning at position n into another string s2 Refer sample Input and Output: 1. The first input corresponds to the string input 2. The Second Input corresponds to the number of characters to be copied 3. The third input corresponds to the string index Sample Input 1: SRMUniversity 5 0 Output 1: SRMUn Explanation: The String index starts from 0 and add five characters after that S=0 R=1 M=2 U=3 n=4 Sample Input 2: SRMAPPLELAB 6 3 Output: APPLEL Explanation: The String index starts from 3 and add six characters after that S=0 R=1 M=2 A=3 P=4 P=5 L=6 E=7 L=8 A=9 B=10 Output: APPLEL Test Case 1 Input (stdin) SRMUniversity 5 0 Expected Output SRMUn Test Case 2 Input (stdin) SRMAPPLELAB 6 3 Expected Output APPLEL

Program :

#include <stdio.h>
#include<string.h>
#include <stdlib.h>

int main()
{
    
  char a[50];
  int c,b,i;
  scanf("%s",a);
  scanf("%d%d",&c,&b);
  for(i=b;i<b+c;i++)
    printf("%c",a[i]);
  
  return 0;
}