Friday, 17 March 2017

DATA TYPES IN C

Basic and important Data types in C.

  • Integer type :- Integer data type in c are used to store integer values. "int " followed by a name is used to declare a integer type of variable.
    • Declaration
      • int a=23;
      • int a;
      • a=78;
      • int a,b

Thursday, 16 March 2017

USING CODE::BLOCKS

CODE::BLOCKS
Code::blocks is a open source , cross platform C,C++ IDE.

Using code::blocks for writing C programs.
Functions of each symbol with following number.
  1. That symbol is used to create or open a new source file in the IDE
  2. That is used to open an existing file.
  3. Its used to save a particular file.
  4. In case of working on a bunch of files to save all the files no.4 symbol is used.
  5. Is used to compile the code written in a .c file
  6. Is used to run the code after compilation.
  7. Is used to compile and run the code at the same time.
Error in the code.

If there are any errors or warning in the code then they are shown below in the build messages.

FIRST C PROGRAM

Lets start with our first c program example
Here is a simple c program which prints a simple "Hello world" message on the console.

  • #include<stdio.h>
  • int main()
  • {
  •        printf("Hello world \n");
  •        return 0;
  • }
The above program will print a simple "Hello world" message shown below.

You might be thinking what is that #include , stdio.h, main ,printf , return 0 for. SO.......
Lets have a look at the code.
  • #include
#include is a preprocessor directive. Both user and system header files are included using the preprocessing directive "#include".
  • stdio.h
"stdio.h" is a header file which stands for standard input output library. In order to use the "printf" function we need to include "stdio.h" header file. By including stdio.h we can use other functions like "scanf", "getc", "putc" and all. We'll look at it in later sections.
  • int main()
"int " is a Data type which refers to integer values. "main( )" is a function which is necessary in order to run any particular program. We'll come to functions and data types in later sections. Just remember that "int main( )" is a initial function which is required for any program to run and int defines the return type of that "main function". "main" function is the first function to be executed in any program.
  • printf("hello");
"printf" is a build in function which is used to display message on console or screen.
  • return 0
In main we have seen something about return type that return type is here we return 0 which is an integer value. "return 0" is mostly used in main function to specify that the program is working fine.
  • { } (curly braces), ; (semicolon)
"curly braces" are used to declare the scope of any function. The semicolon is used to define statement termination.

C BRIEF INTRODUCTION

  • What is C ?
C is a programming language developed at AT and T's Bell Laboratories of USA  in 1972. Designed and written by Dennis Ritchie. C language is a general purpose and structure oriented programming language.
  • Why C ?
Its not that you can't learn object oriented language before C. But before learning object oriented language like C++ , Java , C# and all which include more complicated stuff like classes, objects, inheritance , polymorphism and all. You should be familiar with the basic syntax, loops, pointers, input/output, structures.

Though C++ , Java, C# uses object oriented principle they still requires the core C language elements. That the reason over the years the importance of c is still unchallenged.

Major parts of popular operating system like Windows, Linux , unix are still written in C. This
is because even today when it comes to performance nothing can beat C.

C seems so popular is because it is 

  • reliable
  • simple 
  • easy to use
  • case sensitive language.
Getting started with C is similar to english language

The C Character Set



Constants, variables and keywords
Constants :-Two major categories
  • Primary
  • Secondary



C Keywords
Keywords are the words, whose meaning has already been explained to the C compiler. The keywords cannot be used as variables names because if we do so we are trying to assign a new meaning to the keyword which is not allowed by the complier.

Variables
Rules for constructing variables names
  • The first letter of variable name should be an alphabet or underscore
  • No commas or blanks are allowed 
  • No special symbol