Saturday 8 June 2019

Roman Number

The chart of roman numerals :

 I -1       
II -2
III - 3
IV - 4
V - 5
VI - 6
VII - 7
VIII - 8
IX - 9
X - 10
 XI - 11
XII - 12
XIII - 13
XIV - 14
XV - 15
XVI - 16
XVII - 17
XVIII - 18
XIX - 19
XX - 20

XXX - 30
XL - 40
L - 50
LX - 60
LXX - 70
LXXX - 80
XC - 90
C - 100
D - 500
M - 1000

Wednesday 2 January 2019

Variables in C

In programming, we actually work with some data. Suppose we are going to add two numbers 3 and 5. So, where are we going to store this value and do addition? Here, we use variable. 

So, variable is an identifier that is used to store some value. Values are actually stored in memory location and variable is the name of that storage location or memory location. 

A variable represents a single data item. By variables or variable name, we can access the data item anywhere in the program. Different data item can be stored at any place of the program.

Variable is an identifier, so rules of identifier should be used here. 

-- Variables are constructed with digits, letters.
-- But variable name must begin with letter (underscore is also allowed at the beginning).
-- Variables are case sensitive.
-- Special symbols are not allowed(i.e. ",',% or blank space etc. ).

Monday 31 December 2018

C Data type

The word data type tells that it describes the type of data.  We haven't yet studied variables, functions etc. Data type is used there to describe the type of data. C supports several different types of data, each of which may be represented differently within the computer’s memory. Below are 4 basic data types.


Data typeDescriptionMemory requirement  Value range
charsingle character1 byte -128 to 127
int integer quantity2 bytes-32,768 to 32,767
float floating-point number4 bytes-2,147,483,648 to +2,147,483,647
double double precision floating-point number 8 bytes 2.3E-308 to 1.7E+308

The above data types can be used in an extensive way by using qualifiers like signed,unsigned, short, long.
For example, int data type can be used as signed int or long int and char data type can be used as signed char or long char.
Signed int means it will consider the sign bit and it is same as normal int but in case of unsigned int the value range will be from 0 to 65,535.

The char data type represents individual characters. Hence, the char type will generally require only one byte of memory. Actually char type is of integer type.
With most compilers, a char data type will permit a range of values extending from 0 to 255. Some compilers represent the char data type as having a range of values extending from -128 to +127. There may also be unsigned char data (with typical values ranging from 0 to 255), or signed char data (with values ranging from -128 to +127).

Keywords and Identifiers of C Language

Identifiers
Identifiers are names that are given to various program elements, such as variables, functions and arrays. These are user-defined. Identifiers consist of letters, digits and some characters but the first letter must be a letter. Generally lowercase letter is used but uppercase letter can also be used. Uppercase and lowercase letters are not interchangeable.
Identifiers can be of any length but typically it accepts 31 characters.
The following names are valid identifiers.

    a   x   xy   firstname  lastName  area_of_circle   _length  test18
The followings are not valid identifiers.
         18test                   The first character must be a letter
         "xx"                      Illegal character "
         first name             Blank space
         last-name              Illegal character -

Keywords:
In C programming language, there are some certain reserve words. These reserve words are called Keyword. Keywords can be used only in particular purpose that is defined in language. So, keywords cannot be used as identifiers. Keywords have standard predefined meanings.
C keyword list is below:
      
Keywords in C Language
auto double int struct
break else long switch
case enum register typedef
char extern return union
continue for signed void
do if static while
default goto sizeof volatile
const float short unsigned

Note that the keywords are all lowercase. Since uppercase and lowercase characters are not equivalent, it is possible to utilize an uppercase keyword as an identifier. Normally, however, this is not done, as it is considered a poor programming practice.

Sunday 30 December 2018

C Character Set


Character set is important for any computer languages because this character is understood by the compiler. To write a program, we code, but the code has to be meaningful to the compiler. To write statement, expression, variable or custom function name, this are formed from this computer set.

C character sets are belows:
  • Uppercase letter A to Z
  • Lowercase letter a to z
  • The digit 0 to 9
  • And some special character sets
    +    -      *    /    =    %   &    # 
    !     ?     ^    "      '   ~      \      |
    <     >   (      )      {    }     [      ]
    :      ;     .     ,       _
Most versions of the language also allow certain other characters, such as @ and $, to be included within strings and comments. It also allow some White space characters. These are;
  • \b blank space
  • \t horizontal tab
  • \v vertical tab
  • \r carriage return
  • \f form feed
  • \n new line 
  • \\ Back slash
  • \’ Single quote
  • \" Double quote
  • \? Question mark
  • \0 Null
  • \a Alarm (Audible Note)

Saturday 29 December 2018

C Program Structure

C program structure

C is structured. So, it is modular and the modules are function, i.e. the modules are called function. One of the functions must be called main. The program will always begin by executing the main function, which may access other functions.

To run a c program, you must include something at the beginning of the code, which will ensure your smooth compiling. It is sort of mandatory because this loads some initial code to run a program. For example;
#include <stdio.h>

The #include is a "preprocessor" directive that loads a file called stdio.h (stdio.h is a header file). Header files are collection of some build-in codes that does a lot of task to run a program.
Now look at the below program;

#include <stdio.h>
int main()
{
  printf("Hello,World"); 
  return 0; 
  //end of code(this is a comment)
}

So the whole program is enclosed by a function and this function is called 'main()'.
In later tutorial, you will learn about details of functions, how to write function, how to use it, what are required to write a function.  
Codes are written in an enclosed pair of braces, i.e., { }
Inside braces expression statements are written, i.e., printf("Hello,World");
Each expression statement must end with a semicolon (;). 
Comments (remarks) may appear anywhere within a program, as long as they are placed within the delimiters  /* and */ (e.g., /* this is for multiple comment */). Single line comment can be written after two forward slashes //.
The program is typed in lowercase. Either upper- or lowercase can be used, though it is customary to type ordinary instructions in lowercase.

What Is The Difference Beween Numerals and Number?

Number is a concept, it is a mathematical concept. To express the quantitative value of the object, this  is developed in ancient history. S...