Last active
December 14, 2015 12:18
-
-
Save austa/5085121 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* File: main.c | |
* Author: alaattin | |
* | |
* Created on 04 Mart 2013 Pazartesi, 17:58 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
#define SIZE 50 | |
/* | |
* | |
*/ | |
int main(int argc, char** argv) { | |
char metin[SIZE]; | |
int toplam = 0; | |
int i = 0; | |
int sayisal = 0 ; | |
printf("Bir metin giriniz: \n"); | |
gets(metin); | |
for(i=0; i<SIZE; i++){ | |
if(metin[i] == '\0') | |
break; | |
else{ | |
if(isdigit(metin[i]) != 0){ | |
toplam +=metin[i] - 48; | |
} | |
} | |
} | |
printf("Toplam %d\n", toplam); | |
return (EXIT_SUCCESS); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
metindeki rakamsal ifadenin sayısal karşılığına ulaşmak için ascii ye bir bak derim.
ör: ascii 48 = 0
o zaman
toplam +=metin[i] - 48;
değişikliğini yaparsan sayısal karşılıklara ulaşmış olursun...