Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
533 Widoki

Hello this is Gulshan Negi

Well, I am writing a program for making Calculator in C but it shows some error at the time of its execution.

Here is my source code: 

#include
#include
#include
#include

int Sum_of_Digits(int digit)
{
int sum =0;
while(digit > 0)
{
sum +=(digit%10);
digit/=10;
}
return sum;
}

void main()
{
char name[100], partner[100];
int p,ns = 0, ps =0,love =54,i,j,love_percentage, opt;
clrscr();

do
{
printf("Enter Your Name: ");
get(name);

printf("Enter Your Partner Name: ");
gets(partner);

for(i =0; i
{
ns += (tolower(name[i])-96);
}

for(j = 0; partner[j] != '\0'; j++)
{
ps+=(tolower(partner[j])-96);
}
p= Sum_of_Digits(ns);
love_percentage = (Sum_of_Digits(ns)+Sum_of_Digits(ps)+love);
printf("The Love Percentage is %d", love_percentage);
printf("\nPress 1 To continue or 0 to Exit: ");
scanf("%d",&opt);

}while(opt!=0);
getch();
}


can anyone give their suggestions on this?

Thank you

Awatar
Odrzuć