1 - Krijo nje program ne gjuhen C i cili mer si input nje string dhe e afishon. 

#include <stdio.h> #include <stdlib.h> void main() { char str[50]; printf("\n\nMer nje string nga tastjera :\n"); printf("-----------------------------------\n"); printf("Jep stringun : "); fgets(str, sizeof str, stdin); printf("Stringu qe ju futet eshte : %s\n", str); }


2 - Krijo nje program ne gjuhen C i cili llogarit gjatesine e nje stringu.

#include <stdio.h> #include <stdlib.h> void main() { char str[100]; int l= 0; printf("\n\nLlogarit gjatesine e nje stringu:\n"); printf("---------------------------------\n"); printf("Jep stringun : "); fgets(str, sizeof str, stdin); while(str[l]!='\0') { l++; } printf("Gjatesia e stringut eshte : %d\n\n", l-1); } 

3 - Krijo nje program ne gjuhen C i cili kopjon string-un ne nje tjeter.

#include <stdio.h> #include <string.h> #include <stdlib.h> void main() { char str1[100], str2[100]; int i; printf("\n\nKopjo stringun ne nje string tjeter :\n"); printf("-----------------------------------------\n"); printf("Jep stringun : "); fgets(str1, sizeof str1, stdin); i=0; while(str1[i]!='\0') { str2[i] = str1[i]; i++; } str2[i] = '\0'; printf("\nStringu i pare eshte : %s\n", str1);
printf("Stringu i dyte eshte : %s\n", str2); printf("Numri i karaktereve te kopjuar eshte : %d\n\n", i); }

4 - Krijo nje program ne gjuhen C i cili gjen fjalen me te gjate dhe me te shkurter ne string.

#include <stdio.h> #include <string.h> #include <ctype.h> void main() { char str[100], fjala[20], mx[20], mn[20], c; int i = 0, j = 0, flg = 0; printf("\n\nGjej fjalen me te gjate dhe me te shkurter ne string :\n"); printf("-----------------------------------------------------\n"); printf("Jep stringun : "); i = 0; do { fflush(stdin); c = getchar(); str[i++] = c; } while (c != '\n'); str[i - 1] = '\0'; for (i = 0; i < strlen(str); i++) { while (i < strlen(str) && !isspace(str[i]) && isalnum(str[i])) { fjala[j++] = str[i++]; } if (j != 0) { fjala[j] = '\0'; if (!flg) { flg = !flg; strcpy(mx, fjala); strcpy(mn, fjala); } if (strlen(fjala) > strlen(mx)) { strcpy(mx, fjala); } if (strlen(fjala) < strlen(mn)) { strcpy(mn, fjala); } j = 0; } } printf("Fjala me e gjate eshte '%s' \ndhe fjala me e shkurter '%s' \nne string eshte : '%s'.\n", mx, mn, str); }

5 - Krijo nje program ne gjuhen C i cili kthen te gjithe string-un ne shkronja te medha.

#include<stdio.h> #include<ctype.h> int main() { int ctr=0; char str_char; char str[100]; printf("\n Konverto stringun ne shkronja te medha. :\n"); printf("-----------------------------------"); printf("\n Jepe stringun me shkronja te vogla : "); fgets(str, sizeof str, stdin); printf(" Stringu me shkronja te MEDHA:\n "); while (str[ctr]) { str_char=str[ctr]; putchar (toupper(str_char)); ctr++; } printf("\n\n"); return 0; }