Lesson 2 of 23

Variables এবং Format Specifiers

9 min 20 XP

C-তে আগে variable-এর type declare করা হয়: int (পূর্ণসংখ্যা), float/double (দশমিক), char (একটি অক্ষর)। Values print করতে printf format specifiers ব্যবহার করে: int-এর জন্য %d, double-এর জন্য %f, char-এর জন্য %c।

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

%.2f দুই দশমিক স্থান পর্যন্ত print করে। sizeof() বলে একটি type কত bytes নেয়। const variable বদলানো যায় না।

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

ভুল specifier (যেমন int-এর জন্য %f) দিলে আবর্জনা print হয়। Interviewer-রা সত্যিই format specifiers নিয়ে প্রশ্ন করেন!

Challenge

+20 XP

int variable marks-এ 87 এবং double variable percent-এ 87.5 রাখুন, তারপর print করুন: Marks: 87 Percent: 87.50

Output Loading C (first time takes a few seconds)
Press Run to see the result here.