Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Maringka Rodney

Compro 2-Paralel A String-removing characters && string functions

1. #include <stdio.h>
2. #include <string.h>
3. int main()
4. {
5. int i,n,p,k;
6. char a[100];
7.
8. printf("Enter the String without space: ");
9. scanf("%s", a);
10. printf("Enter position: ");
11. scanf("%d",&p);
12.
13. printf("\nEnter number of characters: ");
14. scanf("%d",&n);
15. k=p+n-1;
16. i=0;
17. for (i=p-1; i<strlen(a)-n;i++){
18. a[i]=a[k++];
19. }
20. a[i]='\0';
21. printf("string after removing character/characters: %s ",a);
22.
23.
24. return 0;
25.}
#include<stdio.h>
#include<string.h>
int main(){
char nama[20];
char temp[20];
printf("masukkan nama kata/kalimat: ");
gets(nama);
printf("hasil copy: %s\n",strcpy(temp,nama));

printf("hasil reverse: %s\n",strrev(temp));

printf("hasil compare: %d\n",strcmp(temp,nama));


printf("\npanjang string: %d\n", strlen(nama));
printf("ganti ke huruf besar: %s\n",strupr(nama));
printf("ganti lagi ke huruf kecil: %s\n",strlwr(nama));

if (strcmp(temp,nama)==0){
printf("\n%s adalah palindrom\n",nama);
printf("\ncoba gabung: %s\n", strcat(temp,nama));
}
else printf("%s bukanlah palindrom",nama);

return 0;
}

You might also like