In this code it need to calculate the number of times the operators appear. It doesn't calculate it and while running the code it prints "Please enter a note. to finish press Q:" twice and i don't know whats wrong.
#include <stdio.h>
int main(void)
{
char note;
int result1 = 0, result2 = 0, result3 = 0, result4 = 0;
do
{
printf("Please enter a note. to finish press Q:\n");
scanf("%c", ¬e);
switch (note)
{
case'+':
result1 = result1 + 1;
break;
case'-':
result2 = result2 + 1;
break;
case'*':
result3 = result3 + 1;
break;
case'/':
result4 = result4 + 1;
break;
}
} while (note != 'Q');
printf("+ appears %d times\n", result1);
printf("- appears %d times\n", result2);
printf("* appears %d times\n", result3);
printf("/ appears %d times\n", result4);
system("pause");
}