Created
June 11, 2012 10:24
-
-
Save ZNickq/2909469 to your computer and use it in GitHub Desktop.
Cifra de control a unui numar
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
#include<stdio.h> | |
using namespace std; | |
int cate_cifre(int check) { | |
int rasp = 0; | |
while(check>0) { | |
check/=10; | |
rasp++; | |
} | |
return rasp; | |
} | |
int reduce(int orig) { | |
int rasp = 0; | |
while(orig!=0) { | |
rasp+=orig%10; | |
orig/=10; | |
} | |
return rasp; | |
} | |
int main() { | |
int numar; | |
printf("Introduceti numar: "); | |
scanf("%d",&numar); | |
while(cate_cifre(numar) > 1) | |
numar = reduce(numar); | |
printf("Cifra de control a numarului este %d\n",numar); | |
return 0; | |
} |
You should leave a blank line between the programm's functions.Beside this,your code looks good.
@taygun Yeah, completely forgot about that! Fixing now...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Programul pare ok.