This might be a silly question, but I am unable to find the solution. Function mat is not being called after giving input to variable n.
#include <stdio.h>
#include <stdlib.h>
int mat(int n)
{
printf("hello");
int temp = n, count = 0;
while (temp != 0)
{
temp = n % 10;
switch (temp)
{
case 1:
count += 2;
break;
case 7:
count += 3;
break;
case 4:
count += 4;
break;
case 2:
case 3:
case 5:
count += 5;
break;
case 6:
case 0:
case 9:
count += 6;
break;
case 8:
count += 7;
break;
}
}
return count;
}
int main(void)
{
int t, n, h;
scanf("%d", &t);
while (t--)
{
scanf("%d", &n);
h = mat(n);
printf("%d\n", h);
}
}
I think something is wrong with scanf but don't know what it is. this program was to give the output for number of matches being used for particular number.