Bachelor of Technology in Information Technology


Solving problems using String functions



Download 0,65 Mb.
bet13/14
Sana20.03.2022
Hajmi0,65 Mb.
#502184
1   ...   6   7   8   9   10   11   12   13   14
Bog'liq
PSP Lab Manual

Solving problems using String functions




    1. Using built-in string functions ALGORITHM:


Step 1: Start.
Step 2: declare s1[100], s3[100], s2[100] ← world Step 3: print enter string s1
Step 4: read string s1
Step 5: print printing string s2 and print string s2

step 6: print copying string s1 to s3


Step 7: copy string s1 to s3 using string function strcpy(s3,s1) Step 8: print string s3
Step 9: print concating string s3 to s2
Step 10: concatenate string s3 to s2 using string function strcat(s2,s3) Step 11: print string s2
Step 12: print length of string s1 using string function strlen(s1) Step 13: if(compare string s1 and s3 == 0)
Print strings are equal
Step 14: else
Print strings are not equal
Step 15: Stop.


SOURCE CODE:


#include #include #include


Int main(int argc, char **argv)


{
char s1[100],s3[100],s2[100]="World"; printf("Enter a string s1\n"); scanf("%s",&s1);

puts("Printing string s2"); puts(s2);


puts("Copying s1 to s3"); strcpy(s3,s1); puts("Printing string s3");
puts(s3); puts("Concating s3 to s2"); strcat(s2,s3); puts("Printing string s2");
puts(s2);
printf("\n %d is the string length\n", strlen(s1)); if(strcmp(s1,s3)==0)
printf("\n The strings are equal"); else
printf("strings are not equal"); getch();
}


    1. Sorting and searching of names/strings




ALGORITHM:
Step 1: Start.
Step 2: declare name[10][8], tname[10][8], temp[8], I, j, n. Step 3: print enter the value of n
Step 4: read n
Step 5: print enter n names Step 6: repeat until i< n
Read name[i]
Copy name to tname using string function strcpy(tnmae[i], name[i])

Step 7: repeat until I < n – 1


Repeat until j < n
if(compare string name[i] and name[j] is > 0)
Copy name[i] to temp using string function strcpy(temp, name[i]) Copy name[j] to name[i] using string function strcpy(temp,
name[i])
Copy temp to name[j] using string function strcpy(temp, name[i])
Step 8: print input names and sorted names Step 9: repeat until i< n
Step 10: print tname[i] and name[i] Step 11: Stop.



Download 0,65 Mb.

Do'stlaringiz bilan baham:
1   ...   6   7   8   9   10   11   12   13   14




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish