Wednesday, July 10, 2019

Key words in C

Key words in C
Keywords :

keywords are specific reserved words in C each of which has a specific feature associated with it. Almost all of the words which help us use the functionality of the C language are included in the list of keywords. So you can imagine that the list of keywords is not going to be a small one!

auto
double
int
struct
break
else
long
switch
case
enum
register
typedef
char
extern
return
union
const
float
short
unsigned
continue
for
signed
void
default
goto
sizeof
volatile
do
if
static
while

Monday, July 8, 2019

Escape Sequence


Escape  Sequence:

“\n” is a escape sequence. “\n” is an indication to the compiler that the cursor should be shifted to new Line.



Program

#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();
 printf("My");


 printf("\n\tName is");
 printf("\n\t\tUmesh Patidar");
getch();
}

Output


In the above example \n is use for change the line and \t is equals to a “tab” or equals to 8 spaces.
The above example code is use the escape sequence . So “My” is printed on new line, “Name is” printed on another line with a tab space or 8 spaces, and “Umesh Patidar” is printed on next line with 2 tab space or 8*2 spaces.

Phases of Execution of C Program


Phases of Execution of C Program:

Execution of C Program occurs in 4 phases.

  1.  Writing the code
  2. Compiling the program 
  3. Linking
  4. Execution

process of execution of c Program

Phases-of-Execution-of-C-Program



Writing the code:

It refers to the first step. In the code, we use various Constructs & loops. The main benefit is the ability to break down the code into various modules. This file has the extension of .c

 Compiling the program:

Once the program has been written, the code needs to be converted into the machine language ,i.e. the machine can understand. This conversion takes place with the help of a compiler.
But the Conversion takes place only after all the bugs from the source code have been removed. On compilation, the compiler reports all the errors from the source code, the source code is compiled and converted to machine code, So , the compiler converts C code to binary code i.e. object code.

Linking:

The compilation has already been done. The obj file has been genrated. But for execution of a program, the referred function of the library files must be made available to the source file. This is done with the help of linker. It is used to link the library files with the source code. After the linking, a file with the extension “.exe” is genrated. This is called the executable file.

Execution:

The final stage is executing a C program ie. To run the program. This is done by opening the DOS Command Prompt or by any other software.

This is all about the phases of execution of a C Program.

Thanks for reading......

Translators


Translators:
They have an important role to play in the execution of programs. We know that computer understands only machine language of 0s & 1s . But the coding of high level language use english commands. So we need someone to translate the code to the machine specific code,This is the task of a translator.

A computer program that translate a program written in any language into its equivalnt byte code or machine code is known as a translator. It can be categorized as:

  1.   Assembler
  2. Compiler
  3. Interpreter



Assembler:
It is a program that converts the instruction into bits for the understanding of computer. It acts upon each statement of source code & converts it into the corresponding bits. It also converts decimal numbers into binary code. It genrates object code which is also known as machine code. This machine code once genrated can be executed as and when desired. The genrated code contains a combination of machine instructions, data & all the desired information about placing the instruction in the memory.

Compiler:
It is a progarm that translate the code written in language like C, Java, C#, etc into a byte code or machine code (CPU specific) so that the computer can understand. It first checks the code for any errors. If ther are errors, it reports all of them to the programmer. But if the code is free from errors,the code is converted to its equivalent byte code or machine code. Compled code is faster to execute. The executable code created by compiler can be executed anywhere & anytime without requring recomplilation.

Interpreter:
It reads the code fed to it line by line. If the line being read is free from any error, the code is converted to executable code and then executed. If there is any error, interpreter stops ther itself and reports the error to the programmer. Some languages like java have both compiler and interpreter. Compiler converts source code to byte code. The byte code Is machine independent, so it is portable. The interpreter converts byte code into the machine specific code line by line and execute it.

Thanks for reading.......

First Program of C


Program:



Program to print hello world!


#include<conio.h>
#include<stdio.h>
void main()
{
          clrscr();
          printf(“H E L L O   W O R L D”);
          getch();
}

    Output


output:- first progrtam of c



# :-Preprocessor directory
include:- "include" is key word use to include header files.
main: "main" is main function ,on the execution of program compiler first find the main function in program.
clrscr:- "clrscr" is a function that use to clear our console window.
printf:- "printf" is a function that use to print something on console window.
getch:- "getch" is a function that use to hole the console window.

Previous Topics


Features of C Language


Features of C Language

·         C is a robust language with a rich set of built-in functions and operators.
·         Portable.
·         Memory Management.
·         C provides the use of Pointers and Recursion.
·         Machine independent.
·         Case Sensitive (like A and a are different).
·         Programs written in C are efficient and fast.
·         C is highly portable, programs once written in C can be run on other machines with minor or no modification.
·         C Language is not High level Language nor Low level Language it is Middle Level Language.
·         C is a collection of C library functions; we can also create our function and add it to the C library.
·         C has Rich Library.
·         C is easily extensible.
fiture of c,Features of C,
Features of c

Advantages of C

·         C is the building block for many other programming languages.
·         Easy to learn.
·         It produces efficient programs.
·          It can be compiled on a variety of computer platforms
·         It can handle low-level activities
·         Programs written in C are highly portable.
·         Several standard functions are there (like in-built) that can be used to develop programs.
·         C programs are collections of C library functions, and it's also easy to add own functions to the C library.
·         The modular structure makes code debugging, maintenance and testing easier.

Disadvantages of C

·         C does not provide Object Oriented Programming (OOP) concepts.
·         C provides no data protection.
·         There are no concepts of Namespace in C.
·         It also doesn't feature reusability of source code extensively.
·         C does not provide binding or wrapping up of data in a single unit.
·         Difficult to debug.
·         C does not provide Constructor and Destructor.
·         C allows a lot of freedom in writing code, and that is why you can put an empty line or white space anywhere in the program. And because there is no fixed place to start or end the line, so it is difficult to read and understand the program.
·         C compilers can only identify errors and are incapable of handling exceptions (run-time errors).
·         It does not provide strict data type checking (for example an integer value can be passed for floating datatype).
·         C does not support documentation comment. Even C++ does not support documentation comment.


Thanks for reading

Previous Topics


Sunday, July 7, 2019

Introduction to C Language | Introduction to C Programming Language

C is a Middle-level structured oriented programming language, used in general purpose programming, developed by Dennis Ritchie at AT&T Bell Labs, the USA between 1972 and 1973.

The C Language is developed for creating system applications that directly interact with the hardware devices such as drivers, kernels, etc.

C programming is considered as the base for other programming languages, that is why it is known as mother language.


Some facts about C Language:



·         In 1988, the American National Standards Institute (ANSI) had formalized the C language.
·         C was invented to write UNIX operating system.
·         C is a successor of 'Basic Combined Programming Language' (BCPL) called B language.
·         Linux OS, PHP, and MySQL are written in C.
·         C has been written in assembly language.

It can be defined by the following ways:

  1. Mother language
  2. System programming language
  3. Procedure-oriented programming language
  4. Structured programming language
  5. Mid-level programming language

Uses of C Programming Language:

In the beginning, C was used for developing system applications, e.g. :
  • Operating Systems
  • Language Compilers
  • Assemblers
  • Text Editors
  • Print Spoolers
  • Network Drivers
  • Modern Programs
  • Databases
  • Language Interpreters
  • Utilities

C has become very popular language for following reason:

  • One of the early programming languages.
  • Still, the best programming language to learn quickly.
  • C language is reliable, simple and easy to use.
  • C language is a structured language.
  • Modern programming concepts are based on C.
  • It can be compiled on a variety of computer platforms.
  • Universities preferred to add C programming in their courseware.

 Previous Topics