Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Tuesday, February 17, 2015

Explain Basic Structure of C Programs

Explain Basic Structure of C Programs?

Documentation Section

This section consists of comment lines which include the name of programmer, the author and other details like time and date of writing the program. Documentation section helps anyone to get an overview of the program.


Link Section

The link section consists of the header files of the functions that are used in the program. It provides instructions to the complier to link functions from the system library.

Also Read: List of all useful Turbo C++ keyboard shortcuts
Also Read: How to create your own Header Files in C/C++?


Definition Section

All the symbolic constants are written in definition section. Macros are known as symbolic constants.


Global Declaration Section

The global variables that can be used anywhere in the program are declared in global declaration section. This section also declares the user defined functions.


main() Function Section

It is necessary have one main() function section in every C program. This section contains two parts, declaration and executable part. The declaration part declares all the variables that are used in executable part. These two parts must be written in between the opening and closing braces. Each statement in the declaration and executable part must end with a semicolon (;). The execution of program starts at opening braces and ends at closing braces.

Also Read: What are advantages and disadvantages of C language?
Also Read: How to Write and Run C/C++ Programs in Ubuntu (Linux)


Subprogram Section

The subprogram section contains all the user defined functions that are used to perform a specific task. These user defined functions are called in the main() function.
Read more »

Monday, February 16, 2015

Sunday, February 15, 2015

Tuesday, February 3, 2015

Basic Android application with Google maps v2 API

In this post I will illustrate how to make settings for Google maps v2 API in Android Manifest.

1. Create an Android project.
  • Use API level 11 or above for minimum required SDK.
  • Give the same package name which you gave when you are obtaining the API key from Google.
  • Keep other settings as default 
 2. We need to make some changes Android Manifest.xml
  • Open the Manifest.xml and add following permissions as a child of the <manifest> element
    





     
  • Google Maps Android API uses OpenGL ES version 2 to render the map there for we need to define the feature in Manifest file. Add following lines as a child of the <manifest> element.

  • Add the API key by adding following lines as a child of the <application> element, inserting it just before the closing tag </application> 
 
  • Change the android:value="AIzaSyARrx5gAxtNJCHUBvwyIz4uZEFAm3R60kI" with the API key given by Google
  • Finally your Manifest.xml should be like this.


























3. To use Google maps in our Android project we have to add Google play services lib project.
  • First check whether Google Play services are installed.
  • To do that open Android SDK manager expand the Extras.
  • Check the status of  Google Play Services is installed if it is not installed you have to install it first.
 
  • Then to import the Google play services lib project in to the work space, in Eclipse select
    File >> Import >> Android >> Existing Android Code Into Workspace
  • Click Next and select the Root Directory, browse to the google-play-services_lib. In my case it is in C:Androidadt-bundle-windows-x86-20130219sdkextrasgooglegoogle_play_serviceslibprojectgoogle-play-services_lib
  • Most of the time you can find it under the sdkextrasgooglegoogle_play_serviceslibproject directory.  
  • Select the Copy project into workspace and click Finish.

4. The next step is to add the lib project into the our newly created projects references.
  • Right click on the project select Properties >> Android and then click on Add button under Library
  •  In the project selection window select google-play-services_lib project and then click  OK
  •  Then under the libraries there should be the google-play-services_lib project with a green tick.

 5. As the final step we have to add the fragment for the map in to xml layout.
  • Open the res >> layout and activity xml lay out file and copy following code to create the fragment.

  • For this simplest example dont need to do any change for the Activities java file, keep it as it is.
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

Now you can run the project. If you are running this on Android emulator you have to do certain installations on AVD I will describe that in my next post.


Read more »