Name this program unique c The program takes one command li

Name this program unique. c - The program takes one command line argument - a legal word (it consists of only upper- and lower-case letters). Your program should output the number of unique letters (if you see an uppercase A and lowercase a in the same word, that is the same letter appearing twice) that exist within the word. Sample executions are shown below:

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(\"There are %d unique letters.\",distinct);
return 0;
  
}

 Name this program unique. c - The program takes one command line argument - a legal word (it consists of only upper- and lower-case letters). Your program shou

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site