Hello, thanks for looking at my thread. Is there a data type which can be either a number or letter. So you can input a character or number and it will treat then as the same and still carry out the function only with a number or letter?
Here is the code just you get the general idea. You input how many number you want and which number you want to search for. It then tells you how many times that number appears. But as said earlier I was wondering if it was possible to do this with either numbers or letters.Code:#include<stdio.h>
int main(void)
{
int array[100], search, c, n, count = 0;
printf("Enter the number of elements in array\n");
scanf("%d",&n);
printf("Enter %d numbers\n", n);
for ( c = 0 ; c < n ; c++ )
scanf("%d",&array[c]);
printf("Enter the number to search\n");
scanf("%d",&search);
for ( c = 0 ; c < n ; c++ )
{
if ( array[c] == search )
{
printf("%d is present at location %d.\n", search, c+1);
count++;
}
}
if ( count == 0 )
printf("%d is not present in array.\n", search);
else
printf("%d is present %d times in array.\n", search, count);
if ( count == 2)
printf("One Pair");
if ( count == 3)
printf("Three of a kind");
if ( count == 4)
printf( "Four of a kind");
return 0;
}