A line is a sequence of characters | My Assignment Tutor

me P Type here to search4Lecture Capturex A. Sample Midterm: Foundations c. x ® melboume time – Google Search X +O canvas.lms.unimelb.edu.au/courses/107518/quizzes/109018 II 1:1 2 1°2 $1 Ej0 X OAar 000 0006,4 OX101 Question 2Not yet graded / 3 ptsWrite a program countvowel that reads a line from keyboard as the input and prints the number of vowels in that line. A line is a sequence of characters (including digits) that ends with a newline character (‘In’). The vowels are a, e, ‘o’, and ‘u’. The characters can be either lower case or upper case letters. Some examples of the inputs and outputs are –mac: ./countvowel Enter a line: Mary had a little lamb Number of vowels: 6 mac: ./countvowel Enter a line: Hello world Number of vowels: 3 mac: ./countvowel Enter a line: 1234 Number of vowels: 0Your Answer: include #include define NEWLINE ‘ n’ int main(int argc, char argv[]) int nvowels=0; int c; / read characters from the input/ printf(“Enter a line:”); while ((c=getchar()) != ‘n’) { if (c == ‘a’ Ilc == ‘e’ ‘lc == ‘r II c == ‘0’ IIc == c == ‘A’ III == ‘E’ 11c == ‘I’ II c == ‘0’ IIc == nvowels += 1; / generate the required report */ printf(“Number of vowels: %d n”, nvowels); return 0;•=1, Question 3Not yet graded / 3 ptsWrite a recursive function int fibonacci_rec(int n)) that returns the nth number in the1 -Tr5 g 40 V OPM ENG 31/03/2021 kg


Leave a Reply

Your email address will not be published. Required fields are marked *