Data Types in C (part 2)

        Data Types in C.......

            Today, we will continue our discussion on integer data type. Our outline for today's would be to study modifiers such as short, long signed, unsigned and some programming examples. Long and Short These are the modifiers used to make it possible for a data type to take either less or more memory. Suppose if size of integer is of 4 bytes in your computer, then using short in front of integer makes it of 2 by tes.
    For example, In my computer size of short integer is of 2 bytes. you can see, the output is 2. On the other hand, using long as a modifier
 in front of integer allows integer data type to take more memory space.
     Here you can see, size of long integer is of 8 bytes. 
      Note: It is not guaranteed that short takes lesser memory than the integer and long takes more memory than an integer. The only thing which is guaranteed is that, size of short is less than or equal to size of integer and is less than or equal to size of long As I already told you
 in the previous lecture, that integers can have signed range and unsigned range. Typically signed range is from -32768 to +32767 and the unsigned range is from 0 to 65535 for 2 bytes integer. And for 4 bytes, this would be the range This is because in reality, most of the times along with the positive values there is a need of representing 
negative values as well.
      For example: When you are performing subtraction of 49 with 50, you will get -1 as the answer. For representing these negative values in computer, you have different representations and one of the widely used representation is 2's complement representation. Range of negative numbers comes from this representation only. Apart form this that, there is one more important point that we need to know.
       When you are declaring integer, with some variable name then it is by default a signed integer variable By putting unsigned modifier, in front of integer it allows only positive 
values to be assigned to it.
    Lets see what happens when we are trying to use these modifiers in front of integer data type. I am going to provide 4 programming examples that will print the range of integers when we apply different modifiers in front of integer data type.
      Here is the first example. First of all, I have included a new header file ……. limits.h This header file consists of some symbolic constants
that are useful in determining the minimum as well as the maximum values of any data type according to the system. In this example, I have used symbolic constant
              INT_MIN
and assigned it to variable 1. This symbolic constant gives me the minimum value of the signed integer according to my system. And similarly, 
       INT_MAX
is assigned to variable 2 and this will give me the 
maximum value of signed integer. Here, in this example we are trying to print the range of signed integer writing int or signed int, both are one and the same thing, as I already told you. because, by default integer is signed integer in our systems.
     In my system, the size of integer is of 4 bytes. Therefore, range of signed integer is from -2147483648 to +2147483647. In the second example, we are trying to print the range of unsigned integers. here symbolic constant, maximum value of unsigned integer is UINT_MAX.
      Also, there is no symbolic constant available in limits.h header file, for minimum value of unsigned integer. Because minimum value is fixed for all systems and that is zero. And there is one more important thing to note Here to print the value of an unsigned integer, we have to use %u
instead of %d.
       As %d is used to print decimal value, %u is used to print unsigned decimal value. Now as we can see, the output is range of unsigned integer is from 0 to 4294967295. As for 4 bytes or 32 bits unsigned integer maximum value is 2 raised to the power 32 – 1 which is 4294967295.In the third example, we want to print the range of short signed integer. Symbolic constants for 
getting the minimum as well as the maximum values of short signed integer is SHRT_MIN and SHRT_MAX respectively. Because of this "short" key word, integer data type takes 2 bytes
instead of 4 bytes.
       Therefore range would be from -32768 to +32767. And finally, in example no. 4 we are using USHRT_MAX for getting the maximum value
of unsigned short integer. And as expected,
the range is from 0 to 65535.
        Note: You can also write unsigned short instead of short unsigned here. The order doesn't matter.
       You can also check the range of long integers
by replacing the keyword short with long.
And in printf instead of using %d, you can use %ld for long signed integer and instead of %u
you have to use %lu. There is one more thing called long long integer. It simply means,
Suppose if long integer is of 4 bytes, then long long integer will be of 8 bytes else if long integer is of 8 bytes, then long long integer would be of 8 bytes only. Because the maximum limit is upto 8 bytes you can say.
         Let's try to summarize the information that whatever we had learnt till now. sizeof(short) is less than or equal to sizeof(int) and is less than 
or equal to sizeof(long) Writing signed int some_variable_name; is equivalent to writing
int some_variable_name;
%d is used to print "signed integer"
%u is used to print "unsigned integer"
%ld is used to print "long integer"
which is actually equivalent to signed long integer.
%lu is used to print "unsigned long integer"
%lld is used to print "long long integer"
%llu is used to print  "unsigned long long integer"
OK friends, this is it for now…….

Data Types In C (part 1)

          

Data Types in C...
        

          Today we are going to learn about a  fundamental Data Type called integer. we have various data types to study. And today we begin our session with integer Data Type. Recall from . introduction to variables. Integer can take either 2 bytes of memory space or 4 bytes of memory space, depending upon the machine you're working with. 
      we know 1 byte is equal to 8 bits, therefore 2 bytes equals to 16 bits and 4 bytes is equal to 32 bits. More the size more content it can hold. Obviously, if you want to know the size of integer programmatically, then you can by using "sizeof" operator.
       "sizeof" is a unary operator that helps us in determining the size of any data type that we provide to it. As you can see here in my computer, "sizeof" integer is actually equal to four bytes as the output is 4 of this "sizeof". I provided the output with the help of this printf function.      
          Note:"sizeof" is a unary operator and not a function. You might think of it as a function, but it is not a function. Now let's define "Range". Range is nothing but upper and lower limit of some set of data. For example, here you can see this set consists of some values {0, 1, 2, 3, 4}. If you want to determine the range of this set of data, then you have to determine the minimum value as well as the maximum value.
         Here, you can see the minimum value is 0 and the maximum value is equals to 4. Therefore, the ranges from 0 to 4. As you can see in this set of data, there is no value which is less than 0, and there is no value which is greater than 4. And that is what the definition of "Range" is.
       Now, before diving deep into the concept of range of integers, it is better to get into some prerequisites. And one of the prerequisites that we have to pass through is knowing Decimal number system. In our day to day life, we use Decimal number system for many purposes. Maybe for counting purpose, or maybe when we need to quantize some information like 2 apples, 30 bananas, and so on. Decimal number system is human understandable number system. and is also called as base 10 number system. "base 10 simply means the range of number that we are available with is from 0 to 9.
          Let's take one example of a decimal number. We pronounce this number as five hundred and sixty-eight. Instead of simply saying 568. Have you ever wonder why do we pronounce it like that way? Because in reality, we have numbers ranging from 0 to 9. And if you want to represent such a large number, we have to multiply each digit with their respective place values. Here place value are starting from the rightmost end, and it is 10 raise to the power 0, then 10 raise to the power 1, then 10  raise to the power 2, and so on.
        When we multiply 8 with 10 raise to the power 0, we get 8 only. When we multiply 6 with 10 raise to the power 1 we get 60. When we multiply 5 with 10 raise to the power 2, we get 500. And now, in order to get the desired result, we add them up to get 568 as our result. 
        Isn't that easy? Okay! But this is not something that machine could understand. It has its own number system called Binary number ssystem.Binary number system is machine understandable number system, and is also called as base 2 number system. Means range is from 0 to 1. Only two numbers. As you can see, here, I've written a four bit data 1 1 0 0. In this case, also each digit must also have some place values associated with them. Because binary number system has base is equals to 2. Therefore starting from the rightmost end we have 2 raise to the power 0, 2 raise to the power 1, 2 raise to the power 2 2 raise to the power 3 as their place values. And if you want to represent this number in decimal, then you have to follow the same method that we had adopted in case of decimal number system i.e multiplying the digits with their respective place values, and finally add them up.
          As you can see here, if I multiply 2 raise to the power 0 with 0, I get 0. 2 raise to the power 1 with 1, I get 0. 2 raise to the power 2 with 1 I get 2 raise to the power 2 which is equals to 4. 2 raise to the power 3 multiplied with 1 I get 2 raise to the power 3 and that is equals to 8. By adding all these numbers, we get 12 as our answer.
        Now what would be the range of 4 bit data? As we know, know to calculate range of any number, we have to know its minimum, as well      as maximum value. For 4 bit data, minimum value is equals to 0. When all digits are 0. And maximum value is equals to 15 when all digits are equals to 1. You can get this value by using the same method by multiplying each digit with their respective place values and finally add them up. In this case of maximum value you're multiplying 2 raise to the power 3 with 1, then 2 raise to the power 2 with 1, 2 raise to the power 1 with 1 and 2 raise to the power 0 with 1 and finally add them up to get the answer 15. And here because all of them are zero multiplying it with their respective place values would finally give the answer is equals to 0.
          Therefore, range of all the data is from 0 to 15 only. But there's one more formula available to calculate the maximum value. And that is, 2 raise to the power n minus 1. Suppose you have a 32-bit data, then adding all these place values multiplying with their digits is quite difficult, then this formula is quite handy to apply. Here, by replacing n is equals to 4 for 4 bit data, you get 2 raise to the power 4 minus 1 which is 16 minus 1, and that finally gives the values equals to 15, which is our maximum value. 
             Let's calculate the range of integer. If in your machine, the size of integer is of 2 bytes, then the unsigned range is from 0 to 65 535. By applying the same formula for calculating the maximum value. By replacing n with 16, you get 2 raise to the power 16 minus 1 which is nothing but 65 535. Usually, you also have to represent the negative values. And that we can do with the help of 2's compliment representation. We actually have three different representations to represent negative numbers, and they are signed magnitude, 1's compliment and 2's compliment. But in most of the computers 2's compliment representation is used. 2's compliment range is from -2 raise to the power n-1 to +2 raise to the power n-1 minus 1.
       If you want to know more about 2's compliment representation and other representations, then you can refer the Neso Academy playlist of "Digital Electronics" here on YouTube. Here, you can see -2 raise to the power n-1. By replacing n is equals to 16 I get 2 raise to the power 15 which is -32 768 and +2 raise to the power n-1 i.e. 2 raise to the power 15 minus 1 that gives 32 767.
       On the other hand if your PC supports 4 bytes integer, then Unsigned range is from 0 to 4 294 967 295. By applying the same formula for the maximum value, Signed range can be obtained by using this 2's compliment range. That's it. See you later…..

Rules of Declaring a Variable.....

      Some Of The Important Rules To Declare VARIABLES In C.........


                    C follows some naming conventions Or you can say rules for naming their Variables. the need for making this information separately is that this is one Of the most avoidable topics while Learning C programming because we Usually don’t care how we name our Variables as it is not the case that Everything is allowed in C programming......
        As we want therefore studying naming Conventions is equally important name Of a variable is composed of letters or Maybe the combination of letters both Uppercase and lowercase and digits rules For naming variables are as follows you Cannot start your variable name with a Digit for example globe is a valid Variable name on the other hand to Globe is invalid even though underscore Counts as a letter but don’t begin Variable names with underscore although You cannot begin with underscore because Huge number of variable names beginning With underscore are resolved for system Use using them in your program may cause Problems in your code execution  it’s better to avoid such Names C language is case sensitive means Uppercase and lowercase letters are Distinctive writing.
      You can also assign variable to a variable instead of this constant value 3 or 4.int var1 is equal to 3. Suppose my new variable is var1,I declare another variable var2 and I initialized or you can say I assigned value to it  with the value of var1.Here you can see that I am assigning the value of 3 actually because writing the name of the variable means that I am assigning its constant value and I'm assigning it to variable 2. Lets print it using printf.Lets debug As expected, the output turns out to be 3.You can also assign same values to different  variables in a single line.As you can see I declared and defined variables in the same line using the same data type.All these variables are of integer type.Instead  of defining and declaring in different lines it is better to write them down  in a single line.Suppose I assign them the value equal to 4 all in the same  line and then I print it.
        Lets build and run.And as expected we get the value 4 4 4 because we had printed three times.There are three different variables var1 var2 var3. Because all of them has been assigned to the same value 4 That is why we are getting three values of 4 in the output. 
         Where all are different you can say It is interesting to know that Traditionally lowercase letters are used For naming the variables and uppercase Letters for naming symbolic constants Will talk about symbolic constants when  We study the use of hash define later Special characters such as at the rate Hound percentile power ampersand star Etcetera other than underscore are not Allowed in the name of variables note Maybe some special characters use in Naming variable can work but most of Them failed like when I put dollars Somewhere in between or even at the Beginning of the variable name it works But if I choose some other special Character like percentile it produces Error therefore battle is to avoid the Use of special characters but yes I told You to avoid using underscore at the Beginning but you can use it in between The name of the variables blanks or you Can say white spaces are not allowed in Between for the separation of different Parts of the name of variable. 
         for Example in my variable is invalid Because of the blank space over here you Can see blank space compiler won’t be Able to recognize it as a single Variable instead if you want to improve Readability you can use underscore Instead of blank space int my variable Is now a valid variable name as you can See over here now I’d put underscore Instead of that blank space keyword Slight if-else for wild switch int float Long double etc are result words you Cannot use them in naming your variables Although all these keywords are Lowercase and if you insist to use them In naming your variables you can make Either a Or multiple letters uppercase and then You can use them like this finally there Is one important tip do not use longed Name for your variables it may not look Good and using them later in your Program is not that easy because you Have to write down those long names Again and again in your code whenever You want to use them that’s it for now See you in the next lecture.

Variable (part 1)

    


  

     

                               variable in c...

  In today's lesson,we are going to talk about variables in C programming. Think of a glass of water.If you want to drink some water, then you put water inside glass and drink it. You can think of a variable as a glass of water.As a glass can store water in it similarly variables can store some value in it.After storing  the value,you are free to use this  value in your program.

           In reality, variables are simply names that points to some memory  location.Thanks to the inventor of C language who makes it easy for us to store values in memory by simply using the name of our choice.You don't need to worry about at which location of the memory your value is stored. Your task is to just provide the name and internally it will point to some memory location.But there is one thing that we need to be sure about.You must have to declare variables before using it in your program.Declaration simple means,announcing the properties of the variable to the compiler. Here, by saying properties we mean that what will be the size of the variable and what will be the name of  the variable Don't worry, it is not a very difficult job to do.You will see in a moment how easy it is to declare a variable.

      There is one more term called definition of a variable,which means allocating memory to a variable.Most of the time declaration and definition will be done at the same time.But this is not always the case.It depends on the modifiers you had mentioned with the variables. We will talk about modifiers later and then we will also explain how declaration and definition is different for different modmodifier Let me give you an example of how to declare a variable.Here, the name of the variable is var and it has an  integer data type.Data type simply means how much space a variable is going to occupy in the memory.Therefore by writing....... int var you are declaring a variable along with that you are requesting the compiler to allocate memory for this variable.  Please note down on one thing here after int varwe have put a semicolon over here.This is very important.Because this is how your compiler separates one statement from the other.So don't forget to add a semicolon at the end of the variable.

     Now, the memory location depends upon the type you use Here because in our example,we are using integer data type therefore it may take either two  bytes of memory or may be four bytes of memory.It purely depends on the system you are working on. Again you  don't have to worry about how much space is allocated to your variable.You only have to concentrate on the declaration and definition of the variable If you assign some value to a variable,at the time of declaration itself Then this thing is called initialization.This is how you will do initialization. Note- initialization of a variable doesn't mean that you cannot change the value of a variable afterwards in your code.If you want the value to be changed somewhere,then you can do that this clearly captures the meaning of variable.Variable in its pronunciation has word vary.Something that can vary over time.On the other  hand constant is just the opposite.once defined will never change. 

                  Let's see how we can change the value of the variable after  initialization.Let me write down the code here.I am writing .........#include that is our header file because we have to print some output. Then I am declaring main function.Inside this main function,I'm first declaring a variable named var.Suppose I initialize it first to 3,and afterwards I change this value to 4.You can observe that again I have not written int var in this statement when I'm assigning value to it.because the memory is allocated to the variable once and defining it once again means you want to allocate memory again for the same name. And this is illegal.Note- each variable must be defined only once but it can be used multiple times with different assignment in your program.But there is one exception as well.when we study scope rules later you will understand that same variable name can be defined in different blocks of code.You will slowly understand what does it mean.For now it is enough to know that inside this main function you cannot define multiple variables with the same name.Then suppose we write,printf with %d and we print the value of the variable.I will explain you more about what this %d means.For now, I can only tell you that this will print the  contents of whatever is there inside this variable var you have to put at  the end return 0 Let me save this.And build and run the code.You can see the output here which is 4. Previously I had initialized the Value of 3, and then changed it to 4 and print it.And as expected,my output is equal to 4 without any error.

               You can also assign variable to a variable instead of this constant value 3 or 4.int var1 is equal to 3. Suppose my new variable is var1,I declare another variable var2 and I initialized or you can say I assigned value to it  with the value of var1.Here you can see that I am assigning the value of 3 actually because writing the name of the variable means that I am assigning its constant value and I'm assigning it to variable 2. Lets print it using printf.Lets debug As expected, the output turns out to be 3.You can also assign same values to different  variables in a single line.As you can see I declared and defined variables in the same line using the same data type.All these variables are of integer type.Instead  of defining and declaring in different lines it is better to write them down  in a single line.Suppose I assign them the value equal to 4 all in the same  line and then I print it.

            Lets build and run.And as expected we get the value 4 4 4 because we had printed three times.There are three different variables var1 var2 var3. Because all of them has been assigned to the same value 4 That is why we are getting three values of 4 in the output. 


Constant In C (part 2)

 


      

                                        constants in c

  Let us discuss now character constraints these are also two types single character and string string constant what is single character constants if i write like suppose single character is a so you will write like this in single quotation so this is what character constant constant so you can say character constant is what it is having a single character enclosed within single quote marks this is character constant this is also character constant and suppose i write this backslash this one zero this is also character constant these are backs backslash character constraints these are having different meanings there is list of backslash character constants right those are having different meanings fine and you can say like if you write this one comma this is also character constant right and if you write this at the rate this is also character constant so any single character which is enclosed within these single quotation mark within this you can also write down some characters also like a b c d capital a b c d or some numbers and some special characters also those are character constraints and these character constraints are within computer it these are being stored in the form of sky codes right like uh here this a means 97 capital a means what 65 like this small b means 98 and like this capital b means 66 and like this so on right and these are also having uh their different this this value this is also character constant if you write 1 and see 5 is not equal to this 5 this is character constant it is having some different value this is numeric constant this you need to take care right if you are writing anything between these single quotes the number then that is character constant that is not numeric constant this is not integer constant fine so sky value i am writing here you can see so these are sky values capital a to z 65 to 90 small a to z 97 to 122 zero to nine numbers are having a sky value 48 to 57 and some special character like this um coma or at the rate or some special characters are having values from 0 to 47 then 58 to 64 and 91 to 96 right you can also check out like which special character is having between these lie between these values and between these and between these you can google it out right but you have to take care of this thing and you can also perform some arithmetic operations on these character constants right suppose i am printing uh thissee if you are writing like this percentage printf percentage d this is for integer format specifier and a it is what single quote mark so this is what character constant so it will print what integer value of this a because i am writing here format specifier percentage d this is for integer this is to print integer value right here if you compiler will find it is percentage d then it will print what whatever is given here after this coma the first one the first one for that it will print the decimal value means that that integer value the integer value of a is 97 so it will print 97 and if you write percentage c it is what character constant it is used to print characters and if you write here 97 then it will print the equivalent value character value of this 97 fine and see every character is having integer value that is why i am saying that you can also perform arithmetic operations on character constants right next comes to string constant so string constants are you can say sequence of characters enclosed within double

                  characters and enclosed within double quote mark so this is string constant if you write abc this is what string constant and these characters may be letters number some special characters space everything if i write like uh here a b dollar this is also string constant but here c one thing if i write a in double quote this is not it is single character but enclosed in double quotation mark so it is not character single character constant it is a string constant and if i write a this is what single character constant but these are not equal this is different thing this is different thing this you need to take care this is string constant this is what character single character constant fine and if i write like 1 2 3 4 5 in double quote this is also string constant right but here this like 1 is not equal to this one because this is single character and it is equivalent to its sky value of 1 is 49 but string constant this is not equal to its sky value this is string constant right so you need to take care of this thing also and whenever this string constant is there in a program and when compiler read this string constant then what compiler will do compiler will store the address of the first character reads the address of the first character and it will append a null character constant it will append a null character constant at last why so just to mark this is end of the screw end of this string right so length of the string is what one two three four five six here if you find out the length of this string then it is not five it should be six because a compiler has added null character just to mark that this is end of this string fine so now let us discuss how to declare constants in your program we use what keyword const keyword to declare constant like this right one method is this one so if you write in a program suppose i am writing a function word main i am not writing a complete program you can include those header files and i am writing here const int a value is 10 in this program right means this value of a is constant throughout the program you cannot change this value if suppose you will print this value a then always the output would be 10 and suppose after that i am writing a is equal to 50. you are trying to change the value of a then it this line will give error that this value is you can say its read only value you cannot change this value because you have written conest keyword before this declaration before this initialization of this variable this is variable name that also will discuss what are variables in c this is data type but if you write like this into a is equal to 10 fine when you will print value of a 10 would be printed but after that anywhere in a program you can change this value if you write a is equal to 50 and then if you print value of a then the updated value would be printed 50 now you can change this value this will not give error so you have to declare constant using const keyword right another thing it that i have discussed in starting of this video you can use hash define macro definition symbolic constant so there you can write this would be above this main although you can use anywhere the hash define statement but generally we use where above this main function right so we write like what hash define suppose i am writing a 10 this is also fine right but generally here we write what capital uh letters only like if you're writing pi then pi also if you write max then max also like this right and why i am using these capital letters so that you can distinguish between the normal variables within the programs and the symbolic constraints that is why there are some rules when you use this hash define statement then there are some rules to write this the statements and what are those rules there should not be any space between hash and define there should also be a space between hash define this and then name of that constant and then value of that constant another thing you cannot use here equal to right this would be wrong fine you cannot use semicolon after a statement. 


Constant in c (part 1)

     

          

                                  constants in c.....

 In c constants are having fixed values the value of constants are not going to be changedt hroughout the programmer you can sayd uring the execution of a program the values are to be fixed the programmer while writing a program will specify these values means compiler know the value of constant during compile time you will not give the value at runtime right one thing is what we use symbolic

      constants so that we use to define some fixed values like suppose um value of pi so you will write hash define pi is 3.14 this is what that definition section we have discussed when we were discussing structure of a c program so the value of pi is fixed 3.14 it is symbolic constant if you write hash define suppose max value is 50. so the value of that max is what is to be 50 throughout the program it is not going to be change you cannot change that value these are symbolic constants right so we are having basically two types of constants in c

1] numeric constants 

2] character constants

or somewhere it is also written four types of 

1] constant integer 

2] floating point constant

3] character constant 

4]string constant

     let us discuss so these are four types of constant or you can say two types numeric and character constant is numeric is further divided into two types integer constant and real constant of floating constant here single character constant string constant so basically four types so let us discuss first one is integer constants these are having decimal values like if you write this uh 10 it is it is a constant five integer constant one integer constant integer constant right these are valid but if you write 0 5 this is not you can say decimal constant see in integer also we have 3 types decimal constant octal constant and hexadecimal constraint right decimal means we can use uh the the numbers from 0 to 9 base is 10 octal constant means from 0 to 7 base is 8 and hexadecimal means we can use from 0 to 15 and bases base of these constants are 16 so integer also having three categories so if you write 0 5 that comes under ah octal constant because the rule is what octal constants starts with the value 0 always right but decimal constant means yeah you can use 0 but if there are two digit in that constant so 0 can be at this side right side but 0 cannot be at this side left side if you write like this this comes under category octal constant right and constants are also called literals right so here also you can we can express an integer in three forms decimal octal and hexadecimal and by default if we say integer constant generally by default we represent that in decimal constant not octal not hexadecimal right difference i have told you what is octal now how you write hexadecimal constant c in hexadecimal we have sequence of digits preceded by either 0 x or you can say 0 small x

    let us suppose i write ah 0 x this is what hexadecimal constant right and see in hexadecimal we use what from 0 to 9 numbers and a to f characters i have told i have written here 0 to 15 but here we use from 0 to9 numbers 10 numbers like right and after that 5 is what alphabets a to f right.

    so here you can say a means 10 0 to 9 we use numbers 10 numbers then b like this we are having from 0 to 15 0 to 9 numbers and then 10 to 15 we represent like abcdef so if i write 0x that is also exactly decimal constant if i write like 0 x and 7 If this is also hexadecimal constant but if you write 0 x and suppose i am i am writing 7 g this is not hexadecimal constant because we cannot use g we can use only a to f right so you can say these integer constants are sequence of digits suppose i am writing here one two three four this is also what integer constant but rule or what you cannot write like this 56 comma 100 you cannot write any comma or special character between these constants so this is not valid this is invalid constant integer constant right or if and by default the sign is what plus you can also use sine plus or by default x plus if i write minus 1 to 3 this is also valid so you can write a sign either minus 1 plus if you write like this dollar one two three this is incorrect you cannot use any special character you can you you cannot use any comma you cannot use any spacel ike fifty seven space hundred this is also invalid you cannot use space uh between these sequence of digits this there should not be any space any commas any special character this is valid one two three four or like 56 or five six seven eight this is also valid right so now i hope you got integer constant let us discuss real constants so real constants are also known as floating point constants these are having fractional part like if you uh write 12.56 this is decimal part this is you can say you can say this is what the integer part this is decimal point and this is fractional part so having decimal point these are what real constants so if i write plus this that is also fine if i write minus 50 . 6.02 that is also fine sine can be plus or minus by default sign is plus right but if you write this is invalid there cannot be two decimal points right and you can also represent these uh decimal points or these floating point constant in uh exponential form having mantissa then e then exponent mantissa can be anything like having that decimal point and exponent is always constant right so these are some examples see which one is valid constant or numeric constant or not this one is valid 0x this is also valid This is not valid this one this is not valid because here we have space 0 1 2 this is valid 1 2 3 yes this is valid right and if suppose i write 0x af this is also valid and suppose if I write hash one two three this is invalid you cannot use any special character or known digit character right so these are numeric constant.


Introduction To C programming - 1

         

                                Introduction to c programming



   The c character set

C language uses the uppercase letters A to Z, the lowercase letters a to z, the digits 0 to 9
   Special characters
   + - *  /  %  &  #  !  ?  ^  {  }  (   )  :  ;  ?  =  ,  <  >  (blank space)
Most versions of the language also allow certain other characters, such as @ and S, to be included with strings and comments.
            C program uses certain combinations of these characters, such as 
      \b = backspace
      \n = newline
      \t = Tab
These character combinations are known as escape sequences
Example of c pprogram… . 
Question- write a c program to print a hello word ?         
 Ans-  
    #include < studio.h>
     Main () 
   {
    Printf (“ Hello word “ ) ;
   }
This is very simple program  used  to print the message hello word  on the output screen. 
 1st line of program # is a compiler directive. 2nd line  uses a special word main, which denotes the starting point for execution of the program… All program start their exaction from main. Printf is a only executable statement in above program. This is use to display any message on the screen. 
  Any message written within double quotes of the printf statement is displayed as it is. But one ma note the absence of \n in the output, although this was also included within the double quotes. \n is act ally a special character (known as escape sequence), which corresponds to newline character. Inclusion of \n in double quotes means that cursor should be shifted to start of next line. If you see carefully the output

screen above, the cursor position (shown as =) can be noticed at the start of next line. Had this statement

been written as
printf("Hello \n word ) ;
The output screen would have been different. And looked as 
    Hello
    Word
It may be noted that C programming gets shifted to next line now. Reason for that is the changed position of \n in the modified printf statement. But the cursor remains in the same line now just after the last alphabet  of the displayed message as there is no new line character at the end of the message. This will affected the next output when you rexecute the same program. 
  The semi colon (;) is a must after completion of every statement (end of any line does not necessarily mean completion of a statement). In the above example, semi colon has been put after printf statement, denoting its completion. It is worth noting that all instructions related to C program have been written in lowercase. Remember C is case-sensitive language and thus, any lowercase character cannot be used as uppercase or vice versa. Most of the instructions of C are written in lowercase. 

IDENTIFIERS AND KEYWORDS


Identifiers are names that are given to various program elements, such as variables, functions and arrays. Identi- fiers consist of letters and digits, in any order, except that the first character must be a letter. Both upper- and lowercase letters are permitted, though common usage favors the use of lowercase letters for most types of identifiers. Upper- and lowercase letters are not interchangeable (i.e., an uppercase letter is not equivalent to the corresponding lowercase letter.) The underscore character (_) can also be included, and is considered to be a letter. An underscore is often used in the middle of an identifier. An identifier may also begin with an underscore, though this is rarely done in practice.    
   The standard keyword are 
There are certain reserved words, called keywords, that have standard, predefined meanings in C. These keywords can be used only for their intended purpose; they cannot be used as programmer-defined identifiers. The standard keywords are
1]auto
 2] extern
3] static
3] break
4] Floatn 
5] for
6] case
7] switch
8] char
9] goto
10] typedef
11] const
12] if
13] union
14] continue
15] int
16] default
17] long
18] unsigned
19] do
20] register
21] void
22] double
23] return
24] volatile
25] else
26] short
27] while
28] enum
29] signed
30] sizeof

 also include some or all of the following keywords.
1]ada
2] far
3] near
4] asm
5] fortran
6] pascal
7] entry
8] huge

Data Types in C (part 2)

        Data Types in C.......             Today, we will continue our discussion on integer data type. Our outline for today...