Question

7 - What does the code print to the screen? float x(float) 7/3; printf ( % .2 f, x); a) 7/3 b) 2.50 c) 2.00 d) None of the

0 0
Add a comment Improve this question Transcribed image text
Answer #1

7. d) None of the above.

9 #include <stdio.h> 10 11 int main() 12 13 float x (float) 7/3; 11 4 15 print i (%. 2f,x); 2.33 Program finished with exit

float x = (float) 7/3; // This line converts the value of 7/3 into float and stores the vlaue in x. i.e., x = 2.333333

printf("%.2f", x); // This line fixes the value of x to 2 decimal points and prints the output. i.e., x = 2.33

The output is 2.33

Therefore the answer is None of the above.

8. b) TRUEFALSE

#include <stdio.h> 10 11 int main() 12- 13 int x 3; if(x 3 ||x 2) printf(TRUE); printf(FALSE); 15 17 inp TRUEFALSE ... Pr

int x = 3; //

if(x > 3 || x !=2) printf("TRUE"); // if the value of x is greater than 3 or if the value of x is not equal to 2 then it prints output TRUE.

printf("FALSE"); // Since this statement is outside the if condition it always get printed.

Hence the output is TRUEFALSE

9. c) TRUETRUETRUE

Output:

9 #include <stdio.h> 10 11 int main() 12- 13 14 switch(x 1)0 15 16 17 18 108 intx 3; case 3: printf(TRUE) case 4: printf(T

SYNTAX OF SWITCH:

switch(x){

case 1:

some statement

break;

case 2:

some statement

break;

case 3:

some statement

break;

default: some statement

}

int x = 3; // variable declaration

switch(x + 1){ // This is a switch statement. Since x =3, switch (x +1) becomes switch(4)

case 3: printf("TRUE"); // if(x = 3) it prints TRUE

case 4: printf("TRUE"); // if(x = 4) it prints TRUE. Since the variable x = 4(after coming into switch condition), case 4 gets printed.

default: printf("TRUE"); // by default if no case is true it prints this statement.

Since there is are no break statements in the switch case, the default statement also gets printed.

}

printf("TRUE"); // Since this statement is outside the switch condition it is printed everytime. This line is also printed.

Hence the output becomes TRUETRUETRUE.

Add a comment
Know the answer?
Add Answer to:
7 - What does the code print to the screen? float x(float) 7/3; printf ( "...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 10 What does the last printf in this code print to the screen? a)n-7 b)n- 0...

    10 What does the last printf in this code print to the screen? a)n-7 b)n- 0 c)n--1 d) None of the above 鬐include< stdio. h> int main) int n-0 for (n-7: n<O; n-- printf (n") printf ("n *%d", n); - return 11-What does the code print to the screen? 鬐include< stdio.h> void fun (int) int main) b) 8 d) None of the above fun (3) return void fun (int a) int x-10 while(a !_ 3 x > s} if a...

  • Question 1 The code used to output messages to the screen begins with run # print...

    Question 1 The code used to output messages to the screen begins with run # print output Flag this Question Question 2 The code used to begin a comment in the Python program source code is # Hello * Comment Flag this Question Question 3 A variable name is like a(n) input typed on a keyboard address in computer memory where values can be stored output to a computer screen value assigned to an address in computer memory Flag this...

  • What number does each line of code print out? Briefly explain why. printf("%u\n",(unsigned char)(-2)); printf("%d\n",(unsigned char)(-2));...

    What number does each line of code print out? Briefly explain why. printf("%u\n",(unsigned char)(-2)); printf("%d\n",(unsigned char)(-2));    printf("%u\n",(uint16_t)(-2)); printf("%d\n",(uint16_t)(-2));    printf("%u\n",(unsigned int)(-2)); printf("%d\n",(unsigned int)(-2));

  • 9. Which of the following is true for the following program? #include <stdio.h> int maino int...

    9. Which of the following is true for the following program? #include <stdio.h> int maino int i = 1; switch (0) case 1: printf("%d", 0); case 2: printf("%d", 0); case 3: printf("%d", 0); default: printf("%d", 1); return 0; } (2 points) The program has no error, the output is 1111 The program has no error, the output is 1 The program produces a compile time error, because there are no break statements The program produces a compile time error, because...

  • int main() { int a, Band3 = 0, Band1, Band2, b, c = 1; float t;...

    int main() { int a, Band3 = 0, Band1, Band2, b, c = 1; float t; while (c) { Band3 = 0; printf(" Enter Resistance Value: "); scanf_s("%d", &a); printf("\n Enter Tolerance Value: "); scanf_s("%f", &t); b = t * 100; while (a % 10 == 0) { Band3++; a = a / 10; } Band2 = a % 10; a = a / 10; Band1 = a % 10; printf("\n Band1 = %d, Band2 = %d, Band3 = %d...

  • should be in C language What is the output of the following segment of C code:...

    should be in C language What is the output of the following segment of C code: void CapsLetter (char* x, charl); int main() { char* text; text="This is some sample text."; CapsLetter(text, 'e'); printf("%s", text); return 0; سی void Caps Letter (char* x, char 1) { int i=0; while (x[i]!='\0') { if (x[i]==1) x[i]=1-32; } 1. This is som sample text. 2. THIS IS SOME SAMPLE TEXT. 3. This is some sample text. 4. this is some sample text. What...

  • PSUEDOCODE ONLY!! What is the output of the following code? CREATE x 1 SWITCH (x) Print...

    PSUEDOCODE ONLY!! What is the output of the following code? CREATE x 1 SWITCH (x) Print output here: Print output here: BREAK CASE 2: PRINTLINE (“hELLO wORLD”) CASE 3: PRINT (“HELLO WORLD”) BREAK CASE 4: PRINTLINE(“Hello”) CASE 5: PRINT(“World”) BREAK DEFAULT: BREAK

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

  • C Programming 1 point Given the following code, if Static() is called twice, what will be...

    C Programming 1 point Given the following code, if Static() is called twice, what will be printed to the screen from the second call? int x = 10; void Print(int x) printf("%d", x); } { void Output() { printf("%d", x); > void Static) { static int x = 0; printf("%d", x++); } Type your answer 8 1 point Given the following code, if Static() is called, what will be printed to the screen? int x = 10; void Print(int x)...

  • Covert C++ code into MIPS. -If x has a value if 2, print "bbb" if x...

    Covert C++ code into MIPS. -If x has a value if 2, print "bbb" if x has a value of 3, print "ccc" if x has a value of 4, print "ddd" if x has a value other than 2, 3, or 4 print "eee". result = ""; switch (x) { case 2: result = result + "bbb"; break; case 3: result = result + "ccc"; break; case 4: result = result + "ddd"; break; default: result = result +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT