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

Adding More Expressions into for

Adding More Expressions into for

The C language allows you to put more expressions into the three expression fields in the for statement. Expressions in a single expression field are separated by commas.

The Null Statement

The Null Statement

Looping Under the for Statement

Looping Under the for Statement

The general form of the for statement is

for (expression1; expression2; expression3) {
   statement1;
   statement2;
   .
   .
   .
}

Using Nested Loops

Using Nested Loops

You can put a loop inside another one to make nested loops. The computer will run the inner loop first before it resumes the looping for the outer loop.

Listing 7.7 is an example of how nested loops work.

 

The do-while Loop

The do-while Loop

You may note that in the for and while statements, the expressions are set at the top of the loop. However, in this section, you're going to see another statement used for looping,