C প্রোগ্রাম এর ডেটা টাইপ এবং নামকরণ করার পদ্ধতি

Submitted by administrator on Mon, 01/02/2012 - 14:32

ক্লাস 4: C ল্যাঙ্গুয়েজ এর ডেটা টাইপ এবং নেম

CLASS 4: Data Types and Names in C

You learned how to make a valid name for a C function in Hour 3, "The Essentials of C Programs." Now, you're going to learn more about naming a variable and the C keywords reserved by the C compiler in this hour.

Also in this hour you're going to learn about the four data types of the C language in detail:

  •     char data type
  •     int data type
  •     float data type
  •     double data type

 

Using Scientific Notation
The C language uses scientific notation to help you write lengthy floating-point numbers.

In scientific notation, a number can be represented by the combination of the mantissa and the exponent. The format of the notation is that the mantissa is followed by the exponent, which is prefixed by e or E. Here are two examples:

 

[mantissa]e[exponent],

and

[mantissa]E[exponent].

 

For instance, 5000 can be represented by 5e3 in scientific notation. Likewise, -300 can be represented by -3e2, and 0.0025 by 2.5e-3.

 

Correspondingly, the format specifier, %e or %E, is used to format a floating-point number in scientific notation. The usage of %e or %E in the printf() function is the same as %f.

 

Naming a Variable
You've learned how to make a valid function name. In this section, let's focus on naming variables. Function names and variable names are both identifiers in C.

The following are all the characters you can use to make a valid variable name:

  • Characters A through Z and a through z.
  • Digit characters 0 through 9, which can be used in any position except the first of a variable name.
  • The underscore character (_).

For instance, stop_sign, Loop3, and _pause are all valid variable names.

Now, let's see what you cannot use in variable naming:

  • A variable name cannot contain any C arithmetic signs.
  • A variable name cannot contain any dots (.).
  • A variable name cannot contain any apostrophes (`).
  • A variable name cannot contain any other special symbols such as *, @, #, ?, and so on.

Some invalid variable names, for example, are, 4flags, sum-result, method*4, and what_size?.

 

WARNING
Never use the C keywords reserved in the C language, or the names of the standard C library functions, as variable names in your C program.

 

Summary

  • In this lesson you've learned about the following:
  • The C keywords reserved in the C language
  • The char data type and the %c format specifier
  • The int data type and the %d format specifier
  • The float data type and the %f format specifier
  • Floating-point numbers can be suffixed with f or F to specify float. A floating-point number without suffix is double by default.
  • The possible ranges of the char, int, and float data types
  • The double data type
  • Scientific notation and the %e and %E format specifiers
  • The rules you have to follow to make a valid variable name


In the next lesson you'll learn more about the printf() function and other functions to deal with input and output.

 

 

 

 

Related Items

মডুলার C প্রোগ্রামিং (Modular C Programming)

কেবল মাত্র একটি ফাংশন দিয়ে কোনো বড়ো জটিল সমস্যা সমাধানের চেষ্টা করা ভাল প্রোগ্রামিংয়ের পদ্ধতি নয়। সঠিক পদ্ধতি হ'ল সমস্যাটিকে কয়েকটি ছোট ছোট এবং সরল টুকরো করে ফেলা যাতে তা আরও বিশদে বোঝা যায় । তারপরে এই ছোট এবং সরল সমস্যাগুলি সমাধান করার জন্য ছোট ছোট ফাংশন ব্লক তৈরি করা এবং পরে সেগুলি নিয়মানুযায়ী সংযোজিত করা ।

Programming Style

Programming Style

In this section, I'd like to briefly highlight some points that will help you write clean programs that can easily be read, understood, and maintained.

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 Is the C preprocessor part of the C compiler?

    A No. The C preprocessor is not part of the C compiler. With its own line-oriented grammar and syntax, the C preprocessor runs before the compiler in order to handle named constants, macros, and inclusion of files.

Compiling Your Code Under Conditions

Compiling Your Code Under Conditions

You can select portions of your C program that you want to compile by using a set of preprocessor directives. This is useful, especially when you're testing a piece of new code or debugging a portion of code.