C প্রোগ্রামের Constants ও Variables

Submitted by tushar pramanick on Mon, 02/25/2013 - 09:32

Constants and Variables

Constant এর value  কখনোই চেঞ্জ হয় না। অন্যদিকে  variable কে ব্যবহার করা হয় ভিন্ন ভিন্ন ভ্যালু কে দেখানোর জন্য ।

যেমন ধরো CD disc এবং পেনড্রাইভ। সিডি ডিস্ক এর মধ্যেে রাখা গানগুলিকে কখনোই চেঞ্জ করা যায় না কিন্তু পেনড্রাইভ এর মধ্যে রাখা গানগুলিকে মুছে দিয়ে আবার লেখা যায়। constant হল সিডি ডিস্ক এর মত are variable হল পেনড্রাইভ এর মত। variable এর value সর্বদাই চেঞ্জ করা যায়।

যেমন মনে করো

i = 1;

যেখানে symbol 1 constant কারণ একের ভ্যালু সর্বদাই এক । এবং symbol i কে assign করা হয়েছে constant 1 দিয়ে। অন্যভাবে বলা যায় i এর value one হবে যখন প্রোগ্রাম লাইনটি execute হবে।

 পরে  যদি অন্য কোন স্টেটমেন্ট দিয়ে আই এর value কে চেঞ্জ করা হয়, যেমন

i = 10;

এবার পরে program লাইনটি  execute করা হয় তাহলে  i  এর value  পরিবর্তন হয়ে 10 হবে । এক্ষেত্রে  i এর value  পরিবর্তন হল । যেহেতু  আই এর ভ্যালু প্রথমে ছিল 1 এবং পরে পরিবর্তিত হয়ে  10 হল  সেই জন্য  symbol i কে বলা হবে variable।

ওরে যখন কিছু প্রোগ্রামের উদাহরণ আলোচনা করা হবে তখন constant এবং variable এর ধারনা আরো পরিস্কার হবে।

Comments

Related Items

The #define and #undef Directives

The #define and #undef Directives

The #define directive is the most common preprocessor directive, which tells the preprocessor to replace every occurrence of a particular character string (that is, a macro name) with a specified value (that is, a macro body).

The C Preprocessor Versus the Compiler

The C Preprocessor Versus the Compiler

One important thing you need to remember is that the C preprocessor is not part of the C compiler.

What Is the C Preprocessor?

If there is a constant appearing in several places in your program, it's a good idea to associate a symbolic name to the constant, and then use the symbolic name to replace the constant throughout the program. There are two advantages to doing so. First, your program will be more readable.

Exercises : Answer the following Question

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

Question and Answer

    Q Why is random access to a disk file necessary?