Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi so its just quic standard c programming questions... 1. float x; x =0.35==3.5

ID: 3880067 • Letter: H

Question

Hi so its just quic standard c programming questions...

1. float x;

x =0.35==3.5/10;

printf("%f",x);

The answer listed is 1.000000 and I was wondering why that is?

2. int num = 2;

int a=5;

num = -a++-num;

printf( "%d,%d", num,a);

The answer listed is -7,6 why is num now -7 and why is a now 6? Also for the "%d,%d" part shouldnt it be "%d","%d" or no?

Lastly

Q.3

int x= 130;

if(x>=0 && x<=100)

printf("Valid grade");

else

{

if(x<0)

printf("Under range!!");

else

printf("Over range!!");

}

The anser for this is Over range!! but can somebody explain why that is or the process?

Thank you

Explanation / Answer

float x;

x =0.35==3.5/10;

printf("%f",x);

Here x is float

x =0.35==3.5/10; In this statement a boolean value is assigned to x

x = 0.35 == 0.35 => 1

while print the x value it prints in format of float value .

Question 2:

In this statement num = -a++ - num;

num = -5 - 2;

num = -7

Then the incrementation of a is done a = 6

If you use "%d","%d" it prints garbage value, You shounldnt use "%d","%d".

Question 3:

int x = 130;

if (x >= 0 && x <= 100) // Condition fails as beacuse x <= 100 is false

printf("Valid grade");

else

{

if (x < 0)   // Condition fails as beacuse x < 0 is false

printf("Under range!!");

else // Is been executed

printf("Over range!!");

}

An if condition executes the statement when condition is passed if nor it moves to else statement.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote