Sample Midterm: Foundations of x | My Assignment Tutor

Lecture CaptureX Sample Midterm: Foundations of xGmelbourne time – Google Search x+€ → UN MEMELBOURNEUnansweredQuestion 2Not yet graded / 3 ptsScreenshot has been savedto GalleryCol38O O O © © CO->Write a program countvowel that reads a line from keyboard as the input and printsthe number of vowels in that line. A line is a sequence of characters (including digits)that ends with a newline character (‘n’). The vowels are ‘a’, ‘e’, 1, ‘6’, and ‘u! Thecharacters can be either lower case or upper case letters. Some examples of the inputsand outputs are –mac: ./countvowelEnter a line: Mary had a little lambNumber of vowels: 6mac: ./countvowelEnter a line: Hello worldNumber of vowels: 3mac: ./countvowelEnter a line: 1234Number of vowels: 0Your Answer: include include define NEWLINE ‘n’ intmain(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’ || c == ‘e’ || C == ‘i’ || C == ‘o’ || C == ‘u’||| C == ‘A’ || C == ‘E’ ||C == ‘T’ || C == ‘O’ ||C == ‘U’) { nvowels += 1; } } / generate the required report */printf(“Number of vowels: %dn”, nvowels);return 0;}UnansweredQuestion 3Not yet graded / 3 pts |Write a recursive function int fibonacci rec(int n) that returns the nth number in theType here to search9 ) ENG9:10 PM31/03/20215


Leave a Reply

Your email address will not be published.