convert basic if else if to while.

can someone guide me on how to turn this into a WHILE format?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<stdio.h>
#include<string.h>
main(){
       
char mess[50],space=0;
int len,i,ca=0;

printf("Enter Message: ");
gets(mess);

for(i=0;i<=len;i++){
  
  if(mess[i]=='a' || mess[i]=='A')
    ca++;                  
  else if(mess[i]=='e' || mess[i]=='E')
    ca++; 
  else if(mess[i]=='i' || mess[i]=='I')
    ca++; 
  else if(mess[i]=='o' || mess[i]=='O')
    ca++; 
  else if(mess[i]=='u' || mess[i]=='U')
    ca++; 
  else if(mess[i]==' ')
    space++;                 
}

printf("Total Number of Vowels: %d\n",ca);
printf("Total Number of Spaces: %d\n",space);
             
getch();       
}
This for loop: for (i=0; i<=len; i++){
is doing the same thing as
while (i<=len){
but you have to set the initial value and increment the variable separately.
gee thanks man!
Topic archived. No new replies allowed.