fortran counting vowels (each and total) PROGRAM countingvowels ! Program to pro
ID: 3760503 • Letter: F
Question
fortran counting vowels (each and total)
PROGRAM countingvowels
! Program to provide a count for each and total vowels.
! Program to read a string and count the vowels.
! Vowels (“a”, “e”, “i”, “o”, and “u”).
! vowels should be counted for both upper and lower-case.
! Assume the input string may be no longer than 1000 characters.
! declare variables
implicit none
INTEGER :: i, Vowels=0
CHARACTER(80) :: Line
!---------------------------
! Display initial header
WRITE (*,'(a,/)') "Count for each and total vowels"
!----------------------------
! Prompt for string
! read string
WRITE (*,'(a)',advance="no") "Enter String (80 char max): "
READ (*,'(a)') Line
!----------------------------
! loop
DO I = 1, len (Line)
SELECT CASE (Line (I:I))
CASE ('A','E','I','O','U', &
'a','e','i','o','u')
Vowels = Vowels + 1
END SELECT
END DO
!-----------------------------
! display final string
WRITE (*,'(/,a)') "------------------------------------"
WRITE (*,'(a,/,2x,a,/)') "Vowels: ", Vowels
END program countingvowels
I have done this so far, please fix this can count (each and total) vowels
Explanation / Answer
#include<stdio.h>
#include<conio.h>
void main()
{
char str[50];
int vowels = 0, i = 0;
clrscr();
printf(“ ENTER A STRING…: “);
gets(str);
while(str[i] != ‘)
{
if(str[i]==’A’ || str[i]==’a’ || str[i]==’E’ || str[i]==’e’ || str[i]==’I’ || str[i]==’i’ ||
str[i]==’O’ || str[i]==’o’ || str[i]==’U’ || str[i]==’u’)
vowels++;
i++;
}
printf(“ THE TOTAL NUMBER OF VOWELS IS…: %d”, vowels);
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.