Thursday, 1 June 2017

Decision Making in C ~ mkniit

Decision making in C

Decision making is about deciding the order of execution of statements based on certain conditions or repeat a group of statements until certain specified conditions are met. C language handles decision-making by supporting the following statements,
  • if statement
  • switch statement
  • conditional operator statement
  • goto statement
Read More »

Variables in C Language ~ mkniit

Variables in C Language

A variable is a name that may be used to store a data value. Unlike constant, variables are changeable, we can change value of a variable during execution of a program. A programmer can choose a meaningful variable name. Example : average, height, age, total etc.

Rules to define variable name

  1. Variable name must be upto 8 characters.
  2. Variable name must not start with a digit.
  3. Variable name can consist of alphabets, digits and special symbols like underscore _.
  4. Blank or spaces are not allowed in variable name.
  5. Keywords are not allowed as variable name.
Read More »

Data types in C ~ mkniit

Data types in C Language

Data types specify how we enter data into our programs and what type of data we enter. C language has some predefined set of data types to handle various kinds of data that we use in our program. These datatypes have different storage capacities.
C language supports 2 different type of data types,

Primary data types

These are fundamental data types in C namely integer(int), floating(float), charater(char) and void.

Derived data types

Derived data types are like arrays, functions, stuctures and pointers. These are dicussed in detail later.

Primary data types in c

Integer type

Integers are used to store whole numbers.
Size and range of Integer type on 16-bit machine
TypeSize(bytes)Range
int or signed int2-32,768 to 32767
unsigned int20 to 65535
short int or signed short int1-128 to 127
long int or signed long int4-2,147,483,648 to 2,147,483,647
unsigned long int40 to 4,294,967,295

Floating type

Floating types are used to store real numbers.
Size and range of Integer type on 16-bit machine
TypeSize(bytes)Range
Float43.4E-38 to 3.4E+38
double81.7E-308 to 1.7E+308
long double103.4E-4932 to 1.1E+4932

Character type

Character types are used to store characters value.
Size and range of Integer type on 16-bit machine
TypeSize(bytes)Range
char or signed char1-128 to 127
unsigned char10 to 255

void type

void type means no value. This is usually used to specify the type of functions.
Read More »

Operators in C Language ~ mkniit

Operators in C Language

C language supports a rich set of built-in operators. An operator is a symbol that tells the compiler to perform certain mathematical or logical manipulations. Operators are used in program to manipulate data and variables.
C operators can be classified into following types,
  • Arithmetic operators
  • Relation operators
  • Logical operators
  • Bitwise operators
  • Assignment operators
  • Conditional operators
  • Special operators
Read More »

Keywords and Identifier in C ~ mkniit

Keywords

Keywords are preserved words that have special meaning in C language. The meaning has already been described. These meaning cannot be changed. There are total 32 keywords in C language.
autodoubleintstruct
breakelselongswitch
caseenumregistertypedef
constexternreturnunion
charfloatshortunsigned
continueforsignedvolatile
defaultgotosizeofvoid
doifstaticwhile
Read More »

C Syntax Rules ~ mkniit

C Language Syntax Rules

C language syntax specify rules for sequence of characters to be written in C language. The rule specify how character sequence will be grouped together to form tokens. A smallest individual unit in c program is known as C Tokens. Tokens are either keyword, identifier, constant, variable or any symbol which has some meaning in C language. A C program can also be called as collection of various tokens.
Example of C tokens,
intcurly braces { }commentssemicolon ;
Read More »

C Input / Output ~ mkniit

C Input output function

C programming language provides many of the built-in functions to read given input and write data on screen, printer or in any file.

scanf() and printf() functions

#include<stdio.h>
#include<conio.h>
void main()
{
 int i;
 printf("Enter a value");
 scanf("%d",&i);
 printf( "\nYou entered: %d",i);
 getch();
}
Read More »

My First C program ~ mkniit

First C language Program

Lets see how to write a simple c program
#include <stdio.h>
#include <conio.h>
int main()
{
 printf("Hello,World");
 getch();
 return 0;
}

Different parts of C program.

  • Pre-processor
  • Header file
  • Function
  • Variables
Read More »

Features of C ~ mkniit

Features of C language

  • It is a robust language with rich set of built-in functions and operators that can be used to write any complex program.
  • The C compiler combines the capabilities of an assembly language with features of a high-level language.
  • Programs Written in C are efficient and fast. This is due to its variety of data type and powerful operators.
  • It is many time faster than BASIC.
  • C is highly portable this means that programs once written can be run on another machines with little or no modification.
Read More »

Overview of C language ~ mkniit

C is a structured programming language developed by Dennis Ritchie in 1973 at Bell Laboratories. It is one of the most popular computer languages today because of its structure, high-level abstraction, machine independent feature. C language was developed with UNIX operating system, so it is strongly associated with UNIX, which is one of the most popular network operating system in use today and heart of Internet data superhighway.

History of C language

C language has evolved from three different structured language ALGOL, BCPL and B Language. It uses many concepts from these languages and introduced many new concepts such as data types, struct, pointer. In 1988, the language was formalised by American National Standard Institute(ANSI). In 1990, a version of C language was approved by the International Standard Organisation(ISO) and that version of C is also referred to as C89.
Read More »