1 / 6

# include < stdio.h > # include < ctype.h > # include < conio.h > #define B 20 int main()

Soru1: Dışardan "% s" format belirteci kullanılarak girilecek 20 elemanlı bir dizinin elemanlarının kaç tanesinin rakam, kaç tanesinin harf ve kaç tanesinin özel karakter olduğunu bulan bir program yazınız. # include < stdio.h > # include < ctype.h > # include < conio.h > #define B 20

gavril
Télécharger la présentation

# include < stdio.h > # include < ctype.h > # include < conio.h > #define B 20 int main()

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Soru1: Dışardan "%s" format belirteci kullanılarak girilecek 20 elemanlı bir dizinin elemanlarının kaç tanesinin rakam, kaç tanesinin harf ve kaç tanesinin özel karakter olduğunu bulan bir program yazınız. #include <stdio.h> #include <ctype.h> #include <conio.h> #define B 20 int main() { inti,d=0,s=0,o=0; char c[B]; scanf("%s",c); for(i=0;c[i]!='\0';i++) { d=isdigit(c[i])? d+1:d; s=isalpha(c[i])? s+1:s; o=isalnum(c[i])?o:o+1; } printf("Rakam:%d\nHarf:%d\nOzel Karakter:%d",d,s,o); getch(); return 0; }

  2. Soru2: " Enter" e basılıncaya kadar s[100] karakter dizisine metin girişi yaptıran bir program yazınız. Metni ekrana sadece küçük harfler ve sadece büyük harfler kullanarak yazdırınız. #include <stdio.h> #include <ctype.h> #include <conio.h> int main() { int i; char c[100]; gets(c); for(i=0;c[i]!='\0';i++) { printf("%c",tolower(c[i])); } printf("\n"); for(i=0;c[i]!='\0';i++) { printf("%c",toupper(c[i])); } getch(); return 0; }

  3. Soru3: Sırası ile tamsayıları temsil eden 4 stringi ve ondalıklısayıları temsil eden 4 stringiklavyeden alan bir program yazınız. Programınız bu stringleriçevirdikten sonra toplayarak, toplamı ve ortalamalarını ekrana yazdırsın. #include <stdio.h> #include <stdlib.h> #include <conio.h> int main() { int i; doublesum=0; char c[20]; for(i=1;i<9;i++) { scanf("%s",c); sum=(i<5)? sum+atoi(c):sum+atof(c); } printf("Toplam:%f\nOrtalama:%f",sum,sum/8); getch(); return 0; }

  4. Soru4: Girilen metini tersten yazan bir program yazınız. #include <stdio.h> #include <conio.h> void ters( const char * const ); int main() { char sentence[ 80 ]; printf( "Metingiriniz:\n" ); gets( sentence ); printf( "\nGirdiginizmetinintersi:\n" ); ters( sentence ); getch(); return 0; } void ters( const char * constsPtr ) { if ( sPtr[ 0 ] == '\0' ) return; else { ters( &sPtr[ 1 ] ); putchar( sPtr[ 0 ] ); } }

  5. Soru5: char*a[] = { "the", "a", "one", "some", "any" }; char *n[] = { "boy", "girl", "dog", "town", "car" }; char *v[] = { "drove", "jumped", "ran", "walked", "skipped" }; char *p [] = { "to", "from", "over", "under", "on" }; a->n->v->p->a->n sırasıyla bu dizilerden rasgele bir kelime seçerek alt alta 20 adet cümle oluşturan bir program yazınız. strcat( s, v[ rand() % 5 ] ); strcat( s, " " ); strcat( s, p[ rand() % 5 ] ); strcat( s, " " ); strcat( s, a[ rand() % 5 ] ); strcat( s, " " ); strcat( s, n[ rand() % 5 ] ); putchar( toupper( s[ 0 ] ) ); printf( "%s.\n", &s[ 1 ] ); s[ 0 ] = '\0'; } getch(); return 0; } #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <ctype.h> #include <conio.h> int main() { srand(time(NULL)); char *a[] = { "the", "a", "one", "some", "any" }; char *n[] = { "boy", "girl", "dog", "town", "car" }; char *v[] = { "drove", "jumped", "ran", "walked", "skipped" }; char *p[] = { "to", "from", "over", "under", "on" }; char s[ 100 ] = ""; int i; for ( i = 1; i <= 20; i++ ) { strcat( s, a[ rand() % 5 ] ); strcat( s, " " ); strcat( s, n[ rand() % 5 ] ); strcat( s, " " );

  6. Soru5: Verilen 5 adet ismi alfabetik sırayla yazan programı yazınız. #include <stdio.h> #include <conio.h> #include <string.h> int main() {inti,j; char a[5][20]={"yazgan","baris","osman","cafer","zeynep"}; for(i=0;i<5;i++)puts(a[i]); char yedek[20]; printf("\n"); for(i=0;i<4;i++) for(j=i+1;j<5;j++) { if(strcmp(a[i],a[j])>0){ strcpy(yedek,a[i]); strcpy(a[i],a[j]); strcpy(a[j],yedek);} } for(i=0;i<5;i++)puts(a[i]); getch(); return 0; }

More Related