 Hello and welcome. In this lecture, we are going to look at how different objects, variables and functions are named in a C++ program and we are also going to learn about type declarations. So, here is a quick recap of some topics relevant to what we are going to study in this lecture. We have seen in an earlier lecture the structure of a simple C++ program where we saw main function and within the main function we saw different variables and their declarations. We are going to look at variables, declarations and some related topics in this lecture building upon what we have studied earlier. So, this is the overview of this lecture. We are going to look at how names are given to different objects in C++. We are going to have a very high level overview of type declarations and how these are indicated in a C++ program and we will illustrate these through names and declarations of variables and functions in a C++ program. So, in C++ there are different kinds of computational objects and names must be used to represent these objects. Each object typically can have a value of a certain type and so must also associate a type with every named object in a C++ program. Now the value associated with a named object can change as the program executes. However, the type associated with the object stays the same. Even constant values used in a program can be thought of as objects of a certain type whose values do not change as the program executes. So, what we are going to see in this lecture is how to assign names to different objects and how to declare their types in a C++ program. A name in a C++ program is any sequence of characters where the characters could include any character from uppercase a to uppercase z, lowercase a to lowercase z, the number 0 to the number 9 and you can also use the underscore character. However, when you are forming the sequence of characters, you have to remember a few dos and don'ts. For example, you cannot start a name with a digit like 0 to 9. For example, 1 my bar is not okay because it starts with the number 1. Similarly, a name cannot be a C++ keyword. We have already seen certain keywords like namespace, int, return and so on. So, you cannot use any of these keywords. Although they are a sequence of characters from these allowable characters, but because they are reserved keywords, they cannot be used for names. A name can start with underscore or it can start with any letter from uppercase a to uppercase z or lowercase a to lowercase z. For example, you can have a variable named like this underscore my bar 1. A name can usually be of any length. However, some compilers may limit the length to some large number, but in reality, this is not really a practical concern. Now, it is very important to assign meaningful names to whatever objects you are using in a program and the importance of this is very high if you want your program to be readable. For example, in a big let us say 1000 line program, if I have a variable named average marks, just the name of the variable tells me what this variable is going to be used for. It is going to be used to store the average of some marks. Whereas, if instead of using this variable name, if I had said variable xyz, then it becomes very difficult to understand its purpose and one has to look at the various places where this variable is used in order to figure out what this variable is being used for in the program. So, by assigning meaningful names to variables in programs, you can indeed make your program much more readable. Now, as I said, every object must be associated with a type and C++ allows different types of values. For example, I have indicated in red here different types that are allowed in C++ and this is certainly not a comprehensive list of types. C++ allows much more types and we will see more of these as we proceed in the course. So, here I have indicated some types, care for character and for integer, float for floating point values, we will see what these are later on. Similarly, double is for double precision values. Once again, we will see what these are. You could also have the type void, which means that a variable or an object of this type does not have a specific value associated with it. Similarly, you could have the type bool for a boolean. Now, the type of an object must always be declared before its use. You cannot use an object until you have declared its type already. The way you define the type of an object is by saying type name, space object name. For example, I could have integer, mid-sem marks or character, yes, no response. Clearly, I have used variable names here, which indicate what their purpose is and this is telling what kind of value can be stored in this variable. Now, why are type declarations important? Because the compiler is going to use these declarations to allocate an appropriate amount of memory space based on the type to store the values that are going to be stored with this variable. So, for example, if mid-sem marks is of type integer, the compiler is going to allocate 4 bytes to store the value of that integer. Whereas, if yes, no response is of type character, the compiler is going to allocate 1 byte to store the value associated with this variable. So, as you can see, these type declarations serve a purpose much more than readability of the program. They are actually used by the compiler to do memory space allocation for different variables. Now, you can also use certain qualifiers to types. For example, I could say short int, which basically says I am going to store an integer, but I am going to just need 2 bytes to store the value of this integer. An unsigned int, which is basically saying an integer, but I want to treat it as an unsigned number. I do not want to have a sign bit for this integer. A long int, typically an integer is 4 bytes, but this could be used to say that I am going to store a very large integer value. Please allocate 8 bytes. Some compilers will, however, use 4 bytes itself for long int or I could have unsigned char, which means that use 1 byte as in a character, but I am going to use it for storing unsigned integers. So, the compiler uses the qualifiers that you can give to types. For example, int is the type and short is the qualifier. Char is the type and unsigned is the qualifier. The compiler uses this qualifier information to decide how much space to allocate for a variable and how to interpret the stored values. Now, types are important and similarly, names are important not only for variables, but they are also important for functions in a program. Now, what is a function? We have already discussed about this very briefly when we were talking about the basic structure of a C++ program, but here is a quick look at it again. A C++ function is basically a computational subtask, which you encapsulate within braces and then you give it a name. So, once again you see here a name is needed to identify a C++ function, which will do a computational task or subtask. And the names to be used for functions must follow the same rules as for variables and other objects that we have just seen. Now, a function can also accept optional input parameters and it can return values, but these input parameters must again have names and they must have types and similarly, the return value must have type. And of course, when a function has parameters, what it represents is a parameterized computation. We will quickly see an example of this. This was a friendly summing program that we had seen in an earlier lecture. It reads in two numbers and it outputs their sum. Now, I could also write a function to add integers which takes two parameters called a and b, computes their sum and returns that value. So, for example, here a and b are input parameters and note that they also have names and they have types. The function itself returns a value of a certain type. So, the function itself is associated with a return type here in integer and the function also has a name just like a variable has a name. So, here the name of the function is add to ends and the same naming rules apply for naming functions as for variables. Just like variables, the name and type of a function must also be declared before its use. For example, in the yellow box here, I have separated it into two panes just so that the entire program fits into the slide, but you can read this program as starting here in the left pane and after that going into the right pane. So, here the part highlighted in red is a declaration for a function. It says this is the name of the function, these are the input parameters of the function, these are the types of the input parameters, these are some names of the input parameters and this is the type of the return value of this function. So, this is a declaration for the function just like we have a declaration for variable, we must declare a function before we use it. So, this is the declaration of the function, the main function here reads two numbers a and b and then it invokes this function add to ends passing a and b as parameters to this function. We will look much more about how to invoke functions and how to invoke functions in more complicated ways later during the course, but I am just trying to illustrate here that in a program if you want to use a function, then that function must be declared earlier and the declaration must contain the names and types of the input parameters and the type of the return value and of course, this is the body of the function definition which tells you what the function does. So, in summary what we have seen in this lecture is that there are certain rules for assigning names in C++ names need to be associated with variables functions and in general to any computational object that you have in your program, type declarations are absolutely essential for any named entity in your program. Variables must have type declarations, functions must have type declarations, function parameters must have type declarations, function return values must have type declarations and we have looked at some commonly used types just to illustrate how to write a program with named variables functions and how to declare the types of these variables and functions. Thank you.