Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

" ; " after loop



Comment



Test expression



Iterative statement



Working with switch case




String_ extracting a substring from left




// AHF C PROGRAM SOLVING

//solving here 2_D   ARRAY 	programming problem

#include #define pf printf int main() { char str[100],substr[100]; int i,n; pf("Enter a string: "); gets(str); //taking substring length from left pf("\nEnter the number of character to be copped: "); scanf("%d",&n); //extracting a substring from left for(i=0;str[i]!='\0' && i < n;i++) substr[i]=str[i]; substr[i]='\0'; //end of extracting substring pf("\nThe substring is: "); puts(substr); //printing a substring return 0; }
OUTPUT:


© 2018 - All rights reserved