Tuesday, 25 February 2014

'C' Code to print "Star Triangle"

*
***
*****
*******
*********
***********
*************
***************

main()
{
int i,j,r;
printf("Enter the number of rows of stars of Star Triangle to be drawn ");
scanf("%d",&r);
for(i=1;i<=r;i++)
{
 for(j=1;j<=r-i;j++)
 {
  printf(" ");
 }
 for(j=1;j<=2*i-1;j++)
 {
  printf("*");
 }
 printf("\n");
}
}

'C' Code to swap 2 numbers without the use of a third variable




main()
{
int a,b;
printf("Enter the two numbers,namely 'a' and 'b'");
scanf("%d%d",&a,&b);
a = a + b;
b = a - b;
a = a - b;
printf("The swapped number 'a' is %d\n",a);
printf("The swapped number 'b' is %d\n",b);
}

Thursday, 20 February 2014

Full Forms of some Computer Related Abbreviations

Today I found some Computer Related Full Forms,so I am sharing with all you people so that you can get aware of it.


  • HTTP = Hyper Text Transfer Protocol.
  • HTTPS = Hyper Text Transfer Protocol Secure.
  • IP = Internet Protocol.
  • URL = Uniform Resource Locator.
  • USB = Universal Serial Bus.
  • VIRUS = Vital Information Resource Under Seized.
  • 3G = 3rd Generation.
  • GSM = Global System for Mobile Communication.
  • CDMA = Code Divison Multiple Access.
  • UMTS = Universal Mobile Telecommunication System.
  • SIM = Subscriber Identity Module.
  • AVI = Audio Video Interleave
  • RTS = Real Time Streaming
  • SIS = Symbian OS Installer File
  • AMR = Adaptive Multi-Rate Codec
  • JAD = Java Application Descriptor
  • JAR = Java Archive
  • JAD = Java Application Descriptor
  • 3GPP = 3rd Generation Partnership Project
  • 3GP = 3rd Generation Project
  • MP3 = MPEG player lll
  • MP4 = MPEG-4 video file
  • AAC = Advanced Audio Coding
  • GIF = Graphic Inter changeable Format
  • JPEG = Joint Photographic Expert Group
  • BMP = Bitmap
  • SWF = Shock Wave Flash
  • WMV = Windows Media Video
  • WMA = Windows Media Audio
  • WAV = Waveform Audio
  • PNG = Portable Network Graphics
  • DOC = Document (Microsoft Corporation)
  • PDF = Portable Document Format
  • M3G = Mobile 3D Graphics
  • M4A = MPEG-4 Audio File
  • NTH = Nokia Theme (series 40)
  • THM = Themes (Sony Ericsson)
  • MMF = Synthetic Music Mobile Application File
  • NRT = Nokia Ringtone
  • XMF = Extensible Music File
  • WBMP = Wireless Bitmap Image
  • DVX = DivX Video
  • HTML = Hyper Text Markup Language
  • WML = Wireless Markup Language
  • CD = Compact Disk.
  • DVD = Digital Versatile Disk.
  • CRT = Cathode Ray Tube.
  • DAT = Digital Audio Tape.
  • DOS = Disk Operating System.
  • GUI = Graphical User Interface.
  • HTTP = Hyper Text Transfer Protocol.
  • IP = Internet Protocol.
  • ISP = Internet Service Provider.
  • TCP = Transmission Control Protocol.
  • UPS = Uninterruptible Power Supply.
  • HSDPA = High Speed Downlink Packet Access.
  • EDGE = Enhanced Data Rate for GSM [Global System for Mobile Communication] Evolution.
  • VHF = Very High Frequency.
  • UHF = Ultra High Frequency.
  • GPRS = General Packet Radio Service.
  • WAP = Wireless Application Protocol.
  • TCP = Transmission Control Protocol.
  • ARPANET = Advanced Research Project Agency Network.
  • IBM = International Business Machines.
  • HP = Hewlett Packard.
  • AM/FM = Amplitude/ Frequency Modulation.
  • WLAN = Wireless Local Area Network.

Saturday, 15 February 2014

First 'C' Program:"Hello World"

A program to print "Hello World" on the output screen.

main()
{
  printf("Hello World");
}

Explanation:

                  Here:
                         "{"-->start of the program
                         main()-->driver of the program(always used in a program and never terminated with a semicolon";").
                         printf()-->to printf "Hello World" on the output screen
                         "}"-->end of the program.



Basic Programming Concepts

   

What is a Program?

A program is a set of instructions or commands which are given to the computer to perform a specific task or operations.
In other words,a program is actually logical sequence of various commands.

Basics Constituents of a 'C' Program

There are mainly three basic constituents of a 'C' language Program:

main()

The main() function is called "driver of the program".
It is responsible for the execution of various commands of the 'C' language Program.That's why it's called the driver of the program.

Syntax:
            main()
            {
              <statement 1>;
              <statement 2>;
              <statement 3>;
            }

printf()

The full form of printf() is "print in format".
It is an "Output-statement"

It is used to display the values of any type of variable as well as various messages on the output screen.
Syntax:
            printf(<"Message<Conversion Specification Characters>[Escape Sequence Characters]"> , <Variable>);

scanf()

The full form of scantf() is "scan in format".
It is an "Input-statement"

It is used to input any type of values or data through the keyboard by the user at runtime in any program of the 'C' language.
Syntax:
            scanf(<"Conversion Specification Characters"> , &<Variable>);

NOTE:
"&" is Ampersand(Address operator).
            It is used only in case of integer,long,float,character but not in case of strings.

Escape Sequence Characters

The Escape Sequence Characters are used to set the sequence the sequence of the output on the screen by using the following characters:

New Line:

"\n" : to go to a new line(maintain the vertical distance).

New Tab:

"\t" : to go to new tab(move forward by 7 characters)(maintain the horizontal distance).

Friday, 14 February 2014

Operators

The operators are used to control/operate the various types of expressions within any program of the 'C' language.
In 'C' language,there are five types of operators:

Arithmetical Operators

  1. "+" : for addition
  2. "-" : for subtraction
  3. "*" : for multiplication
  4. "/" : for division
  5. "%": for modulation(to obtain the remainder).
Ex: 5/2 = 2.5 , 6/2 = 3 , 5%2 = 1 , 6%2 = 0.

Logical Operators

  1. "&&" : AND(Double Ampersand)
  2. "||" : OR(Double Pipe)
  3. "!" : NOT(Exclamation).

Relational Operators

  1. ">" : is greater than
  2. ">=" : is greater than or equal to
  3. "<" : is less than
  4. "<=" : is less than or equal to
  5. "==" : is equal to
  6. "!=" : is not equal to.

Assignmental Operators

    "=" : equals or equal to.
Ex: a = 5 ('5' is assigned to variable 'a') , while in a == 5 ('a' is compared with '5').

NOTE:Logical operators are never used independently , thy are used in combination with Relational Operators.

Short-Hand Operators

These operators are very useful as they decrease the time consumption.That's why they are known as Short-Hand Operators.
  1. "++" : incremental operator(increase by '1')
  2. "--" : decremental operator(decrease by '1')
  3. "+=" : increment by '1' or any real value
  4. "-=" : decrement by '1' or any real value
  5. "*=" : multiply by any value
  6. "/=" : divide by any value.
Ex: 1. k = k + 1  OR  k++
      2. k = k - 1  OR k--
      3. k = k + 2  OR k+=2
      4. k = k - 2  OR k-=2
      5. k = k * 3  OR k*=3
      6. k = k / 3  OR k/=3.

Conversion Specification Characters

These characters are used to set the format of any type of data,at the time of input as well as output operations because without conversion,we cannot input or output any type of data within any program of the 'C' language.
  1. "%d": for Integer(Here 'd' denotes the decimal number system).
  2. "%f" : for float.
  3. "%c": for character.
  4. "%s": for string.
  5. "%u":for unsigned values.(All the Buffer Addresses are called unsigned values).


Declaration Keywords

The following are some of the keywords or commands which are used to declare the variables/data names in 'C' language:
  1. 'int': for an Integer.
  2. 'long': for a Long Integer.
  3. 'float': for a float.
  4. 'char': for a character or a string(array of character data type).
NOTE: While using 'char' for a string one must write the limit of the characters used to form string inside a square bracket"[]".
           For ex: char nm[32] , In this example we took an array of 32 characters inside the data type string(character)

Structure of 'C' language Program

*[Global Declaration]
  [Main function]
       *[Local Declaration]
        [Executable Section]
*[User Defined Function]
       *[Local Declaration]
       *[Executable Section]

where "*" stands for optional.

Global Declaration

In Global Declaration,one can declare all the variables or data names which are used anywhere in the program.

Main Function

The main function is also called "The Driver of the 'C' Program" because all the statements or commands of 'C' language are executed by the main function.

Local Declaration

In Local Declaration,on can declare all the variables or data names which are used only within specific section of the program.

User-Defined Functions

These functions are also called as "Special Assistants of the users" which are used to perform any specific task or operation according to the user.

Introduction to 'C'

History of 'C' Language

The 'C' language is a modified or extended version of the Basic Cambridge Programming Language(B.C.P.L) which was known as 'B' Language.That's why then new version is called as 'C' language.

'C' is a programming Language developed at Bell Laboratories(U.S.A) in the year 1970.
It was designed and developed by Sir "Dennis Ritchie".

The first authorised version of 'C' language was released in 1972.

Basics About 'C'

'C is a middle level language which is more comfortable to communicate with the Hardware Machines.



The 'C' language must be studied prior to  studying languages such as 'C++',C# & 'Java'.
Majority of Operating Systems like Windows,Linux,UNIX etc are written in 'C' language.