Bachelor of Technology in Information Technology



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

SOURCE CODE:


#include #include #include void main()


{
char name[10][8], tname[10][8], temp[8]; inti, j, n;
printf("Enter the value of n \n"); scanf("%d", &n);
printf("Enter %d names n", n);

for (i = 0; i< n; i++)


{
scanf("%s", name[i]);
strcpy(tname[i], name[i]);
}
for (i = 0; i< n - 1 ;i++)
{
for (j = i + 1; j < n; j++)
{
if (strcmp(name[i], name[j]) > 0)
{
strcpy(temp, name[i]); strcpy(name[i], name[j]); strcpy(name[j], temp);
}
}
}printf("\n \n");
printf("Input NamestSorted names\n"); printf(" \n");
for (i = 0; i< n; i++)
{
printf("%s\t\t%s\n", tname[i], name[i]);
}
printf(" \n");
getch(); }


  1. Reversing a string ALGORITHM:


Step 1: Start.


Step 2: declare s[1000], r[1000], begin, end, count ← 0. Step 3: print input a string
Step 4: read s
Step 5: using while loop with condition s[count] !← '\0' Count++

Step 6: End ← count - 1


Step 7: repeat until begin < count Step 8: r[begin] ← s[end]
end-- Step 9: r[begin] ← '\0' Step 10: print r
Step 11: print string reverse using library function Step 12: print enter a string to reverse
Step 13: read s
Step 14: reverse the string s using string function strrev(s). Step 15: print reversed string.
Step 16: Stop.


SOURCE CODE:


#include #include int main()


{
char s[1000], r[1000]; int begin, end, count = 0;

printf("Input a string\n"); gets(s);


// Calculating string length

while (s[count] != '\0') count++;


end = count - 1;
for (begin = 0; begin < count; begin++) { r[begin] = s[end];
end--;
}
r[begin] = '\0';

printf("%s\n", r);


// string reverse using a library function puts("String reverse using library function\n"); printf("Enter a string to reverse\n");
gets(s); strrev(s);
printf("Reverse of the string is \n%s\n", s); return 0;
}
------------------------------*-----------OUTPUT----------------*------------------------
Input a string Hello
olleH









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