
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;
}
- What is the output of the
program ? Please explain why using the variables v0, v1, v2, and v3. - 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?

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- 5- What is the output for y? int y = 0; for (int i = 0; i< 10; ++i) { y +=i; } cout << y;arrow_forwardConvert totalYears to millennia, decades, and years, finding the maximum number of millennia, then decades, then years. Ex: If the input is 9011, then the output is: Millennia: 9 Decades: 1 Years: 1 Note: A millennium has 1000 years. A decade has 10 years #include <iostream>using namespace std; int main() { int totalYears; int numMillennia; int numDecades; int numYears; cin >> totalYears; cout << "Millennia: " << numMillennia << endl; cout << "Decades: " << numDecades << endl; cout << "Years: " << numYears << endl; return 0;}arrow_forwardLook at the following code. int x = 7; int *ptr = &x;What will be displayed if you send the expression *iptr to cout? What happens if you send the expression ptr to cout?arrow_forward
- 9. If you are given this code: #include #include #include int main() { float num1, num2; float calculation; float pi=3.14; float e 2.72; printf("\nEnter First Number:\t"); scanf("%f", &num1); printf("\nEnter Second Number:\t"); scanf("%f", &num2); calculation = (num1*num2*pi)/(e); printf("\nThe calculation is: %f", calculation); printf("\n"); return 0; } Modify this code by using functions and global declarations (instead of locals).arrow_forward3. int FINAL= 9; 4. void tryMe(int, int&); 5. int main() 6. { 7. int x = 2, y = 3; 8. int count; 9. 10. tryMe(x, y); 11. cout << "x: " << x << endl << "y: " << "y: " << y << endl; 12. X += 2; 13. tryMe(y, х); 14. cout << "x: " << x << endl << "y: " << "y: " <arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





