goldshakil / ElectricalProgrammingCourse2020

This repository is aimed towards sharing and discussing issues about Electrical and Electronics Programming Course
6 stars 1 forks source link

Assignment3 Lecture 3 slides 42 justification #28

Open EEE2017Assignments opened 4 years ago

EEE2017Assignments commented 4 years ago

In slide 42, the numbers in output are right justified, but the code was printf("%4d", y); So I think it is left justified. My output and slide's output is little bit different. Just write same with slide or change it %4d to %-4d?

Thank you.

goldshakil commented 4 years ago

I didn't check the code but %Xd is right justified if X is positive. And left justified if X is negative.

If the printed number is wider than X then it doesn't matter whether X is positive/negative, It'll be left justified.

https://www.dummies.com/programming/c/how-to-format-with-printf-in-c-programming/

The ppt might have some problems.

EEE2017Assignments commented 4 years ago

Then I'm gonna write the codes same with the ppt's codes.

Thank you, TA.