Skip to content

Instantly share code, notes, and snippets.

@Evshved
Created December 8, 2014 19:58
Show Gist options
  • Select an option

  • Save Evshved/46503999c1fdbd6f9cf8 to your computer and use it in GitHub Desktop.

Select an option

Save Evshved/46503999c1fdbd6f9cf8 to your computer and use it in GitHub Desktop.
7
#include <vcl.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <classes.hpp>
#pragma hdrstop
int main()
{
int sum = 0, i=0,n,count,b;
char Str[100];
fflush(stdin);
printf("Input string ");
gets(Str);
n = strlen(Str);
for (count=0;count<n;count++) {
TryStrToInt(Str[count],b);
switch (b){
case 1: sum+=1;
break;
case 2: sum+=2;
break;
case 3: sum+=3;
break;
case 4: sum+=4;
break;
case 5: sum+=5;
break;
case 6: sum+=6;
break;
case 7: sum+=7;
break;
case 8: sum+=8;
break;
case 9: sum+=9;
break;
}
}
printf("%d",sum);
getchar();
getchar();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment