Data Types - Part 4 | C Language Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome to nourish technologies this is fin woz so in the last session so we discussed about a character data type now in this session we will see some of the examples on a character data type so first we will see write we are writing unsigned character and signed character in the form of circles right so here it is suppose if it is a signed character the limits are minus 128 to Plus 127 all these limits we are writing in a form of circle because based on these circles only now we will see how programs will execute here it is so we are writing so this is circle either positive value or negative value counting starts with 0 this is a starting point positive value is counting in a clockwise direction positive value is counting and here it is the maximum value is 127 is 127 negative values counting starts to the minus 1 minus 2 minus 3 and so on up to minus 128 this is assigned character this is signed character first we will see the examples on a signed character so same story in the Declaration of variable if you are not specifying whether the variable is assigned variable or unsigned variable by default it is assigned variable and next one this unsigned circle also we are writing just 0 to 255 and this is the circle and starts with 0 1 2 and so on and so on up to 255 255 so this is unsigned character circular unsigned character circle so based on these two based on so these two circles so now so we are discussing all the programs these two so one is the sign circle and second one is a and sign circle a simple program I will write a simple program for example here it is here it is we are including the header file hash include stdio.h if you want to clear the screen we can include so that see when I would odd hitch also but of course not required anyway we discussed and here it is directly I am writing main function I am declaring one character care variable name any name you can give for example here it is a character name CH I am giving character name CH and what is the value any value you can give suppose I am giving capital a but remember one thing in any programming language we are representing characters by using single quotes by using single quotes right here it is we are printing the value printf printf so how to print this character right here it is percentage C is a format specifier and we are printing the value CH we are printing the value CH here it is CH value will print in the location of percentage see sir suppose whenever we are printing that CH value printf I am NOT giving percentage see I am giving percentage D but the variable is a CH only but the variable is CH only here it will print it has to print in teaser so what integer it will printer CH contains a variable so what is the variable capital a right it brings what capital a so that capital a corresponding ASCII value it will print so capital a value corresponding ASCII value is a 65 so it will print the value 65 okay so this is a simple program so on a character data type first we are declaring one character we are printing character by giving percentage see and we are printing the ASCII value by giving percentage D so percentage D means what it is an integer format specifier so it has to print in teaser sir--what integer it will print already we discussed in a character system every character is represented by a constant integer value so this is the constant integer value 65 so it will print the value 65 okay so we'll see the next program so some trick equations here it is they will ask like this for example character CH character CH so they are storing for example 258 258 they will stores or can be store yes of course we can into character data type we can store integers also sir then what character will go on store right here it is assigned character or unsigned character means by default it is assigned character by defer is assigned character so it will count the value 258 first CH gets memory allocation CH gets memory allocation and it has to store the value 258 it will count 258 in assigned circle see this is signed circle this is signed circle and here the range is minus 128 to 127 so counting 258 starts here 0 1 2 3 4 and so on like that it will keep on counting this value is equals to 255 in the short data type we discussed very clearly just compare these two circles so that is why I have written here write a 0 above value is a 255 so 255 256 257 to 58 so 258 corresponding value is a 2 so in the memory the value 2 will go and store in the memory the value 2 will go on store so here it is whenever we are printing printf printf and here it is a percent is d we are printing ch value and here it is a printf printf % is see we are printing the CH value sir whenever we are giving percentage D it is happy we can say that easily it will print the value 2 it will print the value 2 sir whenever we are printing that percentage see what character it will print sir that we do not know right so here it is no need to buy hurt that entire ASCII code right what value it will print means some unexpected value some garbage character it will print an unknown character it will print that is what 2 corresponding unknown character it will print two corresponding ASCII character what it is that will print from the ASCII character system okay so this is a bit freak equation right they will ask in the interview on a character data type okay and now so we will see how to write a program that if you input one character it has to print that corresponding s Q value in this program first time we are working with a scanner function first time we are we are reading information from the end user in C programming language okay see here the program is write a program to display ASCII value to display ASCII value of character to display ASCII value of character so this is a heading of the program so first time we are reading right information from the end user we are taking input from the end user right how we are taking input see here it is hash include hash include stdio.h header file we included a next one we are writing main method directly and here it is I am declaring one variable variable character variable name any name you can take just like the previous program I am taking CH only now CH gets memory allocation these do not assign any value directly please do not assign any value directly because here it is my requirement is I just want to read information from the end user I want to read the input from the end user while application is executing that is my concept here it is CH gets memory allocation at some location now address is very very important this is address memory location address so we're right CH gets memory allocation so now here it is this is the console on console first I want to print a message so what is the console where you can see the output and where we can give the input so that is called a console black screen right here it is so we are asking clearly enter one character enter one character that message I want to print message is very very important right if you do not print this message and whenever you show that console output to the end user what end user want to do that they cannot understand okay so that is a reason we need to provide some information best example ATM application whenever you enter into ATM Center a clear information it will show please choose one language insert your ATM card insert your PIN number insert how much amount you want to withdraw please collect the cash please collect the card information is very very important how good you are writing the logic is not at all matters right how clearly you are providing interface to the end user is very very important as a developer remember so here so first we are asking the message very clearly enter one character printf the same message we are writing here enter one character enter one character so whatever the message you have written in the printf function so that will be written on the console or not yes so that will write on the console on the console it will print that message enter one character so that we have to read right so first time so whenever they will enter one character for example I entered that character hash I entered that character has any character you can pass right so then automatically system will print that as key value see that hash we should collect into this location into this location so here we need to provide the memory address we need to provide memory address how to provide memory address who will provide memory address so first time we are using scanf function in a c programming how many characters you want to read sir i want to read only one character so write one time percentage c format specifier sir i want to read a ten characters ten times you have to write a percentage c but here it is only one character so that we are collecting the character address you have to provide ampersand is the address operator what it will return the address of or the memory location of this character it will return the memory address of this character it will return okay so here it is 2 0 4 6 it will return so hash whatever the character you have given in the console that will be stored in to this location so hash will go on store and of course not exactly hash hash corresponding ASCII value will be converted into binary and then the binary value will go on store and now I want to print printf ASCII value is ASCII value is I am writing in the next line ask you value is percentage D and here it is what we are printing CH we are printing this is clear we are reading using scanner function surveyor scanner function is available in stdio.h header file only the standard input/output dot H header file only that scanner function is available and we are reading into a location CH in the CH hash is their hash is their I want to print the ASCII value very simple how to print the ASCII value instead of writing percentage see you please write a percentage D is enough so here it is percentage D we are writing C hich corresponding value it will write the sir what is it ask you value 35 35 it will write write whenever you start executing your program right on the console it will ask the message very clearly please enter one character any character you can enter plus - dollar hash any character you can enter when you press ENTER then automatically it will show right so what is the ASCII value of that character okay all these programs practically once again I will explain right here it is using the blue-screen ide okay so this is how to print the ASCII value of the given ASCII character right sir can I print all the ASCII character symbols at a time impossible because printer function you have to write 256 times so because how many number of ASCII values are there 256 ASCII values are there can you write a printer function 256 times in a single program impossible case so that is why so please wait up to control statements concept some loops we'll discuss in the coming concepts so there I will show you very clearly how to print the ASCII character set in a C language okay right so thank you for watching so thank you all for more videos please subscribe to nourish ID thank you
Info
Channel: Naresh i Technologies
Views: 417,956
Rating: 4.9369812 out of 5
Keywords: C Language, Srinivas, Data Types in C, Naresh IT, Hands on C Language Training, C Language Demo, Online C Language Training, C Language Tutorial Videos, C Language Overview, C Language Interview Questions
Id: OkD5xX-aW9o
Channel Id: undefined
Length: 15min 18sec (918 seconds)
Published: Wed Sep 07 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.