ad728

Saturday, December 31, 2016

Facebook Color Code

Facebook Color Code

Note: Facebook Color can only added via FB Lite and seen in FB Lite only. 
fg=ffff0600 FOR RED
fg=b0ffd700 FOR GOLDEN
fg=b0000000 FOR BLACK
fg=b0ff7f00 FOR ORANGE
fg=b0ffff00 FOR YELLOW
fg=b0ff00ff FOR LIGHT PINK
fg=b0ff007f FOR DARK PINK
fg=b0ff0000 FOR REDDISH PINK
fg=b0800000 FOR BROWN
fg=b0ffc0cb FOR LIGHT PURPLE
fg=b06f00ff FOR DARK BLUE
fg=b0c0c0c0 FOR GREY
fg=80ffffff FOR SKY BLUE
fg=b000ffff FOR LIGHT BLUE
fg=b0bf00ff FOR PURPLE
fg=b08f00ff FOR DARK PURPLE
fg=b0808000 FOR MEHANDI GREEN
fg=b0ba55d3 FOR LIGHT PURPLE
fg=b0f000f0 FOR MAGENTA
fg=b00000ff FOR BLUE
fg=b0b08080 FOR STEEL GREY
fg=b0000080 FOR MOVVE
fg=b0964b00 FOR LIGHT BROWN
fg=f0f00f0f FOR RED
fg=b000ff00 FOR GREEN
Note: If you want other types of color effect type bg instead of fg.
This will work only on Facebook Lite.
Method:
First write less than (<) color code  then greater than(>) and at last type the text you want to show in color.
For example: <bg=b000ff00> Hello
                       <fg=b000ff00> Hello
Watch the video and enjoy texting 

Share:

Thursday, December 15, 2016

AIDE Tutorial - 17 Check Box

AIDE Tutorial - 17 Check Box

Watch the video below and try yourself
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<CheckBox
android:onClick="aaa"
android:id="@+id/one"
android:text="Phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<CheckBox
android:onClick="bbb"
android:id="@+id/two"
android:text="SD Card"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Java
package com.mycompany.myapp3;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
public class MainActivity extends Activity
{@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.main);}
public void aaa(View view){
CheckBox one =(CheckBox)findViewById(R.id.one);
if (one.isChecked()){
Toast.makeText(this,"Phone is selected",
Toast.LENGTH_SHORT).show();}
else{Toast.makeText(this, "Phone is not selected",
Toast.LENGTH_SHORT).show();}}
public void bbb(View view){
CheckBox two=(CheckBox)findViewById(R.id.two);
if (two.isChecked()){
Toast.makeText(this,"SD Card is selected",
Toast.LENGTH_SHORT).show();}
else{Toast.makeText(this, "SD Card is not selected",
Toast.LENGTH_SHORT).show();}}}
Share:

Tuesday, December 13, 2016

AIDE Tutorial - 8 Toast Gravity

AIDE Tutorial - 8 Toast Gravity 



Add a button on XML
<Button
        android:onClick="Click1"
        android:text="Click Me"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />



Import these on Java
import android.view.View;
import android.widget.Toast;


Add after R.layout.main
public void Click1 (View view){
    Toast aaa = Toast.makeText(
getApplicationContext(),
"you clicked",
Toast.LENGTH_SHORT
);
aaa.setGravity(Gravity.BOTTOM,0,0);
aaa.show();
}


For center change BOTTOM to CENTER
For top change BOTTOM to TOP


Fill the horizontal
aaa.setGravity(Gravity.TOP|Gravity.FILL_HORIZONTAL,0,0);

Share:

Sunday, December 11, 2016

AIDE Tutorial - 6 Button

AIDE Tutorial - 6 Button


Watch the below video 🤗

Normal Button
This is the example of normal button.

<Button
android:text="Android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>


Image button
This is the example of image button. In this image button i have choosen the ic_launcher i.e. auto generated android icon on AIDE application.

<ImageButton
  android:src="@drawable/ic_launcher"
    android:layout_width="wrap_content"
   android:layout_height="wrap_content"/>

Text + Image Button
This is the example of text plus image button.In this  i have choosen the ic_launcher i.e. auto generated android icon on AIDE application.
<Button
    android:text="android"
 android:drawableLeft="@drawable/ic_launcher"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>




Note: all the text in red are code. For more please watch the video embeded above.
Share:

Friday, December 9, 2016

AIDE Tutorial - 9 Internet Button

AIDE Tutorial - 9 Internet Button



Define a button in main.xml
<Button
        android:onClick="Click1"
        android:text="Click Me"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />



Import these three View, Intent and Uri in java
import android.view.View;
import android.content.Intent;
import android.net.Uri;

And then add the following code after R.main
public void Click1 (View view){
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://shyamkumarkc.blogspot.com")));
}




Share:

Wednesday, December 7, 2016

AIDE Tutorial - 7 Toast Button

AIDE Tutorial - 7 Toast Button





Toast Button will help to appear toast when the button is clicked. In this app, we add onClick method to the button whenever the button is clicked a toast message will appear. 
        To show toast we will use a normal Button.
Add a button on XML
First of all add a button. Lets add a normal button.

<Button
        android:onClick="Click"
        android:text="Click Me"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />



Java
Import these on Java
import android.view.View;
import android.widget.Toast;

Add after R.layout.main
public void Click (View view){
     Toast.makeText(
getApplicationContext(),
"you clicked",
Toast.LENGTH_SHORT
).show();


After adding this on Main Activity.java you need to build the app. When you click button a small toast will appear which says you clicked.
Toast.LENGTH_SHORT instead of this you can also write Toast.LENGTH_LONG this will shows toast for longer duration.
Share:

Tuesday, November 29, 2016

How to change Android App icon ?

How to change Android App icon on AIDE?


First choose the picture which you want to put as an icon of the App. Then copy or move the picture or image to the Storage/App Project/App name/app/src/main/res/drawable. You will get only drawable-hdpi, drawable-mdpi, drawable-xhdpi and drawable-xxhdpi but not drawable.
Just create a drawable folder and paste the image on it and give it a small name here I give the name as id_launcher because the default icon contain ic_launcher and it will be easy to rename it.

Now open the app project in AIDE and the Android Manifest.XML. Rename the App icon name ="@drawable/ic_launcher" to ="@drawable/id_launcher" then click on build app. Install the app you will see the desired picture or image as the app icon. The app icon must be in .png extension other extensions of image may not work in the app.
Watch the video for support



Final word: You have recently learned to change the app icon in AIDE android development project as well as Android Studio and Eclipse. But its slightly change in case of copying file in the Android Studio and Eclipse, to change app icon you should directly open project in the respective software and directly copy the image in drawable folder shown in the software. You don't need to search the folder in storage and as it is in Android Manifest.XML
If you have any questions first see "Why my Android App icon does not change?" and then comment your questions below


Share:

Sunday, November 27, 2016

Why my Android App icon does not change?

Frequently Asked Questions (FAQs)

Why my Android App icon does not change?

Ans: This may happens mainly due to these reasons:

a. Copied file in different directory

You must create a drawable folder to add the icon in image in Storage/App Project/App name/app/src/main/res. inside the res folder, like shown below
Copying in other folder needs changes in code inside the Android Manifest.XML

b. Name is not included in Android Manifest.XML

After copying the image in same directory you should replace the name of the image ic_launcher to your image name. Rename the image similar to ic_launcher like ip_launcher, id_launcher, etc. the name can also affect the process.

c. Uppercase and lowercase is not properly mentioned

You should replace the name of the image ic_launcher to your image name. Rename the image similar to ic_launcher like ip_launcher, id_launcher, etc. the name can also affect the process. Consider the Uppercase and lowercase of the folder name and image name.


d. Consider Image Extension

This is important thing you should do if your app icon did not work. The app icon must be in .png extension other extensions of image may not work in the app.

e. Name of the project

Look the name of project you are working with and the name of the project you are copying the image file; sometimes you may work at one and copy file to another. This sounds funny but I too have been through this many times.


Note: If you have any other questions comment below I will upload answer and notify you. Thank you. Once again watch the videos and try it you will definitely success.


Share:

Friday, November 25, 2016

Modern Filing

Modern Filing


Flat or Horizontal Filing

Then file is kept in flat position in flat or horizontal filing. Documents are chronologically filed in folder; the oldest document is at the bottom.

Advantage

a. It is simple to understand and easy to operate. No need to have special skills.
b. It is economical. Files are cheap.
c. It needs small space of office; can be placed in drawer or alimirah.
d. It is convenient to locate documents. Classification of documents allow their quick location.
e. It protects document from water, rats, insects, dust, etc.

Disadvantage

a. It requires time for punching and filing a new document and taking document out.
b. The files are kept one over another. It makes difficulty locating needed files.
c. The filing capacity is limited. Different sized documents cannot be filed.
d. Punching and inserting in clips can damage documents.
e.  It is not suitable for large offices.

Vertical Filing


It consist folder that are kept in standing position. It  is folded in the middle to hold documents. It is placed in a drawer in vertical position in chronological order.

Advantage

a. It has large capacity to store documents.
b. Folders can be increased or decreased as per need.
c. It protects document from water, fire, dust, insects, etc.
d. Documents can be quickly located in cabinet which ensures secrecy.
e. This filing system is suitable for all type of offices.

Disadvantage

a. It requires high investment in folders and cabinet.
b. It requires more space to install filing equipment.
c. It is complex can be operated by skill man power.
d. Documents can be misplaced or lost. there is no tied up of documents.

open-Self Filing


Open-self filing is used to keep files, documents openly. In this filing, files are kept in numerical order. This type of filing system have large capacity to store files.

Advantage

a. It has large capacity to store the files, documents.
b. Folders can be increased and decreased as needed.
c. This types of filing system is applicable to all types of offices.
d. Documents can be easily filed and taken out if needed.

Disadvantage

a. It requires high investment on open self.
b. It requires large office space to install filing system.
c. It is complex only skilled man power can operate it.
d. This filing system don't protect the document from theft, dust, insects, etc.
Share:

Wednesday, November 23, 2016

Numerical Filing

Numerical Filing


In numerical filing, all the paper, records are arranged on the basis of number. the number is provided to the file according to the received date of paper like 1, 2, 3. The index is used in this system.

Advantages

a. The numbered file provides easy reference. Card index provides cross reference.
b. It is suitable for big offices with large number of files.
c. Numeric figure provide accuracy in filing. Misplacements of documents are few.
d. It is flexible. Files can be added or removed easily.
e. Identify of file can't be known without knowledge of file number.

Disadvantages

a. It is complex. Trained people are required for the operation.
b. It is expensive. Separate index and skilled manpower are needed.
c. Index needs to be consulted to locate file. It is time consuming.
d. It is unsuitable for small offices with small number of files.
Share:

Monday, November 21, 2016

Geographical Filing

Geographical Filing


in Geographical filing all the papers, records are arranged according to the region, district, zones, etc which are also arranged in alphabetical or numerical filing system.

Advantages

a. It is simple to understand and easy to operate.
b. Needed files can be located fast with the help of index.
c. It is suitable for offices having operation in wide geographical areas. Global companies use this system.
d. It requires little time for filing documents.

Disadvantages

a. It is expensive; it requires index which is not suitable for small offices.
b. It is difficult to handle if geographical knowledge is poor.
c. The name of place and person is written on the file tab so there is lack of secrecy.
d. Classification of documents in geographical are is time consuming.
Share:

Saturday, November 19, 2016

International Organizations and their headquarters

Some International Organizations and their headquarters



Lets learn about some international organization and where the headquarters are :
1. United Nation Organization (UNO)- New York
2. UNICEF - New York
3. UNESCO - Paris
4. UNIDO - Vienna
5. World Health Organization (WHO) - Geneva
6. UNFPA - New York
7. International Labour Organization (ILO) - Geneva
8.  International Monetary Fund (IMF) - Washington DC
9. World Trade Organization (WTO) - Geneva
10. International Court Of Justice - The Hague
11. International Atomic Energy Agency - Vienna
12. World Bank - Washington D.C.

13. International Committee of the Red Cross -Geneva
14. International Maritime Organisation - London
15. Universal Postal Union - Berne
16. Food and Agricultural Organisation - Rome
17. World Meteorological Organisation - Geneva
18. South Asian Association for Regional Cooperation (SAARC) - Kathmandu
19. Amnesty International - London
20. Transparency International - Berlin
21. World Intellectual Property Organization - Geneva
22. International Renewable Energy Agency - Abu Dhabi (UAE)
(Interim HQs)
23. Common wealth of Nations - London


Final word:
If you think any other organizations to be listed or any mistake in this article please comment below. We will make correction within 24 hours.

Share:

Saturday, November 5, 2016

The Magic of Words

Unit One : Stories of the Supernatural

The Recurring Dream | A Story from England

 
The story starts with a description of Kimberly Clark, the protagonist of the story, who is twenty five years old with all qualities of a normal young woman. She is pretty, she loves to dance, and she has many friends and a good position in the office of a large company. Despite these all, she has a problem. She has been troubled by a strange and mysterious dream that haunts her every night.
The strange dream always begins on a country road. Kim stands on this road and sees a lane with a white fence and a hedge on each side. At the end of the lane, on the top of a little hill, she sees a small white cottage with green shutters. Then she walks up the lane to the house, goes in and looks around. In one of the rooms, she finds a man asleep in bed. He is a little old man with white hair and a white heard. When she comes near his bed, the man wakes up. Then he sits up and looks at her. When she tries to speak to him, she wakes up. She is very surprised troubled by the dream because she has never known any little old man like that and neither the place.
Kim’s roommate knows everything. So, one day she proposes Kim to visit her (Janet’s) parents’ farm house to feel peace in mind. As they pass through a country road, Kim sees the similar scene which she sees in her dream. They stop there. Janet does not want Kim to go and see the small cottage but Kim goes.
The house was exactly the same, except for a sign in front of the house which said ‘FOR SALE’. Unlike her dream, Kim goes to the door of the house and knocks and to her surprise the same old man answers the door who immediately closes the door. After Kim’s request, he opens the door. Kim again asks why the house is for sale. The old man reveals that the house is haunted by a ghost. Kim tries hard to think to say something instead asks who the ghost is. The old man gets surprised and shocks her by replying that she herself is the ghost.

The Loving Mother | A Story From the Island of Hokkaido, Japan

Mr Shoji Sakota was a pharmacist in the city of Sappora on Hokkaido Island in northern Japan. He used to have his own drug store in the same building, where he used to live. He used to live alone in the rear part of the building because his wife had died several years earlier.
One stormy winter night in 1964, he was working in his room at about mid night. As it was the end of the fiscal / financial year, he was very busy with the profit, loss and the accounts of the whole year. At that time, there was a knock at his door. At first, he avoided it. But the knocking persisted or repeated. At last, he opened the door thinking that somebody might have come for some very important medicine. It was a woman who wanted an ame (Japanese candy used for pacifying young children) on a stick for her baby. Mr Sakota was quite surprised at it because the lady was buying sweet at that time of night. He was very much moved or surprised by the appearance of the lady. She was so strange that her hair was disheveled / messy / uncombed / untidy and her eyes were quite strange.
In short, she looked a lady from another world. The lady went from there but somehow or other Mr Sakota could not forget her appearance and at last he left working and went to the bed. On the next night, the same woman came and both the times she asked for an ame. Mr Sakota was all the more worried. He had a friend with whom he shared his worries. The friend was a photographer. So, they planned to snap the lady if she came the next time or next night.
The next night also, the lady came at the same time and with the same demand. The photographer friend was hiding in the shop and he snapped the lady from different angles. But, when the photographs came, they were quite surprised to find that all articles were present in the photograph but not the lady. Then the two friends decided to follow her the next time if she came.
The next night also, the lady arrived at the same time and asked for an ame. When she left the shop, the two friends followed her quietly. Finally, they reached to a room in an old building. In the room, they found a baby sucking or licking an ame and the woman appeared to be sleeping there in the bed. When they tried to wake up the lady, they realized that she was dead and they felt that she had been dead for several days.
The conclusion is that after her death the lady’s soul was worried about the child. She not only wanted to arrange for food for her child but she also wanted someone to come and know that she had been dead and her child was in a helpless situation. She had selected Mr Sakota for this.

The Lost Doll | A Story from Colombia, South America

Carmen was the only child of Roberto and Rosa Soto. She was beautiful, bright and loving child. However she was sick from the day of her birth. When she was four, she fell sick seriously and died. A few days after the funeral ceremony, Rosa gave away Carmen’s playthings and clothes to a priest of another village so that she couldn’t see them time and again. She thought that she wouldn’t have another child as she was told at the time of Carmen’s birth. When Roberto knew about it, he became very unhappy because he was hopeful that they would have another child. He asked about her the little dolly which Carmen always carried with her. Rosa said that she didn’t give it away. Then they searched everywhere in the house as well asked the villagers too but they couldn’t find it.
However they soon forgot about the lost doll because Rosa became pregnant. On the first anniversary of the death of Carmen, Rosa gave birth to another child. Roberto and Rosa became very happy. She was named Evangelina, which meant “good news”. When Evangelina grew she looked very much similar to her sister Carmen. But she was healthy girl. When she was about four, she told her mother that she had been sick a long time ago. She also told her aunt that she had a little, beautiful doll with blue eyes and red dress. She had buried it under a tree in the yard. She requested her mother to dig up the doll. When Rosa dug up the ground, she found the lost doll. She looked surprised, shocked and sick because it was difficult for her to believe. Evangelina also said that when she was sick, the nice man came and helped her to bury that doll under the tree.
The story accounts the supernatural significance regarding its particular focus on the concept of reincarnation. When Evangelina was born and grown up, she looked very much similar to that of Carmen’s actions, characters, behaviors and other many things were very much similar. The priest said that God healed Carmen and sent her back in the form of healthy Evangelina. Though Rosa did not believe that her newly born child as the reincarnation of Carmen but she could not reject the mysterious fact towards the end of the story. When Evangelina reported everything about past and about her doll, Rosa could say nothing anymore.

The House Call | A Story from Germany



The story took place on 26th December, 1903 in Berlin, Germany. The famous German surgeon, Dr. Emil Braun, was sitting alone in the dining room of his apartment trying to write notes about the surgery while having his dinner. Soon he dozed off but woke up when he heard the doorbell ring. He heard a child talking about her sick mother to Mrs. Braun. He went to the door and saw in the semidarkness a little girl of perhaps six or seven who was wearing a cotton dress and shabby shoes. Over her head, she had a ragged shawl which she was holding together at the neck. The doctor felt sympathy for the child and her sick mother and became ready to go with her.
It was raining lightly outside as the doctor walked down the steps to the street but the girl was already almost a block up the street, waiting for him. She walked too fast, however. Stopping only for a moment at each corner to make sure he saw where she was going. The girl led the doctor through the poorest part of Berlin, the section of the city around the hospital where Dr. Braun was head surgeon. Finally they reached an old tenement house where the girl’s mother was living. The doctor climbed up stairs up to the fifth storey. As the doctor entered the room, he heard the door close softly behind him.
The woman was lying in the bed. The doctor recognized her as a person who at one time worked as the maintenance staff at the hospital. She was suffering from pneumonia. When the doctor talked about the girl, daughter of the woman, Elda said that her daughter, Adelheid, had died of the flu in September just three days after her seventh birthday.
The doctor was surprised. The little girl was not there. Elda told that she had kept Heide’s shoes and shawl to remind her of Heide. The doctor got up and looked. He saw the same ragged shawl on a hook and a pair of shabby shoes on the floor. As he looked closely he found them wet. Elda said that she had been thinking about him earlier that night hoping and praying for him. As she was talking she felt asleep. Then, touching her feverish head once more, he took his black bag, stepped out into the dark hallway, and closed the door.

Share:

Thursday, November 3, 2016

Record management

Record management


We know that record means the information in the form of written which are  used by an office for formulating plan and policies and perform so many activities. Management means 'manage',  'men' and 't' where t refers to tactfully. Record management means the management of written informations and records like progress report, certificate, letters preserved for future reference. It is the process of collection, storing, distribution, as well as disposal of records.
According to Peterson, " Record management refers to the activities designed to control the life cycle of records from its creation to its ultimate disposition."
In conclusion, the record management is one of the important function of business organization as well as other organization. by the help of record management, an organization or office can easily show its all past information in the present days and are also important  for future reference.
Importances of record management
We know that, record management is related with the arrangement and preservation of records. By the help of record management, an office can peform so many activities correctly and perfectly. It helps to keep the document safely.
The importances of record management are as follows.
1. Source of decision making
All the decisions are made by the decisions maker with the help of past records, information which is already stored by record managment. So it is the source of decision making.
2. Helps to evaluate performance
With the help of past records, all the organization can evaluate its performance between past and present. By the help of record management, organization can easily compare its past and present performance.
3. Helps to detect and rectify errors
Human beings make so many mistakes in their life and the decision maker is also a human. So, mistakes and errors should be detected and rectified. Past information provided by record management helps to detect and rectify errors.
4. Fulfill statutory obligation
For the fulfillment of statutory obligation, the organization has to protect prospectus, memorandum, articles of association, certificate of incorporation and registration, etc. They are safely preserved by the record management for legal requirement.
5. Bring efficiency in performance
By the help of record management, an office personnel can easily submit required documents quickly in short time to the concerned authority which helps to bring efficiency in performance of employees as well as organization too.
6. Helps to settle disputes
If any misunderstanding arises between parties the upto date record management of the organization helps to provide records and documents as evidence. This will helps to settle disputes.
7. Helps in Planning and policy making
All the plans and policies are formulated by top level manager for the future with the help of past records. Record management helps to provide past records to make plans and policies.
Types of records
On the basis of nature
Records, papers are categorized according to the nature of the records.
1. Correspondance records
In daily life, an organization receives so many letters, correspondance from external as well as internal. Those letters and correspondance should those type of letters, information falls in correspondance records.
2. Financial records
The financial records are mainly related to income and expenditure of the organization which includes journal, ledger, trail balance book, cash book, profit and loss account, balance sheet etc. All those records are kept in this section.
3. Legal records
On the basis of legal obligation, all the records which are required for legal reference are kept in this section. prospectus, memorandum, articles of association, certificate of incorporation and registration, Tax clearance, etc. are the important legal records.
4. Human resource records
The records which are related to staffs, workers and employees of organization falls under human resource records.  Transfer letter, Promotion letter, recruitment letter, etc falls under it.
5. Miscellaneous records
The records which does not fall in correspondance, financial, legal and human resources fall under this record. Information letters, greeting cards, visiting cards, etc falls under this record.
On the Basis of retention
Very Important records
Under the very important records, generally legal records like memorandum, article of association, certificate of registration and incorparation, property's certificate, etc fall which may be needed at any time.
Important records
Under the Important records, generally financial records, and correspondance records falls which may be important in decision making process.
Useful records
Under useful records, generally human resource records fall which may be useful in organization for its day to day activities.
Useless or Less usefull records
Under this records, other different records fall which are not useful after the expiration of time. It should be disposed.

Principles of record management
a. Principle of Purpose
The purpose of record management should be clearly mention. The office must record only those data which may be important for future reference.
b. Principles of Verfication
The records must be true and relaible. Organization should keep those types of records which must be helpful in legally.
c. Principles of Classification
All the records recorded by office must be classified so that the data can be found in the time of necessity for the fulfillment of purpose.
d. Principles of Accountability
All the records recorded by office must be accountable which should help to give main destiny of record management for future reference.
e. Principles of Cost
Organization or office must concerntrate with the cost in record management. The organization or office must keep needed documents safely with minimizing cost.

Retention and Disposal of records
Meaning
Retention and Disposal of records is the important function of an organization. In organization, so many documents are received from outsider as well as inside of the organization. All the records may not be important for the organization in future.
They can be categorized into two groups:
1. Retention
2. Disposal
        The preservation of records and documents for the future reference is known as retention. This types of records are Very important, Important and Useful. Retention is the process of preservation of important documents for future, transfer of useless documents, destruction of useless records.
        The records which is only important for some time or useless after expiry of time, those types of records are disposed and destroyed by organization. The process of disposing useless documents is known as disposal of records.
Share:

Monday, October 10, 2016

AIDE Tutorial - 26 Simple Notification

Main.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="show"
        android:text="Click here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java

package com.kc.simplenotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

public void show (View v){
Notification.Builder nb=
new Notification.Builder(this);
nb.setContentTitle("Notification");
nb.setContentText("You Clicked!!!!");
nb.setSmallIcon(R.drawable.ic_launcher);


NotificationManager nm=(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}

Watch Video

Share:

AIDE Tutorial - 26.3 In Progress Notification

Main.Xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="abc"
        android:text="Download"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java

package com.kc.inprogressnotif;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

public void abc(View v){
Notification.Builder nb=new Notification.Builder(this);
nb.setContentTitle("Notification");
nb.setContentText("Download in progress");
nb.setSmallIcon(R.drawable.ic_launcher);
nb.setProgress(100,90,false);

NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}


Share:

AIDE Tutorial - 26.4 Expandable Notification

Main.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="show"
        android:text="Click here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

MainActivity.java
package com.kc.ExpandableNotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
public void show (View v){
Notification.Builder nb=new Notification.Builder(this);
nb.setContentTitle("Notification");
nb.setContentText("Downloaded");
nb.setSmallIcon(R.drawable.ic_launcher);

Notification.InboxStyle nis=new Notification.InboxStyle();
nis.setBigContentTitle("Downloaded part");
nis.addLine("Part 1");
nis.addLine("Part 2");
nis.addLine("Part 3");
nis.addLine("Part 4");
nis.addLine("Part 5");
nis.addLine("Part 6");
nis.addLine("Part 7");
nis.addLine("Part 8");
nb.setStyle(nis);


NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}



Share:

AIDE Tutorial - 26.1 Updating Notification

Main.Xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="show"
        android:text="Click here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java

package com.kc.UpdatingNotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
int count=0;



public void show (View v){
count++;
Notification.Builder nb= new Notification.Builder(this);
nb.setContentTitle("My Notification");
nb.setContentText("You clicked!!! "+count+" times");
nb.setSmallIcon(R.drawable.ic_launcher);

NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}


Share:

AIDE Tutorial - 26.2 Multiple Notification

Main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="click"
        android:text="Click here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java

package com.kc.MultipleNotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }


int in;
public void click (View v){
in++;
Notification.Builder nb= new Notification.Builder(this);
nb.setContentTitle("My Notification");
nb.setContentText("You Clicked!!!");
nb.setSmallIcon(R.drawable.ic_launcher);
NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(in,nb.build());
}
}


Share:

AIDE Tutorial - 25 Search Dialog

Main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <SearchView
android:id="@+id/mainSearchView"
        android:queryHint="Search your country"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
<ListView
android:id="@+id/mainListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
</LinearLayout>
Java

package com.kc.searchdialog;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.widget.SearchView.*;
public class MainActivity extends Activity
{
ArrayAdapter <String> ad;
String country[]={
"USA","UK", "Nepal", "UAE",
"China","Bangladesh", "India", "Japan",
"Korea","Russia", "Bhutan", "Afganistan",
"Pakistan","Australia",
};


    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

ad=new ArrayAdapter<String>(
this,
android.R.layout.simple_expandable_list_item_1,country);

ListView lll=(ListView)findViewById(R.id.mainListView);
SearchView sss=(SearchView)findViewById(R.id.mainSearchView);

lll.setAdapter(ad);
sss.setOnQueryTextListener(new OnQueryTextListener(){
@Override
public boolean onQueryTextSubmit(String p1)
{
// TODO: Implement this method
return false;
}
@Override
public boolean onQueryTextChange(String ppp)
{
ad.getFilter().filter(ppp);
// TODO: Implement this method
return false;
}
});
    }
}


Share:

AIDE Tutorial 24 TabHost

Main xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="top">
    <TabHost android:id="@+id/th"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/one"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="android smartphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="@+id/two"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:text="apple smartphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="@+id/three"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
Java

package com.mycompany.tb;
import android.app.*;
import android.os.*;
import android.widget.*;

public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
  
TabHost th=(TabHost)findViewById(R.id.th);
th.setup();



TabHost.TabSpec sp=th.newTabSpec("");
sp.setContent(R.id.one);
sp.setIndicator("Android");
th.addTab(sp);

sp=th.newTabSpec("");
sp.setContent(R.id.two);
sp.setIndicator("iphone");
th.addTab(sp);

sp=th.newTabSpec("");
sp.setContent(R.id.three);
sp.setIndicator("myphone");
th.addTab(sp);
   }
}


Share:

Monday, September 26, 2016

C Programming

Include Header File Section

C program depends upon some header files for function definition that are used in program.
Each header file by default is extended with .h. The header file should be included using # include directive as given here.
Global Declaration
This section declares some variables that are used in more than one function. These variables
are known as global variables. This section must be declared outside of all the functions.Function Main
Every program written in C language must contain main () function. The function main() is
a starting point of every C program. The execution of the program always begins with the function main ().
Declaration Part
The declaration part declares the entire variables that are used in executable part. The initialisations of variables are also done in this section. Initialisation means providing initial value
to the variables.


Executable Part
This part contains the statements following the declaration of the variables. This part conatins a set of statements or a single statement. These statements are enclosed between the braces.
Identifiers


Identifiers are names of variables, functions, and arrays. They are user-defined names,
consisting sequence of letters and digits, with the letter as the first character.Variable
It is a data name used for storing a data value. Its value may be changed during the program
execution. The value of variables keeps on changing during the execution of a program.Scope
Scope of variable tells compiler the visibility of variable in the blocktypedef
It is used to create new data type. But it is commonly used to change existing data type with another name.
Syntax:
typedef [data_type] synonym;
OR
typedef [data_type] new_data_type;
Example:
typedef int integer;
integer rno;
Keyword 
C Keyword
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






Operators
Type of Operator
Symbolic representtion
Arithmetic operators
+, -, *, /, %
Relational operators
  >, <, ==, >=, <=, !=  
Logical operators
&&, ||, !=
  Increment and decrement operator   
++ and --
Assignment operator
=
Bitwise operator
&, |, ^, >>, <<, ~
Comma operator
,
Conditional operator
  Condition ? True Statement  False Statement
Qualifier
Qualifier is an extra name given to either variables or functions , showing an extra quality or extra meaning for that variable or function.
1.Size qualifiers- It tells the size of basic data type. E.g. short, long
short int
2. Sign qualifiers- It tells the sign of the variable +ive or -ive E.g. signed , unsigned
3. Constant qualifiers/modifier - It can be declared with keyword const. An object declared by const cannot be modified.
const int i=10;
float const f=0.0f;
unsigned const long double ld=3.14L;
Example
void main()
{
const int a=5;
a++;
printf(“%d”,a);
}
output : compiler error, cannot modify const variable.
4. Volatile qualifiers- A variable is declared volatile when it’s value is changed external source from outside the program. “volatile” keyword is used.
(There is another type qualifier near, far, huge, which qualify only pointer type data type ,interrupt is also qualifier of data)
Storage Class
A storage class is an attribute that tells us where the variable would be stored,
what will be the initial value of the variable if no value is assigned to that variable,
life time of the variable and scope of the variable.
Scope:-  Scope of variable tells compiler the visibility of variable in the block
There are four storage classes in C:
1) Automatic storage class
2) Register storage class
3) Static storage class
4) External storage class
Automatic storage class:
keyword - ‘auto’.
variable declared stored in the memory.
Default - garbage value.
Scope - local to the block in which the variable is defined.
Variable is alive till the control remains within the block in which the variable id defined.
Example
#include<conio.h> #include<stdio.h> void main(){ auto num = 10; { auto num = 60; printf(“%d",num); } printf(“ %d",num); } Output: 60 10
Register storage class:
keyword -‘register’.
Variable declared stored in the CPU register.
Default - garbage value.
Scope of  variable - local to the block 
- The variable is stored in CPU register, it takes very less time to access that variable. Hence it becomes very time efficient.
- It is not necessary that variable declared as register would be stored in CPU registers. The number of CPU registers is limited. If the CPU register is busy doing some other task then variable might act as automatic variable
- Unary operator[&] is not associated with it because value is not stored in ram.
- If we store same variable in the register memory than we can access that memory location directly without using the Address operator
Example
#include<conio.h> #include<stdio.h> void main(){ register int a; printf(“%d",a); } Output: 7247 //the output is garbage value.
Static storage class:
keyword - ‘static’.
variable declared stored in the memory.
Default - zero.
Scope- local to the block in which the variable is defined.
Life of variable persists between different function calls.
Example
#include <stdio.h> void Check(); int main(){ Check(); Check(); Check(); } void Check(){ static int c=0; printf("%d",c); c+=5; } Output- 0 5 10
External storage class:
keyword - ‘extern’.
Variable declared stored in the memory.
Default - zero.
Scope - global.
-Variable is alive as long as the program’s execution doesn’t come to an end.
-External variable can be declared outside all the functions or inside function using ‘extern’ keyword.
Example
#include <stdio.h> void Check(); extern int a=5; /* a is global variable because it is outside every function */ int main(){ a+=4; Check(); return 0; } void Check(){ ++a; /* ----- Variable a is not declared in this function but,
works in any function as they are global variable ------- */ printf("a=%d ",a); } Output : a=10
Conditional Operator ( ? : )
Syntax: conditional_expression ? expression_if_true : expression_if_false
Nesting of conditional operator
Syntax : conditional_expression_1 ?(conditional_expression_2 ?expression_true_conditional_2 :expression_false_conditional_2 ) :expression_false_conditional_1
Example :-
int  x = 5 ,  y= 6;
int a = x > y ? x : y ;
a= x if x > y otherwise a = y
we can also assign a string using conditional operator.
Decision Making(if, if_else, nested if_else, else_if ladder)
1.  if
if ( test expression )
{
  statement_block;
}
2.  if_else
if ( test expression )
{
  statement_block;
}
else
{
  statement_block;
}
3.  nested if_else
if ( test expression )
{
  if (   test expression )
   {
     statement_block;
   }
   else
    {
     statement_block;
    }
}
else
{
  if (   test expression )
   {
     statement_block;
   }
   else
    {
     statement_block;
    }
}
4.  Else_if ladder
if ( test expression )
{
  statement_block;
}
else if ( test expression )
{
  statement_block;
}
else if ( test expression )
{
  statement_block;
}
else
{
  statement_block;
}
Switch Statement
switch ( expression )
{
case value 1:
  statement_block-1;
  break;
case value 2:
  statement_block-1;
  break;
.....
default:
  default_block;
  break;
}
/* If value of expression is equal to any value for example value1 then statement block 1 will be executed if the value is not matched with any value then default statement block will be executed*/
Some Rules for switch statement:
- expression must be an integral value.
- cases must have different value
- break statement should be there for terminate the case statement block.
- default case is optional.
Looping
For loop
It is an entry control loop .
for ( initialization ;  test_condition ;  increment/decrement  )
{
body_of_loop;
}
Example:
for ( i = 1 ; i <= 3 ; i++ )
{
printf(“%d “,i ) ;
}
Output: 1 2 3
Step 1 :  i is integer and it is initialized by 1
Step 2 :  Controllers of compiler now check the condition if i<=3 then it will come to the body of loop then it will print value of "i “  i.e.  1 and then controllers will come to the part of increment and will increase the value of “i” . Here i++ means i=i+1 . We can also use i=i+5 or i=i*2 or whatever we want.
Step 3 :  Now the value of i = 1+1= 2 and it will check the condition that i<=3
Step 4 :  Condition is true again and it will print the value of “i” i.e. 2 and it will now go to the increment part again and increase the value of “i” and again check the condition.
Step 5 :  3<=3  the condition is again true and it will print the value of   “i”  i.e.  3 and then it will again increase the value of “i”
Step 6 :  4<=3 the condition is false now and the loop will terminate.
Nested for loop
for ( initialization  ;  test_condition;   increment/decrement  )
{
for (  initialization ;  test_condition;  increment/decrement )
  {
      //body_of_loop
  }
//statements;
}
Try it :
1.
for ( i=0 ;  ;  i++ )
{
  printf (" Hello ");
  if ( i > 4)
   break;
}
2.
for ( i = 0 ;  ; )
{
  printf (" Hello " );
  i++;
  if(i>4)
  break;
}
3.
for ( ;  ;  )
{
  printf (" Hello");
}

While loop
It is exit control loop.
Syntax:
while ( test_condition )
{
  body of loop;
}
How it is used:
initialization;
while ( test_condition )
{
   body of loop;
   increment/decrement/other_change;
}
Try it
1.
while ( 0 )
{
   printf ( "Hello World ");
}
2.
while ( 1 )
{
    printf ( "Hello World " );
}

Do While loop
Syntax:
do
{
   body of loop;
} while ( test_condition ) ;
Note :  Semicolon must be there after while (   test _condition )
Switch Statement
switch ( expression )
{
case value 1:
  statement_block-1;
  break;
case value 2:
  statement_block-1;
  break;
.....
default:
  default_block;
  break;
}
/* If value of expression is equal to any value for example value1 then statement block 1 will be executed if the value is not matched with any value then default statement block will be executed*/
Some Rules for switch statement:
- expression must be an integral value.
- cases must have different value
- break statement should be there for terminate the case statement block.
- default case is optional.
Looping
For loop
It is an entry control loop .
for ( initialization ;  test_condition ;  increment/decrement  )
{
body_of_loop;
}
Example:
for ( i = 1 ; i <= 3 ; i++ )
{
printf(“%d “,i ) ;
}
Output: 1 2 3
Step 1 :  i is integer and it is initialized by 1
Step 2 :  Controllers of compiler now check the condition if i<=3 then it will come to the body of loop then it will print value of "i “  i.e.  1 and then controllers will come to the part of increment and will increase the value of “i” . Here i++ means i=i+1 . We can also use i=i+5 or i=i*2 or whatever we want.
Step 3 :  Now the value of i = 1+1= 2 and it will check the condition that i<=3
Step 4 :  Condition is true again and it will print the value of “i” i.e. 2 and it will now go to the increment part again and increase the value of “i” and again check the condition.
Step 5 :  3<=3  the condition is again true and it will print the value of   “i”  i.e.  3 and then it will again increase the value of “i”
Step 6 :  4<=3 the condition is false now and the loop will terminate.
Nested for loop
for ( initialization  ;  test_condition;   increment/decrement  )
{
for (  initialization ;  test_condition;  increment/decrement )
  {
      //body_of_loop
  }
//statements;
}
Try it :
1.
for ( i=0 ;  ;  i++ )
{
  printf (" Hello ");
  if ( i > 4)
   break;
}
2.
for ( i = 0 ;  ; )
{
  printf (" Hello " );
  i++;
  if(i>4)
  break;
}
3.
for ( ;  ;  )
{
  printf (" Hello");
}

While loop
It is exit control loop.
Syntax:
while ( test_condition )
{
  body of loop;
}
How it is used:
initialization;
while ( test_condition )
{
   body of loop;
   increment/decrement/other_change;
}
Try it
1.
while ( 0 )
{
   printf ( "Hello World ");
}
2.
while ( 1 )
{
    printf ( "Hello World " );
}

Do While loop
Syntax:
do
{
   body of loop;
} while ( test_condition ) ;
Note :  Semicolon must be there after while (   test _condition )
Array
It is the ability to use a single variable to represent a collection of items and to refer an item by using variable name and it’s index.
Declaration of 1-D Array:
data_type  variable_name[ size ] ; 
Example : int arr [10] ;
Initialization of 1-D Array
data_type  variable_name [size] = { value_1, value_2...,value_size };
Example : int arr [3] = { 1, 2, 3} ;
int arr [ ]  = { 1,2,3 };  // a[0]=1 , a[1]=2 , a[2]=3
char name [ ] = { ‘S’,’A’,’N’,’J’,’A’,’Y’,’’};
char name[ ] = “Sanjay Sharma”;
int arr [4] = { 1,2 }; // partially initialization , remaining initialized by 0 for int
char name [10 ] = { ‘S’,’N’,’J’,’’}; //size is 10 but 4 are initialized. remaining are NULL for char
Declaration of 2-D Array
data_type   variable_name [row_size ] [column_size ];
Example: int arr[4][4];
Initialization of 2-D Array
Example: int arr[2][2] = {1,2,3,4};
int arr[2][2]= { { 1,2 } ,{ 3, 4} };
Row
Col
1th
2th
0th
1
2
1th
3
4
int num [ ][ 2 ] = { 1,2,3,4 }; // It is correct
int num [2][ ] = { 1,2,3,4 }; // It is not correct

Character Array or String
Initializing and Declaring String
char string [10] ;
char name [ ] = { ‘S’,’A’,’N’,’J’,’A’,’Y’,’’};
char name[ ] = “Sanjay Sharma”;
Note: 
- If we have two variables char array type means string char s1[10] and char s2[10] we cannot copy these char type array directly as s1=s2;
-  is null character. It should be last element of character type array because it tells the compile that the string has come to it’s end because in C Language there is no array boundation.
Reading String From User
scanf (“%s”,string);
Note: scanf function terminates the input when input is whitespace
Example: 
if user entered a name SANJAY SHARMA
and we print it using printf (“%s”,string) then SANJAY will be printed.
The solution is scanf (“%[^ ]”,string); here [^ ]tells the compiler to do not terminate the input till new line ( ) entered.
Other solution is gets function which can get a string with white space from user. For using gets() we have to include string.h header file.
Exmaple: gets (string);
Call by value vs Call by reference
Call by value: This method copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
Call by reference: This method copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. This means that changes made to the parameter affect the argument.
Types of Function
1. No argument No return type
void printdata ( )
{
printf (“ Hello ”);
}
2. With Argument No Return Value
void printdata (int i)
{
printf (“%d”,i);
}
3. No Argument With Return Value
int checkdata ( )
{
return 2;
}
4. Argument With Return Value
int sendvalue( int i)
{
return i;
}

Recursion:
It is the process of calling a function by itself , until some specified condition is satisfied. It is used for repetitive computation ( like finding factorial of a number) in which each action is stated in term of previous result.
return type Function ()
{
//body
Function()
}
Example:
#include<stdio.h> long int factorial(int n); void main() { int n; long int m; scanf("%d",&n); m=factorial(n); printf(" factorial is %d", m); } long int factorial(int n) { if (n<=1) return(1); else return (n*factorial(n-1)); }
Structure
Structure is user defined data type, which can store the different data type variable together
Syntax:
struct [structure tag]
{
   member definition;
   member definition;
...
} variables_name;
Example
struct book
{
  char  name[50] ;
  char  author[50] ;
  int  id ;
} b ;

Union
A union is a user defined data type that enables to store different data types in the same memory location. We can define a union with many members,
but only one member can contain a value at any given time.
The memory required to store a union variable is the memory required for largest element of an union
Syntax:
union [union tag]
{
member definition ;
member definition ;
...
} variables_name ;
Example
union book
{
  char  name[50] ;
  char  author[50] ;
  int  id ;
} b ;
Difference between Structure and Union
Structure
Union
1.The keyword  struct is used to define a structure
1. The keyword union is used to define a union.
2. When a variable is associated with a structure, the compiler allocates the memory for each member. The size of structure is greater than or equal to the sum of  sizes of its members. The smaller members may end with unused slack bytes.
2. When a variable is associated with a union, the  compiler allocates the  memory by considering the size of the largest memory. So, size of union is equal to the size of largest member.
3. Each member within a structure is assigned unique storage area of location.
3. Memory allocated is shared by individual members of union.
4. The address of each member will be in ascending order This indicates that memory for each member will start at different offset values.
4. The address is same for all the members of a union. This indicates that every member begins at the same offset value.
5 Altering the value of a member will not affect other members of the structure.
5. Altering the value of any of the member will alter other member values.
6. Individual member can be accessed at a time
6. Only one member can be accessed at a time.
7. Several members of a structure can initialize at once.
7. Only the first member of a union can be initialized.
Pointer
Pointer is a user defined data type which creates special types of variables which can hold the address of primitive data type
like char, int, float, double or user defined data type like function, pointer etc. or derived data type like array, structure, union, enum.
Pointers are used in C program to access the memory and manipulate the address
Declaration of Pointer
Dereference operator(*) are used to identify an operator as a pointer.
Syntax:
data_type  * pointer_variable_name;
Example:  int  *ptr;
Explanation :
int a=5;
int  *ptr;
ptr=&a;
ptr is a pointer which is storing the address of “a” variable.
Pointer to Pointer
int  *ptr1;
int  **ptr2;
ptr1=&a;
ptr2=&pt1;
Notes:
* is known as indirection operator which gives content of any variable.& is known as reference operator which gives address where variable has stored in memory.* and & operators always cancel to each other i.e. *&p=pBut it is not right to write: &*p=p.The value of null pointer is 0.If pointer is assigned to NULL, it means it is pointing to nothing.
Generic pointer
void pointer in c is known as generic pointer. Literal meaning of generic pointer is a pointer which can point type of data.
Example:  void  *ptr;
#include<stdio.h> int main() { char c='A'; int i=4; void *p; char *q=&c; int *r=&i; p=q; printf("%c",*(char *)p); p=r; printf("%d",*(int *)p); return 0; }
Wild pointer:
A pointer in c which has not been initialized is known as wild pointer.
Example: #include<stdio.h> int main() { int *ptr; printf("%u ",ptr); printf("%d",*ptr); return 0; } Output: Any address Garbage value
Here ptr is wild pointer because it has not been initialized.
Note :  There is difference between the NULL pointer and wild pointer. Null pointer points the base address of segment while
wild pointer doesn’t point any specific memory location.
Dangling pointer:
If any pointer is pointing the memory address of any variable but variable has deleted from that memory location while pointer
is still pointing such memory location. Such pointer is known as dangling pointer and this problem is known as dangling pointer
problem. In other word we can say a pointer whose pointing object has been deleted is called dangling pointer.
#include<stdio.h> int *callme(); void main() { int *ptr; ptr=callme(); fflush(stdin); printf("%d",*ptr); } int * callme() { int x=5; ++x; return &x; }
Output: Garbage value
Note: In some compiler you may get warning message returning address of local variable or temporary
Explanation: Variable x is local variable. Its scope and lifetime is within the function call hence after returning address of x variable
x became dead and pointer is still pointing ptr is still pointing to that location.
Solution of this problemMake the variable x is as static variable.
#include<stdio.h>
int *callme();
void main(){
int *ptr;
ptr = callme();
fflush(stdin);
printf("%d",*ptr);
}
int * call(){
static int x=5;
++x;
return &x;
}
Output: 6

NULL pointer:
Literal meaning of NULL pointer is a pointer which is pointing to nothing. NULL pointer points the base address of segment.
NULL is macro constant which has been defined in the heard file stdio.h, alloc.h, mem.h, stddef.h and stdlib.h as
#define NULL 0
Examples of NULL pointer:
1. int  *ptr=(char *)0;
2. float  *ptr=(float *)0;
3. char  *ptr=(char *)0;
4. double  *ptr=(double *)0;
5. char  *ptr=’’;
6. int  *ptr=NULL;
Example:
#include <stdio.h> int main() { if(!NULL) printf("In if part"); else printf("In else part"); return 0; } Output: In if part
Explanation:
!NULL = !0 = 1
In if condition any non zero number mean true.
Structure
Structure is user defined data type, which can store the different data type variable together
Syntax:
struct [structure tag]
{
   member definition;
   member definition;
...
} variables_name;
Example
struct book
{
  char  name[50] ;
  char  author[50] ;
  int  id ;
} b ;

Union
A union is a user defined data type that enables to store different data types in the same memory location. We can define a union with many members,
but only one member can contain a value at any given time.
The memory required to store a union variable is the memory required for largest element of an union
Syntax:
union [union tag]
{
member definition ;
member definition ;
...
} variables_name ;
Example
union book
{
  char  name[50] ;
  char  author[50] ;
  int  id ;
} b ;
Difference between Structure and Union
Structure
Union
1.The keyword  struct is used to define a structure
1. The keyword union is used to define a union.
2. When a variable is associated with a structure, the compiler allocates the memory for each member. The size of structure is greater than or equal to the sum of  sizes of its members. The smaller members may end with unused slack bytes.
2. When a variable is associated with a union, the  compiler allocates the  memory by considering the size of the largest memory. So, size of union is equal to the size of largest member.
3. Each member within a structure is assigned unique storage area of location.
3. Memory allocated is shared by individual members of union.
4. The address of each member will be in ascending order This indicates that memory for each member will start at different offset values.
4. The address is same for all the members of a union. This indicates that every member begins at the same offset value.
5 Altering the value of a member will not affect other members of the structure.
5. Altering the value of any of the member will alter other member values.
6. Individual member can be accessed at a time
6. Only one member can be accessed at a time.
7. Several members of a structure can initialize at once.
7. Only the first member of a union can be initialized.
Pointer
Pointer is a user defined data type which creates special types of variables which can hold the address of primitive data type
like char, int, float, double or user defined data type like function, pointer etc. or derived data type like array, structure, union, enum.
Pointers are used in C program to access the memory and manipulate the address
Declaration of Pointer
Dereference operator(*) are used to identify an operator as a pointer.
Syntax:
data_type  * pointer_variable_name;
Example:  int  *ptr;
Explanation :
int a=5;
int  *ptr;
ptr=&a;
ptr is a pointer which is storing the address of “a” variable.
Pointer to Pointer
int  *ptr1;
int  **ptr2;
ptr1=&a;
ptr2=&pt1;
Notes:
* is known as indirection operator which gives content of any variable.& is known as reference operator which gives address where variable has stored in memory.* and & operators always cancel to each other i.e. *&p=pBut it is not right to write: &*p=p.The value of null pointer is 0.If pointer is assigned to NULL, it means it is pointing to nothing.
Generic pointer
void pointer in c is known as generic pointer. Literal meaning of generic pointer is a pointer which can point type of data.
Example:  void  *ptr;
#include<stdio.h> int main() { char c='A'; int i=4; void *p; char *q=&c; int *r=&i; p=q; printf("%c",*(char *)p); p=r; printf("%d",*(int *)p); return 0; }
Wild pointer:
A pointer in c which has not been initialized is known as wild pointer.
Example: #include<stdio.h> int main() { int *ptr; printf("%u ",ptr); printf("%d",*ptr); return 0; } Output: Any address Garbage value
Here ptr is wild pointer because it has not been initialized.
Note :  There is difference between the NULL pointer and wild pointer. Null pointer points the base address of segment while
wild pointer doesn’t point any specific memory location.
Dangling pointer:
If any pointer is pointing the memory address of any variable but variable has deleted from that memory location while pointer
is still pointing such memory location. Such pointer is known as dangling pointer and this problem is known as dangling pointer
problem. In other word we can say a pointer whose pointing object has been deleted is called dangling pointer.
#include<stdio.h> int *callme(); void main() { int *ptr; ptr=callme(); fflush(stdin); printf("%d",*ptr); } int * callme() { int x=5; ++x; return &x; }
Output: Garbage value
Note: In some compiler you may get warning message returning address of local variable or temporary
Explanation: Variable x is local variable. Its scope and lifetime is within the function call hence after returning address of x variable
x became dead and pointer is still pointing ptr is still pointing to that location.
Solution of this problemMake the variable x is as static variable.
#include<stdio.h>
int *callme();
void main(){
int *ptr;
ptr = callme();
fflush(stdin);
printf("%d",*ptr);
}
int * call(){
static int x=5;
++x;
return &x;
}
Output: 6

NULL pointer:
Literal meaning of NULL pointer is a pointer which is pointing to nothing. NULL pointer points the base address of segment.
NULL is macro constant which has been defined in the heard file stdio.h, alloc.h, mem.h, stddef.h and stdlib.h as
#define NULL 0
Examples of NULL pointer:
1. int  *ptr=(char *)0;
2. float  *ptr=(float *)0;
3. char  *ptr=(char *)0;
4. double  *ptr=(double *)0;
5. char  *ptr=’’;
6. int  *ptr=NULL;
Example:
#include <stdio.h> int main() { if(!NULL) printf("In if part"); else printf("In else part"); return 0; } Output: In if part
Explanation:
!NULL = !0 = 1
In if condition any non zero number mean true.
Dynamic Memory Allocation
Allocate the memory at run time is called Dynamic memory allocation.
Although, C language inherently does not has any technique to allocated memory dynamically, there are 4 library functions under "stdlib.h" for dynamic memory allocation.
malloc () :  Allocates requested size of bytes and returns a pointer first byte of allocated space
calloc():  Allocates space for an array elements, initializes to zero and then returns a pointer to memory
free ():  free or dellocate the previously allocated space
realloc () :  Reallocate or change the size of previously allocated space
/*read n numbers and find their sum*/ #include<stdio.h> void main() { int *x, n, i, sum=0; printf(" Enter number of numbers"); scanf("%d", &n); x=(int *)malloc(n * sizeof(int)); for(i=1;i<=n,++i) { scanf("%d", x+i); sum +=*(x+i); } printf(" The sum is %d ", sum); }
File Handling
Data Files are used to store data on the memory device permanently and to access whenever is required. There are two types of data files
1. Stream Oriented data files    : Stream oriented data files are either text files or unformatted files.
2. System Oriented data files  :  System oriented data files are more closely related to computer’s operating system and more complicated to work with.
 Opening and Closing data files
The first step is to create a buffer area where information is stored temporarily before passing to computer memory. It is done by writing.
FILE *fp;
- Here fp is the pointer variable  to indicate the beginning of the buffer area and called stream pointer
- The next step is to open a data file specifying the type or mode i.e. read only file , write only file , read /write file. This is done by using the library function fopen.
The syntax is
fp = fopen( filename , mode ) ;
the mode can be--
‘r’ ( to open an existing file for reading only)‘w’ ( to open a new file for writing only. If file with filename exists, it will be destroyed and a new file is created in its place)‘a’ ( to open an existing file for appending. If the file name does not exist a new file with that file name will be created)‘r+’ ( to open an existing file for both reading and writing)‘w+’ ( to open a new  file for reading and writing. If the file exists with that name, it will be destroyed and a new one will be created with that name)‘a+’ ( to open an existing file for reading and writing. If the file does not exist a new file will be created).
For writing formatted data to a file we use the function fprintf.
The syntax is fprintf( fp,”conversion string”, value ); 
Example to write the name “Sanjay” to the file named ‘st.dat’
FILE *fp; 
fp=fopen("st.dat","w"); 
fprintf(fp,”%[^ ]”,”Sanjay”);
The last step is to close the file after the desired manipulation. This is done by the library function fclose. Syntax is:
fclose(fp);
functions:
fclose (ptr) ;
fclose( ) function returns zero on success, or EOF if there is an error in closing the file.
Reading from a File
Once the file has been opened for reading using fopen( ), as we have seen, the file’s contents are brought into buffer and a pointer is set up that points to the first character in the buffer.
To read the file’s contents from memory there exists a function called fgetc ( ). This can be used in our program as-
ch = fgetc ( fp ) ;
The fgetc ( ) function reads a character from the input file referenced by fp.
str=fgets( ) it allows to read a string from a stream.
fscanf (FILE *fp, const char *format, ...)
function to read strings from a file but it stops reading after the first space character encounters.
example: fscanf(fp,"%s",str)
Writing a file
fputc ( argument_char , fp ) ;
fputc() writes the character value of the argument to the output stream referenced by ptr.
fputs( argument_string, fp );
fputs() writes the string in argument to the output stream referenced by ptr.
Share:

Total Pageviews

Sponsor

Sponsor

ad300

Blog Archive