Good morning. Today we shall be discussing another important topic. This is about pointers. We have first and the allocation of our variables and arrays to memory locations. We had remarked on this aspect earlier once and we had said that ordinarily we will have nothing to do with addresses of memory locations at which our variables and array elements are positioned. However, there are occasions when it is useful to be able to refer to the memory locations directly and that facility is provided in this family of languages through the use of pointers. So we will re-look at the addresses and memory locations and visit the notion of pointers. We will specifically discuss pointer variables, pointer assignments, pointer arithmetic. Look at some example programs. Then we will revisit the issue of passing parameters to functions. You will recall that we have maintained that functions will return either no value in which case we declare the function as a void function or it will return one of the values of the known type that we are aware of namely integer, floating point, character, etc. And therefore we designate the function as int something, float something, whatever. In any case, we are familiar with how a function can return one value. But if we want a function to return multiple computed values, more importantly if we want the function to affect the arguments that we pass to the function as parameters so that the modified values are reflected in our main program and the control comes back, we do not know of any such facility because CC++ family of languages always insists on passing value by copying that value some place. And therefore even if you modify the copy, the original remains unaffected. We will see how we can use pointers to change the situation in our favor. Pointers have other usages particularly in the context of character strings. We shall look at an example of by forgetting a first name, last name pair separated by blanks given as input. How do we extract the first name separately, last name separately? We can of course do this problem by using the get string function and then separating out the components of the string. It is precisely to separate out the components that we shall use the notion of pointers. And then we will discuss the input output functions provided in C++, scanf and printf. So this is something which is well known to us namely that memory locations comprise of bytes, you have memory addresses starting with address 0, 0 is notional, nothing ever gets allocated to memory address 0. But we know that the smallest unit of memory that is allocated is a byte. We also know that byte is inadequate to hold most of the values that we are interested in and therefore we have units of multiple bytes. So you have two bytes for short int, you have four bytes for int or float, typically. You could have eight bytes for double, however 32-bit machines don't permit that. But essentially an integer multiple of two is the unit of allocation of memory. Consider these references int m float a3 char c4. Assume that some values have been allocated to these memory variables either through input or assignment. We will look at the memory map after these variables are allocated memory locations. Imagine that the first memory location allocated to m is at 10,000. It's an arbitrary number, could be any number. What you see on the right hand side here are the values which we presume to exist inside these memory variables. So m has a value of 573. The address of m is 10,000. We know for sure that when we declare int m, m would have been allocated four bytes. Consequently, if this is the memory map, the next available location for memory allocation is starting at 10,004. So observe that a0 may be allocated here. It is not necessary that a0 be allocated here. But in a possible memory map, if 10,004 is the beginning address of a0, then the address of a1 will be 10,008, 10,012 and so on. Observe also that the char array c will occupy only one byte per element because it's a char array. And therefore, if c0 begins at address 10,016, then 10,017 will be the address of c1, 10,018 will be address of c2 and so on. So this much is known to us. We have always maintained that we have nothing to do with these addresses. But we note that these addresses are sort of pointers in memory because they point to a specific location containing value of a prescribed type. So 10,000 is a pointer to m. What is important to note is not only that 10,000 is a pointer, but 10,000 points to a variable containing a integer type value. If m was not declared as integer but was declared as flow, then the same 10,000 would become a pointer to a floating point type of value. As we shall see later, the notion of pointers in these programming languages is intrinsically linked to the type of value that the pointer points to. So pointer and the type of value are deeply associated. You cannot imagine a pointer variable as would be declared in c++ to be dissociated from the type. This is not possible. As we have maintained, ordinarily we will have nothing to do with these pointers or absolute addresses. However, we have the facility to exploit these addresses as they are allocated by the compiler and the linking loader later on. So when my program starts execution, when the program is loaded, the executable program, when you say dot slash a dot out, your compiled and linked program gets loaded into the memory. Actually it is that point of time when the absolute addresses are allocated, independent of what addresses were allocated in the compiled type because the operating system may decide where exactly your program will get loaded. In a large server which is shared by hundreds of users, an individual's program today may get loaded at some place, tomorrow may get loaded at some other place. So at that point in time, whatever is the memory address that gets allocated to your variables, et cetera, is what will come. We have facilities not only to declare pointer variables, but to extract the actual addresses allocated to our memory locations and use them favorably. Here is a special declaration of the type that we had not seen earlier.  We have never seen these kind of declarations. Int p1 would have declared a variable p1 whose value would be an integer, but int star p1 does not do any such thing. Int star p1 allocates a completely separate memory location in which no integer value will ever be kept of the kind that we know of. If we say float star p2, again p2 will be allocated a memory location in which no floating point value will be ever kept. But these variables p1, p2, p3 star, or other star p1, star p2, star p3 as we call them, are pointer variables which are destined to contain addresses of some other variables. What is important is that these addresses as I said are intrinsically linked to the type of value that will be associated. So for example, the pointer p1 will never be able to point to a floating point value or a care value. It will always be able to point only to an integer value. Whether that value is that of a simple variable like m or n, or that value is inside an array element such as a5 for example. The pointers point to a value of a particular type. Naturally there will be separate memory locations for these three variables and each of these contain an address. Now here is the interesting point. The address itself will be an integer number like house number 0, 1, 2, 3, 4, 5. Typically in 32 bit machines the addresses are 32 bit numbers. The larger addresses are possible. You could have a 64 bit architecture in which the addresses would be 64 bit or even 128 bits. The address itself will not come and stay inside these memory locations automatically. So initially what these pointer locations contain is indefinable. We don't know what it is. However, we can during our program execution assign any address of an appropriate element of an array or a variable to any one of these pointers. So for example, if in our program we write p1 is equal to and m and is called an address operator. m has a value of 573 as we saw. What will be the value of p1? So if m was allocated a location 10000 and the value was 573 the p1 which is a pointer will be assigned the value 10000. So this is the way we extract the address of a variable by putting an and operator or an address operator. The counter operator to the address operator which is called dereferencing operator is actually star. If we say star p1 it means the contents of a location pointed to by p1. Consequently if p1 has 10000 then the location pointed to by p1 is location 10000. It contains the value 573 and therefore star p1 will represent the value 573. In short given any set of pointers star pointer will always mean a value. p1 itself will mean the address and to get an address in the first place you will have to say pointer equal to and some variable name or array element name which will extract the address. So these are three simple notions that we should remember. One and is an address operator. In my program anytime I say and something the address of that variable or array element will be computed based on what is actually the case and that address will be allocated to the pointer. At any point of time if I refer to p1 I am always referring to the pointer. Since pointer itself is an integer number like 10000 it is possible for me to do arithmetic with pointers. For example if I add 1 to p1 the value of p1 will be 10000. If I add 2 to p1 the value of p1 will be 10000 and so on. How can I exploit this? We shall see that in a moment. So pointers themselves are essentially integer numbers on which meaningful arithmetic can be permitted is permitted. In fact we have to be careful on what we are doing with the pointer values because it is quite possible to assign an arbitrary value to a pointer and then make that pointer point to something else. A general default value of a pointer is assumed to be null that is 0. Although 0 is a valid memory location 0 is never ever allocated to any meaningful contents of your program either variables or arrays or even translated code. Consequently null pointer is assumed to be a pointer pointing nowhere. It is possible to arbitrarily allocate to a pointer p1 some value like 10000. Now 10000 may be an existing memory location but if you say star p1 it will point to an integer number starting with 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000. And whatever trash exists in that memory will become the value pointed by that point. So where do we extremely careful in using the pointer arithmetic if at all we do that? Once again to conclude pointers can be declared pointers are intrinsically associated with a specific type of value. They cannot exist nearly as arbitrary pointers. The way you declare the pointers is defined where you need the pointers to refer to which type of values and declare appropriate number of pointers in your program. An array of pointer is perfectly possible which we shall see in the later classes how we could exploit that. Separate memory locations are assigned to the pointer variable so declared they will contain addresses. The way to initialize pointers or to assign any value to pointers is to use the address operator and the address operator and can be associated with any variable or array element of our choice. Then p1 will be assigned that address. If we ever wish to refer to the value pointed to by that pointer we use star p1 or dereferencing operator. So and is called the address operator, star is called the dereferencing operator. If we want to print the value of m using the corresponding pointer we can say cout star p1. We can also print the actual absolute value of p1. So this statement cout less less p1 is perfectly valid. However what will it print will be an hexadecimal number. An hexadecimal number some of you may recall the discussion it is always written starting from 0 and therefore you have 0x as hexadecimal. If you have forgotten it is worthwhile to remember that the values numerical values which are ever printed by your cout statement or the values which you use even for input. For integer numbers a value never starts with 0. A leading zero is never printed by cout statement. A leading zero is not expected to be used by you because when you use a leading zero the number is treated as an octal number. When you prefix a integer number by 0x the number is treated as a hexadecimal number. As you know hexadecimal numbers have digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and a, b, c, d, e, f. But it is quite possible that you have a number let us say 167. It is not at all clear whether this is a decimal number, octal number or hexadecimal number. It could be any one of the three because the digits which are actually used are possible in any one of the three system. If I write a number 167 as is it will always be treated as a decimal number. If I write this number as 0, 1, 6, 7 it will be treated as an octal number. So the value will be 7 into 8 to the power 0 plus 6 into 8 to the power 1 plus 1 into 8 to the power 2. If I write the same number as 0x 167 this will be treated as a hexadecimal number. The value of 167 here will be 7 into 16 to the power 0 plus 6 into 16 to the power 1 plus different interpretation. And that is why as I said e41 a0. Every time you run the same program you may not get the same value. As I mentioned the program may get loaded at a different segment of the memory. So memory allocation will differ. Now this is something that you should carefully look at. If I say p2 is equal to and a0. If I make such a statement then pointer p2 points to the 0th element of a. When I say p2 plus plus in ordinary arithmetic I would expect the value of p2 to be incremented by 1. However, when I incremented a pointer value by 1 the actual increment to the address value that happens depends upon the type that is associated with the pointer. Since it is associated with an integer array a has been declared as integer and pointer p2 is associated with type int. We have said integer int point p2 or float. I do not know what it was. Float I think. You remember what was the yeah. We have declared p2 as float. Float is associated with how many bytes? Four bytes. So therefore when I say p2 plus plus the p2 will be incremented by 4 and not by 1. This is extremely important to understand. If on the other hand if I have a car pointer it will be incremented by 1. But if it is a float pointer it will be incremented by 4. Int pointer will be incremented by 4. And you can see the obvious reason for doing that. You want after increment the pointer to point to the next element of the array. And therefore after saying p2 plus plus if I ever print star p2 that is the value pointed to by p2 I will get the value of element a1. Here is an example program. So I have declared two integer variables m and n an array a of three elements. And I have given arbitrary values to m and n 5.73 and minus 1, 2, 3, 4, 5, 6, 7. I have declared two integer pointers ptr1 and ptr2. Just for good measure I print the values of m and n. Then I do a address computation. I say ptr1 is equal to and m. I expect ptr1 to point to the variable m. I say ptr2 is equal to ptr1 plus 1. What will these do? ptr1 will be incremented now by 4. So it should be pointing out to the next set of 4 bytes. Since I had declared m and n consecutively I expect that m and n should be allocated memory locations one after another. So when I print the values of pointers just the pointer values I expect to get whatever is the actual pointer values. Whatever is ptr1 ptr2 is bound to be 4 more than that because I have said ptr1 plus 1 is ptr. And I expect star ptr1 and star ptr2 to print the values of m and n. However when I execute this program you will notice that this is the first print out. This is the first print out of course. The pointers are these values. Notice 0xbfcaf8ac and b0 because this is the x-ray decimal number. So ac, ad, ae, af are the 4 bytes and the next one is b0. So I am getting the pointer increment correctly reflecting change of 4 bytes. However when I print the corresponding data values I do not get the value of n here. I do get a value of m. So why could this happen? Yes. Okay. He is saying the adjacent location was not empty. There was some content there. However the adjacent location does not belong to n is definite because I had m and n. I had taken the address of m. The assumption which I made is that n was allocated memory immediately following m. That assumption is wrong. So this is another vital information that we should remember. If I have declared variables and arrays in my program, if I have declared variables in a certain order, compiler is completely free to allocate memory to those variables anywhere it chooses. It is not necessary that the variables in my program will be allocated memory in sequence. However compiler guarantees one thing. If I have declared an array of say 20 elements, then those 20 elements will be definitely allocated memory in consecutive location. The entire array today may get allocated, here may get allocated somewhere else. But within the array the elements are not frittered away in memory. That is guaranteed by the compiler. Here is a modified version. So instead of ptr1 is equal to and m as previous. This time I do not play around with ptr1. But I simply say ptr2 is equal to and n. I am specifically extracting the address of n and assigning it to ptr. Rest of the program is same. I print the pointer values and I print the values pointed to by these two pointers respectively. This time I get the correct results. However, this time I notice that the pointers are these values. So 0xbfb2772c which is the address allocated for m and 28 is the address allocated for n. 28 is smaller than 2c incident. What the compiler has done is it has first allocated memory to n and then the next location has been allocated to m. But that is incidental and that is the compiler's choice. So what do we conclude? That the compiler can allocate memory to my variables anywhere it pleases. However, and this is the important point. If I declare an array which is let us say a3 and let us say a0, a1 and a2 I put some values. I print those out. I again do exactly the same pointer arithmetic that I tried earlier. I extract the address of a0 in pointer 1 and then I say pointer 2 is pointer 1 plus 1, pointer 3 is pointer 1 plus 2. So I am actually incrementing the pointers by 1 and 2 respectively. And I want to see what are the pointer values and what are the data values pointed by them. As you might expect now, this works correctly. These are the original values of a0, a1, a2. The pointers are these values. Observe that these values are consecutive. 5c, 5d, 5f, then 6 0, 6 0, 6 1, 6 2, 6 3 and then 6 4. So consecutive locations have been allocated to consecutive elements of the array and the corresponding data values are correct. So this is the important point to remember. In case of arrays, incrementing a pointer by 1 points to the next successive element of the array. So array elements are always allocated consecutive memory location. Please note this applies to an individual array. If I declare int a15, b28, then it is not necessary that the array b will be allocated memory following array. The entire array could be located anywhere. But if you capture the address of element b0, whatever be that address, then b1, b2, b3, b4, etcetera will always follow the consecutive locations. How do we use this fact to our advantage in our program? First, we have a relook at parameter passing. This is the way we have so far handled our functions. Suppose I want to calculate for given x and y arguments, 5 times x plus y modulo 10 as some function and return that value. This is how I will write my function int f in bracket int x int y. These are the two parameters. I declare a sum which is integer number. I say sum is equal to 5x plus y modulo 10 and I return sum. In the main program, I would have read let us say values of a and b which are integer numbers. I pass a and b as arguments to this function. So this is a function call. I know that values of a and b will go to this function. The sum will be computed. The return sum value will come here to replace f of a b and I will get that value in c. This much is normal. But what do we do if we want the parameters themselves to be modified and get back the value? Here is a standard example. Whenever we want to swap values of two variables, let us say we want to swap the values of variables x and y. We cannot say x is equal to y y equal to x. So what do we do? We take a temporary variable such as temp. We say temp is equal to x, x is equal to y, y is equal to temp. This is what we do. If we want to write a function to do this, our swap function might look like this. There are two parameters integers int p and int u. We have written int swap but it is immaterial because we do not expect the function to return any meaningful computed value. All that we want this function to do is exchange the value of p and q. So again I declare int t which is a temporary variable equivalent and I said t is equal to p, p is equal to q, q is equal to t. Return zero is incidental. Since I have declared the function to be int, I have to return something. Therefore, I am returning. Would this do my job? Easy question. So let us see. I modify my program like this. I read the values of x and y which are the actual values which I want to swap. I call this function swap xy and print x and y. Unfortunately, we will not get the value swap and that is because the way c plus plus functions work is that when I call this function swap, the value of x is copied to a location. The value of y is copied to a location and these locations, the copying locations are the corresponding placeholders in my function statement a and b or whatever or p and q. So even if I change p and q in my function, the copy changes. The main values x and y which I send remain exactly as they are. Therefore, I will not be able to swap values in this fashion because the function parameter changes are not reflected back into the main program. Now, while this is good because this is a safe green program, accidentally if somebody changes something in the function, my original parameters remain intact which is what we need most of the time. But whenever we need otherwise, what do we do? So here is a program which does not work. I have rewritten the program named, the function is named try to swap. Observe it is declared as y because I do not want this function to return any computed value. It is supposed to take two parameters a and b and says temp is equal to a equal to b, b equal to temp. I call it in the main program like this. I assign x is 1, y is 2, try to swap and output this. What will I get? Will x and y will have change values? It will have the same values copied back. Here is a note void is a very frequently used type for a function which does not return any value. We had once commented that we might declare a function to be void if for example, its sole objective is to let us say print some error messages. It will get an error flag value 1, 2, 3, 4, 5 and it will say if error flag is 1, I print this message, error flag is 2, I print this message and get out. So there is nothing computed, nothing returned. So this is perfectly valid. So this is used whenever the function is performing either a specific task or this is not expected to return any value. Now some of you would have tried in some assignments where arrays are passed as parameters. Consider for example, I want to write a function which sorts an array. The bubble sort or exchange sort or insertion sort that we have seen, a merge sort. It will require you to pass an array containing say 100 or 1000 elements and that function would rearrange elements in sorted order and send it back. Now that thing seems to work. How does it work? If changes to the parameters are not supposed to be reflected? Well in case of arrays the C++ functions behave completely differently. They do not copy entire arrays. It is obvious that it will be very costly. 1 million elements in an array, if you want to copy them you will have to allocate another 1 million locations there and copy those. So they do not do that. What they do is they pass the pointer to the base element of the array, internal. In fact the name of the array when you use the name, that name itself refers to the 0th element as address. So name of an array is intrinsically served as a pointer when passed as a parameter. So that pointer is copied properly. Yes. If somebody changes that pointer in the function, that change will not be reflected. A will continue to have the same locations in memory as you had in the main program. However, if the function is small, it will not of course modify the given pointer copy, but it will use that copied value directly to perform operations. And when it performs operations, since that pointer still points to the original memory allocated here, the actual operations happen on the variables that I have in my main program. So array elements if they get modified in a function then the change is reflected back in the main program because of this reason. We understand now that if we pass pointers, then our method can work to swap variables. This is known as calling by reference. I will have to make specific changes in my function. Earlier I was getting two integer parameters. Now I will say I will get two integer pointers. If I work with the pointers, I still declare an integer temporary variable temp. I said temp is equal to star a. This is the actual value pointed to by my pointer in the main program. Star a is equal to star b, star b equal to temp. Observe how we call this function. The way the function is invoked is same thing integer x, integer y. X is 1, y is 2. When I call swap, I do not call swap with x and y as parameters. But I send and x and and y. So what am I sending? I am sending addresses of x and y. These addresses will be copied in the appropriate pointer positions. These addresses will be used to do this work here. And since I am manipulating the values pointed to by these addresses, the actual values of x and y will get modified. So whenever you need a function to return more than one value, you can actually use placeholders as addresses of the actual parameters. And those parameters if changed by the function will be reflected back when you get back. This is an important reason why we did not discuss input output functions in C so far. We shall see how the input function which is called scanf. We will be discussing that shortly. It requires you to send pointers of variables rather than the variable names themselves. But first we look at the use of pointers in handling character arrays. This problem is not new. This type of problem we have solved. We had seen this kind of work even in the mid-same exam and several assignments. Somebody has typed this name on one line or this name on one line or this name on one line. We presume that each name consists of first name and second name. We presume that these two parts are separated by one or more blocks. We wish to write a program which will read this string and it will separate out the first name and second name. That's a simple problem that we wish to do. Again we know how to do it. We can define a large string. We can use get as function to read that entire string. And then internally we can keep looking at various elements. Look at the position of the blank and separate out the two parts. But using pointers and using some built-in functions this task becomes much easier. Here is a sample program to do that. The two parts are assumed to be separated by one or more blanks. I include IoString. I use cString which is the standard string library which gives me a whole lot of built-in functions which are available to me. This string is arbitrarily large. Usually a line that I type at import will be less than 80 characters long. But I can without typing return character continue to type a single string on a line. So I am assuming that the maximum string length will be this. I am declaring a character pointer. Car, star, car, ptr. The name is irrelevant. Name is my choice. I could have just said ptr also. Just to indicate that it's a character pointer I am using this. I am declaring two separate arrays to hold the two parts. First name and last name. The variables n char means the number of characters in the original name string. Blank pause is an integer variable which will locate or which will point to hopefully to a position where a blank occurs in the given string. I have length first, length last representing the lengths of the two parts which of course I will have to decipher from the input. I is an ordinary index variable. So the program proceeds with asking you to type a name and you use the get s statement to read the name string. Get s is a deprecated function. A deprecated function means these days you don't use get s. In c plus plus as we shall see later we will use get line. But get line is part of the object library of c plus plus. We have not yet seen object oriented features of c plus plus which we shall be visiting from next week onwards. When we do that we will see how get line could be used. Get s however works perfectly correctly and it is a valid part of the c string library. So when I say get s I will get this name string. Again for those of you who have forgotten the get s statement does the following. It will read each and every character that you type up till backslash end which is the new line character. So when you press return whatever characters you have typed will be assembled together into the string that you have put here and a backslash 0 will be added at the end of that. So you have to remember that not to type more than 255 characters in a line because the array length is 256 and you require the last position at least to hold the backslash 0. Anyway having received this string I calculate the length of that string by using the well-known str alien function which will return the length of the string. Now in order to separate these two one method that we ordinarily use is we set up an iteration looking at every character of this name string and if a character is blind we say we found a blind then we will separate out the first part and last part. This task is done by another built-in function and that function returns pointers. In fact it uses pointers as the arguments as well. So this is what I wanted to introduce to you. Here is that function memchr. Memchr is a very powerful function. It says that given a string which is named string here try to locate within that string a smaller string. In this case it is one character. Memchr is locating a given character inside the string. What is that character? This character is single code blank single code. So notice that we wanted to know where the blank occurs in that string. This particular function will examine all the elements of name string one after another. Trying to locate a blank the moment it finds a blank it will return a pointer to that blank. How long should it search? It might search the entire string. It might search even beyond the string. It might search before the string. We are permitted to specify how many characters it should search. Since the length of the string is encarred I am initially asking this function to look at encarred locations of the name string array and find out whether there is a blank. There is a possibility that there is no blank. Somebody has given an input which does not have a blank. In which case this function returns a null pointer. So if there is a blank the function will return a pointer which points to that blank position. If there is no blank it will return a pointer which is null. A null pointer is the C++ way of saying look I can't figure out where this fellow is. I can't figure out the right value of the point. Notice this square star here. This is called casting. We have seen that. We can say float, we can say in forcing a casting of a type on to whatever value is calculated by the function. This is necessitated by the fact that C++ actually declares main care as a wide star function. So wide star means what? Actually it's a generic function and wide star is a generic nomenclature used by C++. You can cast it to point to any type of pointer provided the operation that you are doing inside that function is appropriate. So I know that this will return a character pointer therefore I am casting it as care star and I am assigning the return value to care PTR. So this is a very powerful use of a pointer. I don't have to set up an iteration to search anything. I just call this function, give it my name string and say locate blank. Observe that I can use the same thing for my mid semester marks analysis by asking it to locate a comma. It will locate a comma and it will give me a pointer to that position. What do I do now? If care pointer is null, well I have nothing to do because that means no blank was found. So there are no two names in that string but if it is not null then I do the following. I have found one blank. I will get the first name. How do I get the first name? The first name begins at 0th position of the name string and it continues up to the blank position minus one. I am therefore setting blank pause to care pointer minus name string plus one. What is name string? Name string is the name of the array. By convention the name of the array is a pointer to 0th location. So I can use name string directly. Care PTR is a pointer which was written by this pointer. Let's say it is 9th. 9th position was blank. This points to 0th position. This is the address of 9th position. So 9th position minus 0th position plus one will give me the position of the blank in absolute in relative terms to the string and I will say I found blank at this position and I know the length of the first part. Since it starts with 0 blank pause itself is the length. I use another function to copy this part of the string in my first name array. First name is the array in which I want to copy a part of the string. Name string is the array which is the full name. How many characters I want to copy? I want to copy length first characters. So if length first is say 7 that is the first part is 7 characters. 7 characters will be copied by the string copy function. But after copying 7 characters I must insert a backslash 0 in null value at the end because otherwise it will not be a valid string. So I put first name length first equal to 0. It is same as assigning backslash 0 and I can output the first name. I can output it either through an iteration like this outputting one character at a time. Or as you know I could have stated see out first name and I would have got the string because first name is a valid string. So do you notice the string operations here? The pointer operations here that the two names could be separated by more than one blank. So I put a wild statement which says if name string blank pause is blank, the first time it will be blank of course because blank pause points to the blank position. So what I will do I will increment blank pause. So I am actually moving blank pause further, further, further till such time that it is no more blank. What does it mean? It is the beginning of the second part of the name. I use that and now of course there is one more check. Suppose somebody goofed up and did not give me the second part at all. That means I will reach the end of the string without locating a blank. Without locating a non-blank character. That means there is no second part. So print a message. There is no last name. And I do an exit, error exits all. But if I find that name, then I will find and print the last name. Again pointers are being used here. Notice how? I want to calculate the length of the last name. I know the end of the string, the total number of characters there. I know the beginning of the second part. I want to now copy into the last name, the beginning of the second part up to the last part. What is the beginning of the second part? Name string which points to 0th element plus blank pause, which now points to the first non-blank element because of my advancement of blank pause. So name string plus blank pause is a pointer to the first non-blank character of the second part. And from that point, how many characters I want to copy? The length last characters because that is the second part length. This strn copy will copy n characters or specified characters from a string pointed to by this pointer into a string pointed to by this pointer. Last name incidentally happens to be an array, but it is treated as a character pointer, which is correct. Then, of course, I have to put a 0 in the last element of that array. Otherwise, it will not be a valid string and then I can print out the last. If this does not happen, I will say the name has only one word and I will type the name of my colleague and it says found blank as 8. This is the earth position. First name is last name is sad. I could try giving some more spaces in between as I have inserted here. So although there is a blank at 7th space, there is a blank as 8th place also, blank at 9th place, blank at 10th place. However, my program skips all those blanks, copies the two parts correctly into their first name and last name and prints them. Suppose my colleague Sridharaiya types his name only as Sridhar tries to cheat the system, the program will say name has only one word because there is nothing else there. However, another smarter chap, Professor Kavi Arya, may put some blanks at the beginning to see what happens. Observe that in our program, we assume that a first blank will happen after the first part, but the program does not think so. Program will locate the first blank where at position 1. As per our rule, it will find the position at 1 and therefore the first part is blank. It will have only backslash 0. There will be no character there. But after skipping these many blanks, the rest of it will become part 2 and therefore the last name is Kavi Arya. You might try to correct this situation by taking into account the possibility that a blank may occur at the first place also. In fact, wherever you deal with character strings and whenever you have an input given in terms of character string which has separate parts, each part containing some valid value here and you want to validate whether the input is correct or not, this kind of processing becomes extremely important and required. It is in this context that we shall quickly look at the IO functions in C++. So far we have used C in and C out. C in and C out are actually not functions. They are called methods or they are called member functions of an object class which is called the stream. We are not we are going to look at that and visit that later but traditionally C++ familiar languages does not have any input-output instructions. Unlike earlier programming languages like FORTRAN and ALGOL, they had specific instructions to do input-output. In C++ input output is traditionally done using IO functions and the standard functions are scanf and printf. The parameters to these functions include a format string. Observe what you do in C in and C out. When you say C in greater greater something, you are actually going to type some text on a line and you want C in to interpret different values from that text. Usually you might give an integer value of floating point value or whatever separated by one or more blanks. So the fact that these blanks are to be forgotten, you have to identify the first element is this integer number, second element is this floating point number, etc, etc. We have seen this kind of thing when we analyze the mid-same paper question and we said I could use the function a to f a to i that is ascii to integer ascii to floating point. But before that I need to separate out that string and ascii string from which to interpret this value and after interpreting that value I could put it aside into variable. All this work is done automatically by C in and now we see how the same work is done by scanf function. The exact opposite is done by printf or cout. When you say cout mn what is happening? m has a integer value, let's say n has another integer value, x has a floating point value. The cout operation actually takes this value, converts it into an ascii value and prints it. cout is a rather dumbo function. It does not put a blank automatically between two consecutive values. You have to insert a blank if you want and that is called formatting. Such formatting information can be prescribed by us for the built-in functions printf and similar formatting information for interpretation of input values can be prescribed by us in this scanf function. We shall quickly look at these two functions and how these functions work. This is the format of printf. The printf function has a format string followed by comma value, comma value, comma value. A value could be a variable, could be an array element, could be a character array, whatever. What does printf function do? Let us say we say percent d is a number backslash n. This is the format string, comma n. n is the value which I want to print. The first is a format string. What printf does is in the format string it tries to look at a format specifier which will tell it how to convert the value of n. In this case the format specifier is percent d. All format specifiers in printf and scanf always have this form, percent d, percent g, percent f, percent i, etc. If the value of n is 523, the output produced by this function will be 523 is a number. Observe is a number comes from here. This blank also comes from here. Percent d is the only format specifier which is associated with n. All that percent d says is take that number n and convert it into a string of characters reprinting that value, as simple as that. There could be more values here n comma x comma y comma z or whatever. There could be more such format specifier. There need not come one after another. I might want to print a value then some string then another value then some string. So I can intersperse any number of format specifier in between the string that I write. In fact if you look at any standard cc plus plus book the first program that you write is called a greeting program. It prints hello world. You have seen that? The hello world program will usually have a printf statement which will say printf double quote hello world backslash and double quote. No value. In that case printf function is being involved not to convert a value into some integer of floating point value into a string but just to print the string itself which is perfectly valid. Percent 6d will specify six digit integer. Percent 7s will specify seven position string. So if the associated string is of larger number of characters only seven characters will be printed. Percent 8.2f will specify a floating point number to be printed totally in eight positions but 2d after the decimal digit. Same percent 8.2g says that use the same format however if the number does not fit there because it is very large or very small or whatever switched to E notation. There are many such format specification you can read any standard book on printf and you will get all format specifications very clearly explained even online tutorials explained the printf format specifications. Let us look at scanf. Scanf has exactly the same pattern as printf except and this is the major difference. I have a format string and in that format string I will have as many percent d percent f etc as many values I want to read. The difference is in printf I was giving values to the function to be printed. I did not expect anything back. In scanf I want the function to read my ascii characters convert them as per my format specifier and give me back the value. Recall our discussion on function invocation. A function is incapable of giving back a value if I only pass a parameter therefore I pass addresses of the parameter. It is in fact only this reason why I have avoided discussion of scanf and printf because unless you are familiar with what a pointer is the notion of and, where one and where two etc won't make sense. You agree? Now you understand what a pointer is and therefore the pointers have to be passed. So scanf needs to be passed pointers so that the values which are assembled by ascii to floating point ascii to whatever conversion are correctly returned back to us. The format string is used to control the interpretation. The stream which is the which is the input character string that you give will contain values to be assigned to the objects pointed to by the remaining arguments to scanf. So here is an example. m and float x y care name 40. Look at this scanf statement percenty blank percenty and m and m. This blank is important. This blank says whenever one blank occurs inside a format string for scanf for printf one blank translates to producing one blank in the output. For input one blank represents any number of white spaces. So actual input that you give need not separate out the two values that you input by exactly one space. You can give two or three spaces. You can give a tab character.  All of them are considered to be white spaces. So all that this format specifies is look somebody user will give you two values. Interpret each values in a percenty fashion that means these are integer value. So use as key to integer conversion internally if you want to and return back the values of m and m. Observe this percentf blank percentf blank percent s. The parameters given are and x and y and name. Observe that x and y are explicitly tagged with the address operators. But the name which is an array here is given as is why because the name of an array itself is automatically a pointer to the 0th location of the air using my cout statement. Now there is just one small squiggle which can be done using scanf but which cannot be done using c in. Suppose this is my input data. Imagine that you are doing an inventory control system for Hindustan Aeronautical Limited they have let's say 100,000 different parts each part has a part code each part has a part name sort of each part has a has a what you call followed by an item code followed by an item value. So let us say fan belt is an item code the item number allocated to fan belt is one two three four five six and let us say the price of that item is 150 rupees 50 and somebody who designed this program long time ago when the space on the disk and memory was extremely costly decided that why should I waste a by by putting a blank in between these after all this is the machine which is going to store these values and the machine which is going to interpret these values. So I save two bytes in every line if such is the input notice that using c in statement you will never be able to get these three values separate because the c in operator requires that different variables which are you are reading from c in are separated from each other by one or more blanks. However by using scan f you can very well do that. So if I say scan f percent six d percent seven s percent f no blank in between this tells the scan f function that somebody is going to give you an input the first six characters of that input are to be interpreted as an integer number and are to be extracted in variable a the immediately next seven characters are to be interpreted as part of a string are to be extracted and are put in the array item code. The scanner will also by the way put a backslash zero at the end automatically. The immediately next characters and this time it is not prescribed how many are to be interpreted as a floating point number and are to be allocated in the memory location for x. Now this is something which you can do using scan f if you have to do the same thing you can't do it using c in but you can do the equivalent of scan f how you do a get us get the and do all the donkey work of extracting separate parts six characters here seven characters here do an ask you to float ask you to integer conversion all that work is done automatically by scala. I would request you to read the details of scan f and print f and practice using the scan f print f details whenever you visit the labs we will have one more assignment for the lab but that there will be no more assignments you'll be required to do your projects. I hope you have formed your project teams the project titles as options will be declared on Friday you will be required to give a choice of four or five project topics that will be prescribed and then you'll be allocated a project which you'll have to work on. There's some important notices and this is the last part as you know there are students I still haven't got by the way all the marks of the allocated by lab TAs as bonus marks so I think yesterday the last batch was submitted my staff will be doing the data entry and validation and will be announcing the final marks on the Moodle on Friday but there are students who unfortunately have not scored good marks in the mid-same and therefore it is possible that they have some serious problems with fundamental concepts. I am arranging extra tutorials these are not lectures these will be tutorials where set of problems will be solved by these students but under the tutorship and mentorship by TAs and I will be personally present here only those students who have secured five marks or less are required to attend this a few others may come but the classroom has a limited size so I have mapped the number of students with five marks or less and I request all students who have less marks like this to necessarily attend we will take attendance there I will be incidentally taking attendance from Friday in a conventional way because the clicker problems although they have resolved they are still not able to guarantee a zero error situation and I don't want to take attendance where some five students are missed out on one day and some test scores are missed out on the second day so we will do a conventional attendance on Friday. As I had announced last time there will be a make-up test for students who have secured 10 marks or less this make-up test will be conducted on Sunday 24th October from 10 to 12 hours most probably in one of the classrooms in the Kamal Rekhi building I'll announce it why this case is being deferred to such a long time that is because I want students to gain confidence either through such special tutorial sessions or through their own efforts needless to have this make-up test will also be a 40 mark test but irrespective of the maximum marks scored by the students the maximum marks allocated will be 10 so that you are not unfair to people who already scored 11th marks or 12th marks or so but this gives a genuine chance to all the students who have got less than 10 marks to make up and come up to that level now the sad part of the news I had announced that I will accept submissions from you for re-evaluation of any answer that you have given where you believe that the correction or the evaluation has not been correct unfortunately there's come to my notice that people are preparing for such a resubmission preparing seriously meaning they are making changes to their answers and they hope to gain some marks like this apart from being grossly unethical for which as you all know the only possible action is an immediate award of fail grade with repeat I have said this earlier we will tolerate anything in this course if you need any help we'll try and give it as much as is possible but any kind of cheating for the smallest amount of provocation a fail grade will be awarded immediate therefore I will still accept the inputs from you for resubmissions but there will have to be an affidavit which must accompany every submission that affidavit wording I am setting you will have to write it in your own hand on a separate piece of paper which will roughly say that you are aware that any unethical behavior in this course will result in a fail grade and that you have not made any changes to program and this applies not only to the questions which you asked for rechecking but even other questions you have to certify that you have not made a single iota change comma full stop change in your answer because that is what is expected by good human beings a basic ethics that is required if that is not so please don't resubmit because I don't want to be forced to give an affidavit okay but I will do that there is no compromise on that answer books for reevaluation will be collected on friday so start preparing an explanation of what your contentioning so you say question 3b you have been given let's say one mark out of four however you believe that you should have been given three marks of four marks or two marks or whatever because this is the additional explanation that you want to offer that additional explanation for every question that you resubmit for reconsideration will be looked at by a group of people on this saturday sunday and we'll announce our judgment online so this friday those of you wish to resubmit papers for reevaluation i will put up a notice on the moodle on exactly how the affidavit should be in exactly what you should write but these additional page or pages that you write on blank papers should be stapled properly to your answer book and then that should be resubmit that's all for the time being this this particular week as you would have noticed there is no fresh assignment this is your last chance to catch up with the pending submissions there have been some students who were severely ill for a long time there's some students who had other emergencies they could not complete the lab assignments there are some students who are perpetually absent in the labs and that is not acceptable the lab attendance also counts and i have decided to take attendance very seriously you look at the attendance today this class is supposed to be full and i think they are at least about 50 students who are upset it is my experience in last 40 years that people who attend classes are actually the ones who need not really attend because they are diligent they are studying something and they will be able to catch up with the people who are at the lower level of the performance will not be able to understand things and who need to attend are usually the ones who don't attend now this is a dilemma i have no solution to this except to enforce the issued rules that the attendance is compulsory so from friday onwards the compulsory attendance will be put in place i'll be taking attendance in the conventional manner i'll not be wasting my time or your time three separate sheets will be circulated in three groups the roll numbers will be listed in increasing order of roll numbers so in order to sign against your name please don't read each and every roll number in that long sheet use binary search locate your name and sign it and and and pass it back okay thank you


Let's take a bold step and ask you before we look at the preview of Mouko versus Croatia. It's very very difficult. There's any factor, a lot of people want Argentina to win is a messy factor. Beyond that, who do you think will win today? Yes, I think I am one of those who also wish that Argentina would win the World Cup because of messy. Beyond emotions and sentiment, I think on the balance of the quality that are available to the two teams, I think Argentina has the capability to also merit to win the World Cup. But like I said, football is like a biscuit, you cannot really predict, depends on what you bring on the field of player when that period in time. Your result yesterday is not important, what is important is the 90 minutes. As honourable as a football analyst, I think the best team should win. And I also pray that the best team will win as well. But if you want to ask me for sentiment, for emotion, I think it would be a thing of joy if Messi will cap his last appearance at the World Cup with a triumph. So for me, it's not that here or there, which is what will happen in 90 minutes or beyond, or might even eventually go to the game of luck, you know, penalty shoot-out and everybody, it's everybody's game. But if you ask me for the sake of Messi, I will wish that his team triumph. Last year, let's look at them to this game against Morocco and Croatia. I'm sure we analyzed that yesterday, but obviously in some hours time, we'll be seeing the first Africa playing in the World Cup third place match, and that will probably be that's historical, and we will be having perhaps the first Africa to win a medal at the World Cup since inception of the World Cup in the 50s. So let's see why you panned out tomorrow. What's your stake on today's game between Morocco and Croatia? Again, like I said yesterday, because of the injuries that really affected the Moroccans, you know, I tend to say that the game will probably go the way of the Croatians. But bear in that, if the Moroccans, if all the injured people are able to recover on time, and we have them there, I think we have a good game on our hands, and it can either go right away. Like I said yesterday, the two teams are very, very disciplined, you know, and they said that to win the tournament, you have to have a very good defense. The two teams has exemplified that, that the fans win the tournament, and they are almost winning the tournament even for the last order that they couldn't overcome at the semifinal. But so far so good, I think they have shown that if you have a good organization, good defense, and there is that likelihood that you are going to win. And the two teams have, like I said, they have shown that. So we will just sit back and see what will happen. But again, as an African, I wish that Morocco will win, and it's my prayer that they will do win. But if we are looking at it without sentiment, and based on the quality of players that are available, I think the Croatians have it. Don't forget that the powerhouse of the Croatians have been their midfielder. If you look at their midfielder, you have Kosovik and Mosović, and the ever-hageless Madrid, you know, and it's a joy to have that kind of three midfielder, you know, they hold on to the ball, they keep possession. Even when they lost against Argentina, they were passing the midfielder. So for me, that's going to be very key. And I think if Morocco can neutralize the midfielder, the job is halfway done. But I pray as an African that Morocco will win. I pray as an African that Morocco will win. I wish that they will win. So I'm going to be looking for them today. Definitely, all Africans are waiting, and not just all Africans, all Arabs, perhaps because we know that the Moroccan side have a very strong alliance, strong ties with the Arabs who are with them. So it's now between the Africans' routines and the Arabs' routines for Morocco. With this, it's noted that perhaps the biggest footballing nation in Africa as the North Africans, the last edition, apart from the last edition, the one before Senegal won, we had them, Algeria, winning the nation's cup. When it comes to continental football, it's mostly the North Africans that would ace when it comes to continental cup, cup champions live and cup confiduation cup. I just want your opinion. What do you think the North Africans are doing in terms of sports that's making them are aid of other African teams, other section of them, the African that's the aid of the West African or the South African. In Morocco, even beyond football, in table tennis, in swimming, we have so much of the Egyptians and all that. What do you think the North Africans are doing in terms of sport that are aid of the other sectors of Africa? First of all, I'd like to differ a little bit on what you said in terms of the performance of African teams at the World Cup. Prior to this year's edition of the World Cup, all the previous teams that have gone beyond the second round in the World Cup has always been African teams, or if you want to say Central, Cameroon. We had, prior to now, we had about four African nations, Nigeria, Senegal, Cameroon that has, Senegal did it twice, that has gone beyond Ghana, that has gone beyond the second round and all of them have been West African teams, you understand. So, it's just only this edition that we have in Morocco that has gone beyond the second round and reached the semi-finals. But having said that, I think the question is why do they tend to do well? Well, the simple question, if you want me to just say simply, that maybe because they are near Europe and the rest of African countries, but jokes apart now, I think what is going for them is their league. They have very quality leagues, most of their quality players do not go abroad, except when they go abroad, they go to Europe or there, so they have the best of their players playing their trade at home. Because the leagues are well organized compared to some other African countries where the leagues are poorly organized, it's neither as quality for these or that. So, for me, the organization that the league that they brought about has manifested in their league is a very key factor. Again, the sponsorship of their leagues, the sponsorship that comes with their leagues, it's also a key factor. Here in Nigeria, the league is not even on the TV. I remember when I was going, I used to support me in Nigeria Bank. Nigeria Bank was based in Binning, and each time I tried to monitor Nigeria Bank using my grammar, translator, I have to tune in to monitor it. I was not forced. It was because of the love that I have for Nigeria Bank that I followed Nigeria Bank. And in those days, I would remember, I followed the Keshi deletes, the Binkeshi, Ozogula, Humphrey, Debo. Those are players that are applying their trade and their quality. Most of them, I remember in those days, the large chunk of NMP players forms the nucleus of the national team. But where are we today? The league is not interesting. We don't go to watch the league. I remember when I was growing up again, I used to go and watch the league, the stationery stores at UAC, this person, Teslim Balogun, and only comes to them. Nobody forced me to do that. I was doing that out of the love that I have for it. But now, the league is not that interesting. If you ask me, which team is even applying the flag of Debo State in the NPP, I would say, I would not go and that is the honest truth. Because the organization has been called. So if the organization is called, how would quality players come from that? So for me, it is because of their organization and their league. That's why the most of them, not often, they tend to do well. Even in Africa, let's say, even not to extend it beyond Africa. In Africa, in the Champions League, they are the one that usually triumph at the end of the season. But they are not able to reduce it. It is not that, if it is not that, the Egyptian players are going to be the Algerians or the Moroccans, their team that will triumph. So if it is the organization, this is how they have organized that league. Then the management, people do not, they put interest beyond personal interest. They put the national interest beyond personal interest. And that explains why they have been successful as well. Well said and I confirm to all what you said because articles and reports we see online from a confirmed source of media houses actually said the same thing in regards to the two sides. I don't want you to be on, definitely you won't have to be on the defense right now, being neutral in the prediction of who is going to win today's game between Morocco and Croatia. What's your prediction for today's game? Well, my prediction is that Croatia will win. But if you want me to predict this call, I might say 1-0. But I pray that my prediction will fail so that Morocco can win. If not because of the fact that I am an African. But if you want me to be very honest, I think Croatia will win 1-0. Okay, thank you very much. But don't forget you preview these games for us. Definitely obviously there will be another other person that is going to give us a review of the matches today and tomorrow and tell us why it's going the way it went. Perhaps in favor of your analysis or against your analysis. So just keep your time and let's don't forget that you also come back in the studio in few days time to tell us what happened at the top place much between Croatia and Morocco and the final between Argentina and France. So just keep it digital some few days time. Thank you very much for being part of today's show. Thank you that like I said, it's always been an honor for me to accept this invitation. I am quite honored. Thank you so much. I look forward to it as well. Thank you very much. Yes sir, we have been speaking with the general manager of Radio Lagos Equal Farm. We are talking about Laji De Lawa who has spent his life on so much football and other sports and he is a very, very veteran broadcaster.


Personal Finance Practice Problem using OneNote. Earnings per share and price earnings ratio. Prepare to get financially fit by practicing personal finance. You're not required to, but if you have access to OneNote, would like to follow along. We're in the icon left-hand side. Practice Problems tab in the $1270 Earnings Per Share and Price Earnings Ratio tab. Also, take a look at the Immersive Reader tool. The Practice Problems, typically in the text area too, with the same name, same number, but with transcripts, transcripts that could be translated into multiple languages and either listened to or read in them. We're looking at tools that can help us out with our investment decisions related to stocks, stocks representing an ownership interest in a corporation, corporations being separate legal entities that have their ownership interest broken out into fixed or even units of shares or stocks. And we're also usually thinking about publicly traded companies, those which have decided to be on public exchanges, making those corporations more transparent, allowing us to get access to more information such as the financial statements to make our investment decisions. Also, note that investing in stocks is a little bit different than investing in other tools such as mutual funds or ETFs where you're kind of grouping together or looking to diversify under the tool of a mutual fund or an ETF. Keeping that in mind, we're calculating the earnings per share and price earnings ratio, very common calculations. We see the calculation down below. The earnings per share equals the net income of the company. The net income could be found if you get the financial statements of the company. We're typically looking at the financial statements on a yearly basis oftentimes, although you could look at other intervals as well. And it would be on the income statement, basically the bottom line of the income statement, revenue minus expenses. Remember that you can get some of these terms a little bit confused in terms of revenue or income and then net income and like net sales. Sometimes you hear these terms. So the net income, we're thinking the bottom line after the expenses in essence. And then we're going to divide that by the average outstanding shares of the company stock. Now note that you might think of it as simply the outstanding shares as of the time you do the calculation, which will probably be the end of the period, right? You're going to get the financial statements for a year, year ended, let's say December 31st and do the calculation as of that point in time. So why would you take the average outstanding shares? Well, in that case, you're trying to look for a point in the timeframe that represents all the points in that year in essence. And you could do that by possibly looking at the prior financial statements in the prior year and look at the outstanding shares at that point and then add them to the outstanding shares at the current timeframe, dividing them by two to get some kind of average. That's not a perfect calculation, but it's an attempt to get an average. Why is that important or why might that be necessary? One, the net income note is a timing statement or timing term. It's on the income statement, meaning you can only say how much income you have or how much revenue or net income you have generated if you give a timeframe such as a year, a quarter, a month will typically be thinking about in essence a year. Whereas when you look at the number of shares outstanding, that actually represents a point in time. So typically if I ask a company or try to look up how many shares are outstanding as of 1231, I can look up that point in time. So notice you're dealing with something that's a range in time and a point in time. In order to match up the point in time and the range in time, you might try to take an average for the point that best represents some point over the range of say a year. This may or may not be as important as well depending on the activity and the shares that have been outstanding. For example, a company might issue more shares in order to generate more revenue, but that doesn't happen all the time. Most of the time the trading that's happening in the stocks is on the secondary market not from the company issuing more shares. They'll typically issue in the initial public offering and then possibly periodically after that point in time or there might be stock splits that happen or buybacks that happen as well, meaning there's changes in the number of shares over the time frame whereas you could have a situation where there wasn't much change in the number of shares over the time frame as well. Okay, let's do that first calculation company information up top. We're going to say the earnings is going to be the 6,500,000. The shares, the shares of common stock are the 2,900,000. The earnings would be found on the income statement in essence, the shares, the balance sheet or on the financial statements and the stock market price is going to be 40. Notice the 40 is not something that would be determined by the financial statements by management, by the company. It would be determined by the market, by supply and demand of these fixed units of stocks that are currently trading for the $40 because they're all uniform. They're all the same in nature. We can say that that's the actual stock price. So the earnings going to be the 6,500,000. Remember that's net income. Notice earnings is another kind of somewhat ambiguous term because you know, it could represent, you might think of it as revenue or net income. So you got to be careful with how those terms are used and the context in which they're going to be used. So it's the bottom line of the income statement in essence. And then we've got the shares of common stock. So these are the number of shares outstanding. They represent even or equal units of ownership interest. They're all basically the same. One person could own of course, multiple shares of common stock but still have them broken out into those fixed units. And that's going to give us our 2.24 about. So if we got our earnings 6,500,000 divided by the average units of ownership interest. We're saying there's 2,900,000 of them out there. That's going to give us our 2.24, $2.24 about of earnings on a per unit, not per owner, but per stock because an owner might own multiple stocks for example but per fixed unit, $2.24. Now note that if we had preferred stock we might alter the formula a little bit because then we would take the net income of the company minus the dividends to the preferred stockholders because the preferred stockholders will be paid first. That's why it's a preferred stock. Don't get that preferred term confused with the preferred stock being safe better than common stock. It just has different characteristics so that terms a little bit misleading but they get paid first generally. So you'd have to take the net income minus the preferred stock if there was any outstanding. And again notice here we divided by the shares of common stock as of like a point in time as of the end of the year. It depends on what the circumstances are in terms of whether you might want to try to take an average which would be like you could take basically again these shares that were outstanding at the end of last year add them to the current shares in the current year and divide them by two. There's no perfect measure because again you're trying to compare something that's a point in time to a time range but those are some other things just to keep in mind. And then we've got the price earnings ratio the price earnings ratio is simply going to be taking the $40 which is determined by the market that's what the stock is currently selling for if it's traded on a public exchange we're going to know what it is because we know that those stocks are probably going to be trading all the time. So we take the 40 divided by the 2.24 and that's going to give us our price earnings ratio of the 1785. So notice what we're saying here we're saying okay this is the earnings on a per share basis and now we're going to take the price that the stock is selling for if it's selling for $40 what is the or how many times over is the earnings per share on a per share basis dividing into that 40. So we're going to take the 40 divided by the 2.24 and we get about 17.85 in essence. So in essence you would say okay well if I paid the $40 for one share and I earned $2.24 let's say this was on a yearly basis then it would take 17 or 18 years to in essence get a return on that earnings per share. That's just a quick kind of calculation. Now note that that number then the 17.87 is useful in that it's generally going to be used as a relative comparison to other kind of stocks typically within possibly the index or possibly the stock itself in prior periods or possibly to other stocks that are currently in the same kind of area or categorization or zone. So we're always doing some comparison and benchmarking to say other stocks to try to paint a picture use a bunch of different ratio analysis to try to paint a picture of what might be happening in the future what's the true valuation of these different stocks so that we can then make decisions based on that going forward. It's also important to realize that this earnings per share of the $2.24 does not necessarily mean that we're going to be receiving in the form of dividends of $2.24. That's basically what the company has earned on say a per share basis. Now we're hoping that we're going to get some value from that either in the form of possibly some of it in the form of a dividend or if they don't give us a dividend we would expect that they would take those earnings and roll them back into the company investing in assets and machinery and equipment for example to grow and that would then increase the value of the company which hopefully would be reflected in the stock price. So the stock price will typically increase if the company is appropriately taking the earnings that they're earning and rolling them back into the company increase in the value of the company and the earnings potential going out into the future. But again just remember that that earnings per share is not necessarily anything that we're going to realize at this point in time it's just allocating the company's earnings over the number of shares outstanding.


It's very much the Open Water Foundation is very much, you know, just in the very beginning. Tracy is here, she's our tax chair and really been instrumental in getting the project to where we are. But our, you know, discussion started probably last summer and in the OSCEU in Dublin last year, September, we made a, you know, boat announcement and the person behind is Daniel. Unfortunately, he couldn't be here. He's in a parallel meeting in European Identity Conference in Berlin the same week. And so he and many of the people really from quite diverse different background and communities realized this concept of open source project for a wallet. And, you know, I will touch a little bit about where these diverse background or diverse people somehow all merged together. And we finally had an official launch in February this year. And so we are kind of almost three months old. And I think Tracy, we had the two code contributions started two days, three days ago. It's for SDJWT, that's for selective disclosure, JSON web token. So people understand web token. This is, you know, this little digital object that we can send each other through web and give people a way to use that as a means to build trust protocols. Okay, so you might have heard not in this keynote or probably tomorrow, a digital trust initiative by Linus Foundation. So the open wallet is also part of that. And I'll leave some information on how the rest of the foundation as well. Very simply, we look at a wallet today and the very, you know, these are called general purpose wallets. So both, you know, Apple and Android platforms offer some kind of built so-called building wallet. It's very general purpose in the sense that you can have many things in it, many kind of things, you know, whether it's cash, credit card and stuff. We also have a lot of a specialized wallet. I didn't show up here. The specialized wallet will be like a crypto wallet or a bank, specific banks application and you will be dealing with only things owned by that particular application or use case, right? So those are more specialized. And we're thinking about as an open source project is, A, we want to have a common go quality code so allow a lot of these kind of application can be relatively easily developed with good privacy and security features. And also we would like to be general purpose so they can be used in any scenarios, not just for a bank, but, you know, in this session, how about one of us, right? So that's the goal. And here are some of the examples. So you can imagine in the middle is all these cards you can pull out of your wallet. You know, basically each one, you can think of as a representation of data. We found very valuable. So anything like really we care about, we want to control over, I think can be represented in some kind of digital objects. And these are, you know, I've shown quite some examples that can be carried with your wallet. And the wallet doesn't necessarily have to be in your mobile phone, but it can be, you know, virtualized in the web, cloud into a metaverse headset and different hardware. So the Google people just hand us one token this morning so that can be your notion of the wallet as well. So it's all different purposes. We use an analogy to try and explain what the project's trying to do. And the analogy is a web engine. So Blink is a web engine and the Blink today probably covers, I don't know, maybe 80% of the browser markets. So the browsers are commercially developed software product, but the engine beneath it is Blink, right? And V8, which is in the JavaScript side. So those, you know, eventually implement a whole category of standards for browser that will be, you know, HTTP, CSS and JavaScript. So if we take the similar kind of the reasoning, why we need this as an open wallet where we, you know, basically building these open source software components that's going to be very critical to build proper wallet or wallet-like applications. And there are many, many of them. And it's really, I think I want to think about a wallet-like application. It's any application that we feel there are data and things we really feel very valuable to us. We want to have control over. And that can mean almost everything, I think. Like if we care about our privacy and ownership and have basic agency in the digital economy or digital, you know, network ecosystem, it is important for us to carry something that we have control over. And so there's a whole set of protocols related to that as well. In addition to these, like, we think of technical protocols, there are also a lot of regulatory rules and in European Union, they call tool box. You know, these rules will also dictate how these assets can be managed. Anyway, so I hopefully already, you know, explained the mission statement. So essentially that's what we want to do. We're not building wallet ourselves. We're not, of course, sort of deciding any, you know, commercial rules and the protocols for standards, et cetera. We'll be coming from the traditional standard bodies as well as the new ones that I think we will develop over, you know, for example, in the Metaverse. I'm sure that Metaverse ecosystem will probably come up with a lot of rules as well. So those are basically, we would like to integrate into the open source project itself. Anyway, very quickly the structure look very similar to, if you're familiar with the Linux Foundation's structure, so this is a typical one. And the only thing I want to point out to is that we create or trying to create one government advisory council. So we have a governing board I'm a member of taking advisory council where Tracy is our chair and we also trying to start a advisory council for governments and government organizations and representatives that can help us sort of advises on regulations as well as, you know, a lot of the rules depend on the type of things we keep in wallets, right? So money like things often comes with a very strong regulation and et cetera. So those will be the, I think our ingredient, we was trying to see this foundation to succeed. I'll talk about a little bit of the role of wallet. So this will be the end of my introduction piece. So the role of wallet, I think of it as a very key component in the overall trust framework. We talk quite a bit about in the keynote, right, a lot about security. But this is something that we haven't quite mentioned, which is like the basic orientation of what security means. Typically, when we talk about security, we talk about protecting a infrastructure. We talk about protecting servers and platforms et cetera. And it is often, you know, like I think not recognize widely enough that we also need to think about each of us as a infrastructure. So we need to have a way to protect our own information. That can be your privacy, data, and whatever you own in the internet. And so I want to basically highlight two things. One is to hold things.  And two is use those things to exercise control. So give user some way of control. And this is quite important. I think it's a, the wallet is also the most direct personal interface. All the, you know, protocols and algorithms you talk about, the end user will not directly feel it. But the wallet, they will. They will be, you know, touching it and using it and, you know, interact with it every day. So it is very important that we do it well with a goal to enable user agency and then to, you know, remove the burden of choice and complexity. So we need to make that very convenient, intuitive for the user. And that's the, I hope that will highlight, I think, in my view, what the roles of wallets should be. I won't spend much time other than to point out that so this is a European Union Digital Identity, EUDI's architecture diagram. And in this big complicated diagram, the pink ones are regulators, the yellow cars are players or parties. And what is that single purple thing? That's the wallet. And so I just want to see if you look at the wallet, it's really in the center of a lot of things. So now I'm going to shift to, in the remaining time, I want to shift to metaverse. And so I, when we were talking about the, you know, starting a open wallet foundation in Dublin, I also met Roy and others, Royo and others who was trying to start open metaverse. And so I got involved into some of the understanding of what metaverse need to be. And, you know, learning some of these, so like very challenges for metaverse. I would just want to say it doesn't exist yet. So we're talking about future challenges. I think it's very interesting because if you look at these top seven lists, this one's from a company called Lucid Reality Labs. It's about reputation, identity, data and security, currency payment, law jurisdiction, ownership, property, community network, time and space. So maybe I can link time and space, but almost everything is related to, I think, the concept of wallet identity and, you know, privacy. And those are the really in people's mind when they think about metaverse. The second one, this is a research effort right now in mostly in UC Berkeley. And so we had an opportunity to talk to Vivek Neer, who's the lead researcher there about metaverse and privacy. And so this is their second paper coming out of that effort, which basically used a relatively rudimentary and simple learning algorithm to uniquely identify 50,000 individuals. So it's very large enough that you can generalize, say basically anybody can be very uniquely identified by the motion alone.  The way you play the game, how you move your arms around all of that by basic information of collecting that within the gameplay's context. So you can say, okay, this particular scene, people are playing, you know, slashing this box in certain way, right? And with about a few hundred vectors or parameters, which is relatively small. If you remember, in like a char GBT, it's 80,000, 100,000 degrees of dimensions there. But this is a few hundred of them would very uniquely identify each individual more than 90, 95% of time. So this clear implication that metaverse has huge privacy problem. And how do we solve that problem? We don't have answer yet. So the next few slide, what I would like to do is basically look at like wide open wallet or wallet kind of thing in general is critical to the metaverse. And so I was now with identity and avatar. And so in the case of avatar, right? It's a digital object, 3D object, let's say, that I have some control over, but not 100%, because some of the avatar has to be automated. And it's going to show quite a lot of things. It's a huge surface or attack factor, you can think of it, that's going to show a lot of things. We really don't know how to deal with that kind of thing today. We don't have a way to really, to build something that representing our identity, not purely as a key or a randomized string or something like that, but really has a very complex object, has a lot of display and it's meant to be public. Well, that's what identity is for. Why you need identity? Because you want that identity to mean something and therefore it must be public in some way. And so between control both of them and you have full control of that, it's critically important. So I would say to build identity and avatar, you need the baseline core capabilities which I think will show up in the wallet. So that control you have is the basis that you can build an identity and avatar for metaphors. The second in that space is authentic content. Authentic goes both ways. One is it's not fake, right? So where it's from. So provenance and authenticity is extremely important and these objects can be also very valuable. They are expensive to build. So you may want to make sure that it cannot be easily cloned, et cetera. So all of that require authenticity as well as provenance. And how do you keep the authenticity and provenance along the entire metaverse or digital object development cycle, right? So we were talking about supply chain for software code and this is exactly the same problem except I think it's much more complicated because now you have all these 3D objects need to all work together. And so this is another area that complicated developer focused process is not gonna work. We need a way that enable all human and creative developers, et cetera to be able to conveniently use that day-to-day in your life. That's the kind of a scale we need to have. And I think that will also somehow start from the wallet. We talk about digital assets. So a lot of people think like a metaverse requires some kind of monetization or you can think of another business model, a model that is not ad. It's not purely subscription, I guess. Something new hasn't happened yet. And I think to enable that kind of business model will need a wallet. Transactions, I'll probably skip this one, it's very clear. If today we do e-commerce, but e-commerce is still quite complicated. It's based on a long chain of events that its security and privacy are very fragile, at least I would say, right? So how do we make those things much more mature and intuitive and easy to use so that we don't constantly fear there's a fraud, there is a hack going on. I think that is critical. And as if we step further into the metaverse, you're even more exposed, I think we need something like a wallet. Privacy, I think this one probably will be the key. This is maybe the general problem, representing all of the above essentially. What is a privacy?  And that's being essentially in the digital world, this becomes enlarged, it becomes very, I think it becomes very accentuated into one or few spots, which is, I think, dangerous. So we need a way so that to spread the systems out and have our own control over it rather than rely on one single solution alone, right? I think it's need both ways. But it's a key that we hold some part that we have a say whether we can have a unilaterally make a decision about privacy. And finally, I want to mention the world of AI and all the agents. So in a complicated system in the universe, I don't believe we can have men or women and humans fully in control of how the system work. A lot of things will have to be automated, including our own avatar. The avatar you purely manipulate by your own hand and play is one thing, but as a representation or identity piece, it will need to be somehow automated so that it can, for example, act on your behalf in some limited fashion. And that is very critical. And it's also bringing the immense challenge, I think, in sort of authenticity in this world. We know it's all made up world, but which one are genuinely true? Which are not? What context we are walking into? What kind of room it is? All of that require, all of us have a way to speak. We need agency in that world. And how do you get that agency? You need to, if you remember, Corey is a specialist this morning. You need to control a piece of computing resource. It has to be yours. So I hope I can convince you that it's also, I think, starting with something the concept of a wallet. Okay, so I'll just leave this quickly on the board. The new opportunities from consumer side, from creator side, developers, businesses, where these things work. And the way I would like to convince everyone is that there's a very critical piece of software we need to do well, as well as have some ownership or have some say how it is developed. And I hope I can convince you that it's an open wallet foundation. So my purpose will be to make this a bridge to the Metaverse community. And hopefully you can join us to make this a reality and possible. It's a very young and new project, a very exciting time. So everybody's welcome. And I think this piece is very important. We cannot rely on any single company in a single organization. We do want to see this develop in the open. So we know what's in there, how it works. And I was chatting with John earlier, right before this session, that I think the key thing is that we need to focus more and more on the individual, the consumer, the person who really, not only using the wallet, but it is designed for them. I think that's very critical. So we welcome all the participation in the open wallet foundation. I will leave a few links and how to get involved. There is a very good report. It was produced at the same time in February, why the world needs an open source wallet right now. And also there's a Discord channel and the GitHub for getting involved. Our GitHub is, all Discord are all very new. So that's how we're just showing up with two project proposals right now. Both are focused on selective disclosure, JWT, and the idea of selective disclosure, I just want to use that as an example, as a very critical, it means that when we are issued or when we have a piece of information like a driver license, when we use that particular object, right, we want to control what is disclosed to a particular party. So if I go to a bar and they want to check my, or used to check my age, I want to be able to give them only that piece of information, not anything more. And that's a very general capability because basically any kind of a wallet, sorry, a web token, once it's based on this, you will have that capability. So that you can apply that to every type of user that we have. And that's just one quick example of why these issues and the software that I make it possible is very important. So that will be the end of my talk and I hope I have a little bit of time. Yeah, so thank you. So we have at least 10 minutes, if I correct? Yeah, any questions, any comments? Yeah, yeah. I should have put this one here. I don't know, Trace, do you remember, like total will be probably close to 50, I would say, members? Right, right, right. Yeah, so the general category of members, so we basically ask the larger organization to donate some fund to run the, but otherwise it's a wide open, anybody can participate. The audio software open source and we have a lot of organizations involved. Some of them, they've been driving the Europeans Digital Identity Initiative, so that's a large group of them. For people who may not be quite familiar, the EU Commission are driving through registration and other means driving a EU-wide digital ID, the sort of like all the countries in the EU can issue the ID, the ID would be recognized European-wide anywhere. So that's a big initiative, a lot of people who have been writing open source code already, we hope to attract them as the Open Water Foundation will become home kind of way for those projects. There's also many group of organizations and open source projects who in the last at least 10 maybe even longer have been working on these issues for a long, long time. And so I will remember at least, you know, trust of IP, I've been very actively involved, Digital Decentralized Identity Foundation, OpenID, OIX in UK, ID2020, for example, and there are numerous ones, and many of them are actually here, so in the audience as well, I wouldn't remember all of them, but there are a lot of these organizations who have come from different backgrounds, some sort of from blockchain side, some from decentralization, web3, some from payment, and want to see the payment ecosystem more open, some from European Union, like from government driving initiatives, I know John is really instrumental in British Columbia, driving the digital ID by the BC Guard, for example, and then many of them, there's also environmental effort trying to use, you know, this to control or manage supply chain for green initiatives, for instance, and John talked a lot about a BC mining initiative program, we've seen a lot of demos using very similar kind of technology, so we are building on top of that foundation, and what we are doing is trying to put all those together in the home, in the neutral home that we could make them, you know, the software be interoperable in some way, general purpose, and scale up potentially, right, so those will be the, I think, the mission or the challenges we want to face. Any other questions? Metaverse? Yeah, I went to a royal, organized a workshop a few months ago in Austin, and we went there, it's really, in the Metaverse workshop, essentially two tracks, and one big track is your identity, privacy, and so I hope, you know, we are thinking up why these are very important. There are actually a lot of open source and open source wallets even out of today, so if you go search open source wallet, a lot of will come up. Most of them I would assume are blockchain based, so basically they are building a wallet for a particular type of, you know, a coin or blockchain they're building, right. What I think is missing is how do we build a wallet that's like we are saying, general purpose, and that is really targeting any individual consumer, and it's for any purposes, not just a particular coin, so general purpose, open source, and you know, good quality for that. So that is an unsolved problem, so today I don't think there is this kind of wallet that will allow you to do all those types, and so there's a lot of, for technical-oriented talents, I think there's a lot of unsolved challenge. This is again, I come back to the browser and web engine analogy. This is a unsolved problem because the web browser today, the security framework there is that the browser is a little attachment. So to empower the browser or the endpoint is a hugely interesting technical challenge. So I think to me that shows the power of these wallet and shows how a completely new type of applications and new potentially type of business models can be developed with this change. So I think it's a very interesting and exciting time. Yes, right, value alignment, like I didn't have a lot of time to dive into, but value alignment is the critical piece, right. How do we realign the overall orientation of these ecosystems? So the user have more say in that while still not sacrificing scalability and also the business model that enables. So I think that that is the critical, the hardest challenge. So we are very beginning. So there's no ready solution quite yet. There's nothing even to download today. But we hope to solve that soon. There's a lot of quite, we didn't start from scratch, you put that way, right. So there's a lot of existing software already developed in different contexts. And we're just in the beginning of the process of attracting those projects, moving to OpenWallet Foundation and then integrate them and potentially creating a new type of infrastructure. So we are thinking about, for instance, how web and native-based application developer today is complicated as space there. So this could potentially provide an opportunity for us to really think how that software framework would look like. So that's another, I think, very interesting development. It will be an echo of a lot of people promoting Web3. And so I imagine that in the future there will be a lot of applications. They wouldn't call it OpenWallet applications, but they will have a wallet embedded in there somewhere. And that could be the crucial thing for that application. Exactly. And agency is not something I think we can simply say, oh, I give you a choice. Well, a lot of choice, like I was trying to remember when I first landed here in the drugstore as a graduate student who didn't know much English. I would have said, I thought I knew, but I didn't. When I walk into drugstore, I had my brain just go, oh, because I just look at every word and these drug names are just incredibly hard for me. And I couldn't do anything. I don't have agency. I have a lot of choices, but I can't. And that's a hard problem to solve. And if we can solve that, I think it will make a lot of the issues we're talking about hopefully better.