C Ödev
-
Selam hocalar. kız arkadaşımın c ödevi var da ben tbtye güvenip hallederim demiştim :) saat 12 ye kadar yapılması gerekiyomuş. bi el atın lütfen.
kac soru yapabiliyosanız yapın o da yeter. bi soru bi sorudur :)
bi de ingilizce olmadığı için çeviri yapamadım birebir kopyaladım kusura bakmayın.
1. (20 pts.) Write a C program that reads a string from keyboard and converts lower-case
letters to upper-case, and upper-case letters to lower-case. You have to use a pointer
while moving on the string and case converting must be on the same string.Enter a string:
She Sells Sea Shells By The Seashore.
Case converting yields:
sHE sELLS sEA sHELLS bY tHE sEASHORE.
2. (20 pts.) Write a program that counts and lists the number of all English letters in a
given string. Your program should be case-insensitive, i.e. lower-case and upper-case
letters should be counted together. You have to use a pointer while moving on the
string.
Enter a string:
She Sells Sea Shells By The Seashore.
Number of each letter in the string:
A : 2
B : 1
E : 7
H : 4
L : 4
O : 1
R : 1
S : 8
T : 1
Y : 13. (20 pts.) Write a C program that finds the sequence of letters “foo” in a string given by
keyboard, and replaces it by the letters “bars”. You have to use a pointer while moving
on the string.4. (15 pts.) Like the first question of the second homework, read N integers from
keyboard and rewrite them in reverse order. However, using indices is prohibited, you
have to use pointers. If you use any indices, like arr[i], then you’ll be graded as zero
from this question.5. (15 pts.) Write a C program that reads N integers from keyboard and finds the sequence
of integers “9-1-1” in the array and replaces them by the sequence “1-1-2”. You have
to use a pointer while moving on the array.
Note: You’ll get the remaining 10 points from your comments and indentation. -
hocam kolaymıs gecen sene olsaydı yapardım.simdi c aklımdan tamamen cıkmıs durumda..uplayalım bari
-
hocam bu 2. sorunun hemen hemen aynısı sadece q girince sonuç veriyodu bizim 1. sınıf ödeviydi switch in içindeki case leri tüm harflere uyarlarsanız tam istediğiniz gibi çalışır
#include <stdio.h> main() { int a=0,b=0,c=0,other=0; char karakter; while((karakter=getchar()) != 'q'){ switch(karakter){ case 'a': a += 1;break; case 'b': b += 1;break; case 'c': c += 1;break; default: other += 1; } } printf("a:%d\n b:%d\n c:%d\n other:%d\n",a,b,c,other); }
-
ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.
1)
#include <stdio.h> #include <ctype.h> int main() { char text[256] = {0}; char *ptr = text; printf("Enter a string:\n"); fgets(text, sizeof(text)-1, stdin); do { if (islower(*ptr)) { *ptr = toupper(*ptr); } else { *ptr = tolower(*ptr); } } while(*++ptr); printf("Case converting yields:\n%s", text); return 0; }
2)
#include <stdio.h> #include <ctype.h> int main() { int i, counts[256] = {0}; char text[256] = {0}; char *ptr = text; printf("Enter a string:\n"); fgets(text, sizeof(text)-1, stdin); do { if (isalpha(*ptr)) { *ptr = toupper(*ptr); counts[*ptr]++; } } while(*++ptr); printf("Number of each letter in the string:\n"); for (i=0; i<256; i++) { if (counts[i]) { printf("%c : %d\n", i, counts[i]); } } return 0; }
3)
#include <stdio.h> #include <ctype.h> #include <string.h> int main() { char text[256] = {0}, shadow[512] = {0}; char *ptrText = text, *ptrShadow = shadow; int i, len = 0; printf("Enter a string:\n"); fgets(text, sizeof(text)-1, stdin); len = strlen(text); for (i=0; i<len-2; i++) { if (*ptrText == 'f' && *(ptrText+1) == 'o' && *(ptrText+2) == 'o') { strcat(shadow, "bars"); ptrText+=3; ptrShadow+=4; } else { *ptrShadow++ = *ptrText++; } } printf("Replaced text:\n%s", shadow); return 0; }
-
Tugberk bunu yazdı
ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.
1)
#include <stdio.h> #include <ctype.h> int main() { char text[256] = {0}; char *ptr = text; printf("Enter a string:\n"); fgets(text, sizeof(text)-1, stdin); do { if (islower(*ptr)) { *ptr = toupper(*ptr); } else { *ptr = tolower(*ptr); } } while(*++ptr); printf("Case converting yields:\n%s", text); return 0; }
2)
#include <stdio.h> #include <ctype.h> int main() { int i, counts[256] = {0}; char text[256] = {0}; char *ptr = text; printf("Enter a string:\n"); fgets(text, sizeof(text)-1, stdin); do { if (isalpha(*ptr)) { *ptr = toupper(*ptr); counts[*ptr]++; } } while(*++ptr); printf("Number of each letter in the string:\n"); for (i=0; i<256; i++) { if (counts[i]) { printf("%c : %d\n", i, counts[i]); } } return 0; }
3)
#include <stdio.h> #include <ctype.h> #include <string.h> int main() { char text[256] = {0}, shadow[512] = {0}; char *ptrText = text, *ptrShadow = shadow; int i, len = 0; printf("Enter a string:\n"); fgets(text, sizeof(text)-1, stdin); len = strlen(text); for (i=0; i<len-2; i++) { if (*ptrText == 'f' && *(ptrText+1) == 'o' && *(ptrText+2) == 'o') { strcat(shadow, "bars"); ptrText+=3; ptrShadow+=4; } else { *ptrShadow++ = *ptrText++; } } printf("Replaced text:\n%s", shadow); return 0; }
Hayattan soguma sebebi yeminle
-
Tugberk bunu yazdı
ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.
hocam aynısını kopyaladım gonderdim. programı çalıştı ama ekranda göstermedi. çalıştığı gibi kapandı. fazla kurcalamaya vakitte yoktu öylece gonderdim. cok saol hocam eyv
-
Seastar bunu yazdıTugberk bunu yazdı
ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.
hocam aynısını kopyaladım gonderdim. programı çalıştı ama ekranda göstermedi. çalıştığı gibi kapandı. fazla kurcalamaya vakitte yoktu öylece gonderdim. cok saol hocam eyv
#include <conio.h> ve return den önce getch();
-
manyaki bunu yazdıSeastar bunu yazdıTugberk bunu yazdı
ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.
hocam aynısını kopyaladım gonderdim. programı çalıştı ama ekranda göstermedi. çalıştığı gibi kapandı. fazla kurcalamaya vakitte yoktu öylece gonderdim. cok saol hocam eyv
#include <conio.h> ve return den önce getch();
12 ye kadardı pek vakit olmadı öyle gönderdim. çok fazla bi puan kırmaz sanırsam
-
Seastar bunu yazdımanyaki bunu yazdıSeastar bunu yazdıTugberk bunu yazdı
ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.
hocam aynısını kopyaladım gonderdim. programı çalıştı ama ekranda göstermedi. çalıştığı gibi kapandı. fazla kurcalamaya vakitte yoktu öylece gonderdim. cok saol hocam eyv
#include <conio.h> ve return den önce getch();
12 ye kadardı pek vakit olmadı öyle gönderdim. çok fazla bi puan kırmaz sanırsam
algoritmaya baksın yeter sktr et cıktısını :)
-
devc++ ta çalıştırdıysa
system("pause");
return 0;
yazarsa en sona ekran kalır
saat 12 yi geçti ama faydasını görür ilerde