Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C program to check vowel or consonant using command line arguments


What I have tried:

C++
#include <stdio.h>
 
int main()
{
  char ch;
 
  printf("Input a character\n");
  scanf("%c", &ch);
 
  if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' &&ch <= 'Z')) {
    if (ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch== 'u' || ch=='U')
      printf("%c is a vowel.\n", ch);
    else
      printf("%c is a consonant.\n", ch);
  }
  else
    printf("%c is neither a vowel nor a consonant.\n", ch);
 
  return 0;
}
Posted
Updated 16-Sep-21 23:02pm
v5
Comments
Patrice T 30-Jan-18 10:45am    
And you hve a question or a problem?
Jochen Arndt 30-Jan-18 10:45am    
And what is your question?

The only advice I can give is to read the assignment again.
The keyword is "command line argument".
F-ES Sitecore 30-Jan-18 10:51am    
google "use command line arguments c"
Rick York 30-Jan-18 10:56am    
Some recommendations for you : look at the isalpha and tolower functions and their relatives. They will cut the number of checks you have to make in half.

1 solution

Handling command line arguments with C programming is part of each C programming book and online tutorial.

A quick web research will give you a lot of examples. I picked some for you:
A Little C Primer/C Command Line Arguments - Wikibooks, open books for an open world[^]
The GNU C Library: Program Arguments[^]
How to parse command line parameters. - C++ Articles[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900