Literals in C Programming

Posted by Tushar Bedekar
The term literal constant or literal refers to a value that occurs in a program and cannot be changed. The C language uses the term constant in place of the noun literal. The adjective literal adds to the concept of a constant the notion that we can speak of it only in terms of its value. A literal constant is nonaddressable, which means that its value is stored somewhere in memory, but we have no means of accessing that address.

Every literal has a value and a data type. The value of any literal does not change while the program runs and must be in the range of representable values for its type. The following are the available types of literals:


Types:-


  • Boolean
  • Integer
  • Character
  • Floating-point
  • String
  • C Compound literal
  • Vector literal
According to Wikipedia  a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values such as integers,floating-point numbers, and strings, and usually for booleans and characters; some also have notations for elements of enumerated types and compound values such as arrays,records, and objects. An anonymous function is a literal for the function type.

In contrast to literals, variables or constants are symbols that can take on one of a class of fixed values, the constant being constrained not to change. Literals are often used to initialize variables, for example, in the following, 1 is an integer literal and the three letter string in "cat" is a string literal:
Read More

How to open webpage in chrome browser offline

Posted by Tushar Bedekar

Many Times in the absence of the internet connectivity we are require to access the certain webpages that we have previously accessed when we have internet connectivity.For example during connectivity we a have opened Facebook,Gmail and Wikipedia etc. similarly when we are suppose to be inside the airplane there is no connectivity due to which we can`t access internet and In such situations if we open our chrome history an click on the previously sites than we see a page showing a dynasore saying that your computer is not connected to internet.


At the same time there is also no setting in the chrome browser by using which you are able to use chrome in the offline mode so by using the trick Given below you can use your browser in the offline mode.


Offline reading in chrome(Trick):-

  • first of all open chrome browser.
  • In the address bar write chrome://flags/#enable-offline-mode
  • then press enter.
  • now you will see an auto reload option in the window open in your browser.
  • which is set in the default mode.
  • revert that option to enable mode.
  • then restart your chrome browser.
Then after restarting your chrome browser move to history by pressing ctrl+H 
select the site that you want to see offline and enjoy.







Warning 

  • We are not responsible for any damages that may happened by using this Techniques. 
  • Use this guide at your own risk. We shall not have any liability or responsibility for whatever happens to you and your device by using the instructions in this guide.
  • The instructions provided in this tutorial for educational purpose only. There is no guarantee that these steps will work for your device.
  •  Applying this guide to any other device or any other model may produce many problems.
  • Read and Understand the whole tutorial first, before going to perform the steps.
  • At the same time this content is not to harm any one but it is only for educational purpose.
Read More

Constants, Variables and Keywords in C

Posted by Tushar Bedekar

Constants:-

A constant is an entity whose value does not change throughout the program execution.

There are rules to be followed in order to create a constant. Let us discuss the rules to create constants.







Rules for constructing Integer constant

1) An integer constant must have at least one digit.
2) It must not have a decimal point.
3) It can either be positive or negative.
4) No commas or blanks are allowed within an integer constant.

5) If no sign precedes an integer constant, it is assumed to be positive.
6) The allowable range for integer constants is -32768 to 32767


 Actually, the range of the integer constant depends on the compiler. The above mentioned range is for 16-bit compiler. However, for a 32-bit compiler the range would be even greater.

The integer constants
• Whole Numbers
• E.g. 50, 45, -35, -26
• Computer allocates only 2 bytes in memory.
• 16th bit is sign bit. (if 0 then positive value, if 1 then negative value)

Decimal Integer constant:
• 0 to 9
• E.g.: 49, 58, -62 … (40000 cannot come because it is > 32767)

Octal Integer constant:
• 0 to 7
• Add “0” before the value.
• E.g.: 045, 056, 067

Hexadecimal Integer constant:
• 0 to 9 and A to F
• Add 0x before the value
• E.g.: 0×42, 0×56, 0×67


Rules for constructing Real constants


Rules for constructing Real constants (Fractional Form)
1) A real constant must have at least one digit
2) It must have a decimal point
3) It could be either positive or negative
4) If no sign precedes an integer constant, it is assumed to be positive.
5) No commas or blanks are allowed within a real constant.

E.g.: +867.9, -26.9876, 654.0


Rules for constructing Real constants (Exponential Form)

1) The mantissa part and the exponential part should be separated by the letter ‘e’
2) The mantissa may have a positive or negative sign(default sign is positive)
3) The exponent must have at least one digit
4) The exponent must be a positive or negative integer(default sign is positive)
5) The range of real constants in exponential form is -3.4e38 and +3.4e38

E.g.: +3.2e-4, 4.1e8, -0.2e+4, -3.2e-4


Rules for constructing Character constant

1) A character constant is an alphabet, a single digit or a single special symbol enclosed within inverted commas. Both the inverted commas should point to the left. For example, ’S’ is a valid character constant whereas ‘S’ is not.
2) The maximum length of a character constant can be 1 character. Allots 1 byte of memory


Variable:-

A variable is an entity whose value keeps on changing throughout the program execution. However, it’s not a rule that the value of the variable will change. A variable value might remain same throughout the program execution. However the main difference between variable and constant is that we can’t change the value of constant in between the program, but we can change the value of the variable during program execution.


Rules for constructing variable names

A Variable name consists of any combination of alphabets, digits and underscores. Some compiler allows variable names whole length could be up to 247 characters. Still it would be safer to stick to the rule of 31 characters. Please avoid creating long variable name as it adds to your typing effort
The first character of the variable name must either be alphabet or underscore. It should not start with the digit
No commas and blanks are allowed in the variable name
No special symbols other than underscore are allowed in the variable name
We need to declare the type of the variable name before making use of that name in the program. Type declaration can be done as follows:

To declare a variable as integer, follow the below syntax:


int variable_name;
Here int is the type of the variable named variable_name. ‘int’ denotes integer type.

Following are the examples of type declaration statements:




E.g.:

int p, n;
float r;

keyword:-

Keywords are the words whose meaning has already been explained to the C compiler. The keyword cannot be used as the variable name. If we try to do so we are trying to assign new meaning to the keyword. The keywords are also known as ‘Reserved words’.

E.g.: for, if, static, while, do, break etc.

Let us take an example:-
We define a variable named x in a program. Let us say x=9.
After some time during execution we change the value of x to 10. Now, x=10.
Here value of x is getting changed. But the value of 9 and 10 will never change. Hence, x is called a variable and 9 is called a constant.

Read More

What really happens when you navigate to a URL

Posted by Tushar Bedekar 3 Comments

1. You enter a URL into the browser 




 2. The browser looks up the IP address for the domain name 


Now the question comes in your mind What is DNS??????????
Answer is->Full Form of DNS is Domain Name System.The DNS translates Internet domain and host names to IP addresses. DNS automatically converts the names we type in our Web browser address bar to the IP addresses of Web servers hosting those sites.

The DNS lookup proceeds as follows:
  • Browser cache – The browser caches DNS records for some time. Interestingly, the OS does not tell the browser the time-to-live for each DNS record, and so the browser caches them for a fixed duration (varies between browsers, 2 – 30 minutes).
  • OS cache – If the browser cache does not contain the desired record, the browser makes a system call (gethostbyname in Windows). The OS has its own cache.
  • Router cache – The request continues on to your router, which typically has its own DNS cache.
  • ISP DNS cache – The next place checked is the cache ISP’s DNS server. With a cache, naturally.
  • Recursive search – Your ISP’s DNS server begins a recursive search, from the root nameserver, through the .com top-level nameserver, to Facebook’s nameserver. Normally, the DNS server will have names of the .com nameservers in cache, and so a hit to the root nameserver will not be necessary.

3. The browser sends a HTTP request to the web server



You can be pretty sure that Facebook’s homepage will not be served from the browser cache because dynamic pages expire either very quickly or immediately (expiry date set to past). So, the browser will send this request to the Facebook server: GET http://facebook.com/ HTTP/1.1 Accept: application/x-ms-application, image/jpeg, application/xaml+xml, [...] User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; [...] Accept-Encoding: gzip, deflate Connection: Keep-Alive Host: facebook.com Cookie: datr=1265876274-[...]; locale=en_US; lsd=WW[...]; c_user=2101[...] The GET request names the URL to fetch: “http://facebook.com/”. The browser identifies itself (User-Agentheader), and states what types of responses it will accept (Accept and Accept-Encoding headers). TheConnection header asks the server to keep the TCP connection open for further requests. The request also contains the cookies that the browser has for this domain. And so the cookies store the name of the logged-in user, a secret number that was assigned to the user by the server, some of user’s settings, etc. The cookies will be stored in a text file on the client, and sent to the server with every request.

 4. The facebook server responds with a permanent redirect 



This is the response that the Facebook server sent back to the browser request: imageHTTP/1.1 301 Moved Permanently Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Sat, 01 Jan 2000 00:00:00 GMT Location: http://www.facebook.com/ P3P: CP="DSP LAW" Pragma: no-cache Set-Cookie: made_write_conn=deleted; expires=Thu, 12-Feb-2009 05:09:50 GMT; path=/; domain=.facebook.com; httponly Content-Type: text/html; charset=utf-8 X-Cnection: close Date: Fri, 12 Feb 2010 05:09:51 GMT Content-Length: 0 The server responded with a 301 Moved Permanently response to tell the browser to go to “http://www.facebook.com/” instead of “http://facebook.com/”. 

 5. The browser follows the redirect 


The browser now knows that “http://www.facebook.com/” is the correct URL to go to, and so it sends out another GET request: GET http://www.facebook.com/ HTTP/1.1 Accept: application/x-ms-application, image/jpeg, application/xaml+xml, [...] Accept-Language: en-US User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; [...] Accept-Encoding: gzip, deflate Connection: Keep-Alive Cookie: lsd=XW[...]; c_user=21[...]; x-referer=[...] Host: www.facebook.com The meaning of the headers is the same as for the first request.


 6. The server ‘handles’ the request 


 The server will receive the GET request, process it, and send back a response. imageThis may seem like a straightforward task, but in fact there is a lot of interesting stuff that happens here – even on a simple site like my blog, let alone on a massively scalable site like facebook. Web server softwareThe web server software (e.g., IIS or Apache) receives the HTTP request and decides which request handler should be executed to handle this request. A request handler is a program (in ASP.NET, PHP, Ruby, …) that reads the request and generates the HTML for the response. Request handlerThe request handler reads the request, its parameters, and cookies. It will read and possibly update some data stored on the server. Then, the request handler will generate a HTML response. 

 7. The server sends back a HTML response 


 Here is the response that the server generated and sent back: HTTP/1.1 200 OK Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Expires: Sat, 01 Jan 2000 00:00:00 GMT P3P: CP="DSP LAW" Pragma: no-cache Content-Encoding: gzip Content-Type: text/html; charset=utf-8 X-Cnection: close Transfer-Encoding: chunked Date: Fri, 12 Feb 2010 09:05:55 GMT The entire response is 36 kB, the bulk of them in the byte blob at the end that I trimmed. The Content-Encoding header tells the browser that the response body is compressed using the gzip algorithm. After decompressing the blob, you’ll see the HTML you’d expect: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook" class=" no_js"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-language" content="en" /> ... In addition to compression, headers specify whether and how to cache the page, any cookies to set (none in this response), privacy information, etc. 

 8. The browser begins rendering the HTML 


 Even before the browser has received the entire HTML document, it begins rendering the website: 

 9. The browser sends requests for objects embedded in HTML 



 As the browser renders the HTML, it will notice tags that require fetching of other URLs. The browser will send a GET request to retrieve each of these files. Here are a few URLs that my visit to facebook.com retrieved: Imageshttp://static.ak.fbcdn.net/rsrc.php/z12E0/hash/8q2anwu7.gif http://static.ak.fbcdn.net/rsrc.php/zBS5C/hash/7hwy7at6.gif … CSS style sheetshttp://static.ak.fbcdn.net/rsrc.php/z448Z/hash/2plh8s4n.css http://static.ak.fbcdn.net/rsrc.php/zANE1/hash/cvtutcee.css … JavaScript files http://static.ak.fbcdn.net/rsrc.php/zEMOA/hash/c8yzb6ub.js http://static.ak.fbcdn.net/rsrc.php/z6R9L/hash/cq2lgbs8.js 

 10. The browser sends further asynchronous (AJAX) requests 


 In the spirit of Web 2.0, the client continues to communicate with the server even after the page is rendered. For example, Facebook chat will continue to update the list of your logged in friends as they come and go. To update the list of your logged-in friends, the JavaScript executing in your browser has to send an asynchronous request to the server. The asynchronous request is a programmatically constructed GET or POST request that goes to a special URL. In the Facebook example, the client sends a POST request to http://www.facebook.com/ajax/chat/buddy_list.php to fetch the list of your friends who are online. This pattern is sometimes referred to as “AJAX”, which stands for “Asynchronous JavaScript And XML”, even though there is no particular reason why the server has to format the response as XML. For example, Facebook returns snippets of JavaScript code in response to asynchronous requests. 
Read More

Introduction to C Programming Language

Posted by Tushar Bedekar
C is a programming language developed by AT & T’s Bell Laboratories of USA in 1972. It was designed and written by a man named Dennis Richie. C is reliable, simple and easy to use.
One can easily learn C++ , JAVA or any other programming language if one has a knowledge of C.

Basic features:-

  • It is 16 bit programming language. 
  • Many of the popular and robust languages available today requires a basic knowledge of "c Programming". 
  • Many major components of popular operating systems like Windows, UNIX, LINUX is still written in C.
  • We all are now familiar with the smart phones, this smartness comes from a microprocessor,operating system and program mes embedded within that smart phones.Generally all these program-mes are written basically in "c Programming " languages.
  • Because of the fast execution f the c program-mes.
  • many popular gaming frame works(such as Direct X) have been built using c programming language.
  • It is simply and easy for the Beginners who are learning to do computer programming

C- Character Set:-


Similar to the other programming languages the C languages also include character set which includes alphabets, numbers an special symbols. following are the some character that we use in "C Programming" languages.
  • Alphabets :- A to B (ASCII value from 65 to 90)       a to b(ASCII value from 97 to 122)  
  • Digits:- 0 to 9(ASCII value from 48 to 57) 
  • Special Characters:- #,*,7,%,4 and 2 etc.(ASCII values as per the character) 
These ASCII values can be found by the help of a "C program me" for program me please click the link given below. Coming soon

Read More

Source Code Vs Object Code

Posted by Tushar Bedekar

Source Code:-

http://www.allaboutcomputing.net/In computing, source code is any collection of       computer instructions (possibly with comments) written using some human-readable computer    language, usually as text. The source code of a program is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source code. The source code is often transformed by a compiler program into low-level machine code understood by the computer. The machine code might then be stored for execution at a later time. Alternatively, an interpreter can be used to analyze and perform the outcomes of the source code program directly on the fly.

Most computer applications are distributed in a form that includes executable files, but not their source code. If the source code were included, it would be useful to a user, programmer, or system administrator, who may wish to modify the program or understand how it works.


Aside from its machine-readable forms, source code also appears in books and other media; often in the form of small code snippets, but occasionally complete code bases; a well-known case is the source code of PGP.



Object Code:-


Object code, or sometimes an object module, is what a computer compiler produces. In a general sense object code is a sequence of statements or instructions in a computer language, usually a machine code language (i.e., 1's and 0's)[citation needed] or an intermediate language such as RTL.



Object files can in turn be linked to form an executable file or library file. In order to be used, object code must either be placed in an executable file, a library file, or an object file.

Object code is a portion of machine code that hasn't yet been linked into a complete program. It's the machine code for one particular library or module that will make up the completed product. It may also contain placeholders or offsets not found in the machine code of a completed program that the linker will use to connect everything together. Machine code is binary (1's and 0's)[citation needed] code that can be executed directly by the cpu. If you were to open a "machine code" file in a text editor you would see garbage, including unprintable characters. Object code is a variant of machine code, with a difference that the jumps are sort of parameterized such that a linker can fill them in. An assembler is used to convert assembly code into machine code (object code). A linker links several object (and library) files to generate an executable.


Source:-Wikipedia

Read More

Byte Code Vs Machine Code

Posted by Tushar Bedekar
Generally, "machine code" refers to the data that can be executed by a certain computer, while "byte code" refers to data that can be executed by a virtual machine. The virtual machine takes the byte code and produces machine code appropriate for the actual machine it is running on.



Machine Code:-

Machine code or machine language is a set of instructions executed directly by a computer's central processing unit (CPU). Each instruction performs a very specific task, such as a load, a jump, or an ALU operation on a unit of data in a CPU register or memory. Every program directly executed by a CPU is made up of a series of such instructions.


Numerical machine code  may be regarded as the lowest-level representation of a compiled and/or assembled computer program or as a primitive and hardware-dependent programming language. While it is possible to write programs directly in numerical machine code, it is tedious and error prone to manage individual bits and calculate numerical addresses and constants manually. It is therefore rarely done today, except for situations that require extreme optimization or debugging.


Almost all practical programs today are written in higher-level languages or assembly language, and translated to executable machine code by a compiler and/or assembler and linker. Programs in interpreted languages[1] are not translated into machine code however, although their interpreter (which may be seen as an executor or processor) typically consists of directly executable machine code (generated from assembly and/or high level language source code).

Byte Code:-

Byte code, also known as p-code (portable code), is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, byte codes are compact numeric codes, constants, and references (normally numeric addresses) which encode the result of parsing and semantic analysis of things like type, scope, and nesting depths of program objects. They therefore allow much better performance than direct interpretation of source code.

The name byte code stems from instruction sets which have one-byte op codes followed by optional parameters. Intermediate representations such as byte code may be output by programming language implementations to ease interpretation, or it may be used to reduce hardware and operating system dependence by allowing the same code to run on different platforms. Byte code may often be either directly executed on a virtual machine (i.e. interpreter), or it may be further compiled into machine code for better performance
.

Since byte code instructions are processed by software, they may be arbitrarily complex, but are nonetheless often akin to traditional hardware instructions; virtual stack machines are the most common, but virtual register machines have also been built.Different parts may often be stored in separate files, similar to object modules, but dynamically loaded during execution.


Source:-Wikipedia 
Read More

File Input/output In "C" Programming

Posted by Tushar Bedekar

The Standard I/O Library provides similar routines for file I/O to those used  for standard I/O.

The routine getc(fp) is similar to getchar()
and putc(c,fp) is similar to putchar(c).

Thus the statement

            c = getc(fp);

reads the next character from the file referenced by fp and the statement

            putc(c,fp);

writes the character c into file referenced by fp.

       Basic Program me:-

/* file.c: Display contents of a file on screen */

#include <stdio.h>

void main()
{
            FILE *fopen(), *fp;
            int c ;

            fp = fopen( “prog.c”, “r” );
            c = getc( fp ) ;                        
            while (  c != EOF )
            {
                        putchar( c );              
                        c = getc ( fp );              
            }

            fclose( fp );
}

         Description:-

In this program, we open the file prog.c for reading.

We then read a character from the file. This file must exist for this program to work.

If the file is empty, we are at the end, so getc returns EOF a special value to indicate that the end of file has been reached. (Normally -1 is used for EOF)

The while loop simply keeps reading characters from the file and displaying them, until the end of the file is reached.

The function fclose is used to close the file i.e. indicate that we are finished processing this file.

We could reuse the file pointer fp by opening another file.



This program is in effect a special purpose cat command. It displays file contents on the screen, but only for a file called prog.c.
Read More
back to top