int main(void) {         int a;         char *s;         int v0 = 9, v1 = 0, v2 = 0, v3 = 0;           printf("Exercise 1:\n====

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

Run the following code and answer the questions.

 

#include <stdio.h>

 

int main(void) {

        int a;

        char *s;

        int v0 = 9, v1 = 0, v2 = 0, v3 = 0;

 

        printf("Exercise 1:\n====================\n");

 

        switch(v0) {

               case 0: printf("Good day\n");   break;

               case 1: printf("Hey There!\n");    break;

               case 2: printf("No Name\n");  break;

               case 3: printf("Yes Please\n"); break;

               case 4: printf("Go ");        

               case 5: printf("Vamos!\n");                

               default: printf(" ");               break;

        }

 

        for(v1; v1<v2; v1=v1+v1) {

               printf("Vamos ");

        }

        printf("\n");

 

        if (v2 == 6) {

            s = "Go";

        }

 

 

        if(v3 != 0) {

               printf("%s VAMOS!\n",s);

        }

 

        return 0;

}

 

  1. What is the output of the program? Please explain why using the variables v0, v1, v2, and v3.
  2. The code has a vulnerability that can prevent the program from outputting properly. Explain what the problem is. What are the values of v0, v1, v2, and v3 that may cause such problem?
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning