Name this program distinct c Each commandline argument will

Name this program distinct. c - Each command-line argument will contain only letters (uppercase and/or lowercase). Print the number of distinct letters that appear in each argument. For this problem, an uppercase X and lowercase x in the same argument are considered to be the same letter and art\' not counted as distinct.

Solution

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
if(argc<=1) {
printf(\"Please pass atleast one integer\");
exit(1);
}
  
int count[256] = {0};
int distinct = 0;
int i=0;
char *p;
int index;
  
for(p = argv[1]; *p != 0; p++)
{
index = *p;
count[index]++;
}
  
int count = 0;
  
for(i=0;i<256;i++)
{
if(count[index]>0)
distinct++;
}
  
printf(\"%s = %d unique letters.\",argv[1],distinct);
return 0;
  
}

 Name this program distinct. c - Each command-line argument will contain only letters (uppercase and/or lowercase). Print the number of distinct letters that ap

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site