hey guys i got a problem with my program i cant get it to work properly.
The question is:
Write a C/C++ program to count the vowels and letters from the keyboard (maximum 50 characters). The string may contain spaces.
Then it prints out the number of occurrences of each of the vowels a, e, i, o and u, the total number of letters, and each of the vowels as an integer percentage of the letter total.
If the input contains
What a beautiful day!
Suggested output format is:
You enterted: What a beautiful day!
Numbers of characters:
a:4 e:1 i:1 o:0 u:2 rest:13
Percentages of total:
a:19.05% e:4.76% i:4.76% o:0.00% u:9.52% rest:61.90%
and this is my program:
#include<stdio.h>
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
void main()
{
int j,k;
float a,e,i,o,u;
int A,E,I,O,U;
char word[50];
printf("Enter First string: ");
scanf("%49[^\n]%c", word);
word = strlen(word);
for(j=0;j<=k;j++)
{
if ('a'==word[j])
a++;
if ('e'==word[j])
e++;
if ('i'==word[j])
i++;
if ('o'==word[j])
o++;
if ('u'==word[j])
u++;
}
printf("You Typed: ");
printf("a:%d\t e:%d\t i:%d\t o:%d\t u:%d\t ", a, e, i, o, u);
printf("Percantage Of Letter:");
A=(a/k)*100;
E=(e/k)*100;
I=(i/k)*100;
O=(o/k)*100;
U=(u/k)*100;
printf("a: %f\t e:%f\t i:%f\t o:%f\t u:%f\t", A, E, I, O, U);
}
Thanxs
<< moderator edit: added [code][/code] tags >>