Showing posts with label Application. Show all posts
Showing posts with label Application. Show all posts

Monday, September 5, 2016

Different variation of #define

1.
#include<stdio.h>
#define SQUARE(t) t*tvoid main()
{
      int n=8, Res;
     Res = 64/SQUARE(t);
     printf("%d",Res);
}
Result will be 64 . why?
because the statement Res=64/SQUARE(t); will be converted to  Res=64/8*8;
Res=64/8*8
     = 8*8=64.
Hence the preprocessor #define only substitute the statement not calculation.
Then what can I do , If I want to result as 1. The program should be
#include<stdio.h>
#define SQUARE(t) (t*t)void main()
{
      int n=8, Res;
     Res = 64/SQUARE(t);
     printf("%d",Res);
}
Now the result will be
Res=64/(8*8)
      =64/64 = 1
Again if program will be
#include<stdio.h>
#define SQUARE(t) (t*t)
void main()
{
      int n=8, Res;
     Res = 81/SQUARE(t+1);
     printf("%d",Res);
}
What will be the result, if you are thing about 1 then it is not right , But why? Now see
Res=81/SQUARE(t+1)
     = 81/(8+1*8+1)
     =81/(8+8+1)
     =81/17
      =4.76
=  4 (Because integer will display only integer part)
then what are the solutions? The solution will be
#include<stdio.h>
#define SQUARE(t) ((t)*(t))void main()
{
      int n=8, Res;
     Res = 81/SQUARE(t+1);
     printf("%d",Res);
}
2. Now guess what will be the result of
#include<stdio.h>
#define CUBE(t) t*t*t
void main()
{
      int n=5, Res;
     Res = 125/CUBE(t);
     printf("%d",Res);
}
???????????????????/
Your queries are always welcome.
3.
#include<stdio.h>
#define print(Num) printf("%d",Num);
int main()
{
    int Number=10;
    print(Number);
    return 1;
 }
It will display 10 , So Now you can print integer variable by own print command
4.


Sunday, August 28, 2016

Logical Components of an Android Mobile Application Development

Logical Components of an Android Mobile Application Development

 When you want to create a dynamic application then you have to require some important logical components of an Android application. There are four logical component of the Android Mobile Application Development:
1. Activity: Activity is one of the key logical component of the Android Mobile Application Development. It is the basis of User Interface of the app and makes the foundation of User Interface. User Interface contains visual elements , layout elements , resources and many more things.
Programmed component of the Used Interface which is programmed using java is an Activity and event handling. For example : Music is playing in background and in front you are using the browser.

2. Service: Service is another key component of an Android application. It always runs in the background and does not have a user interface. But UI is associated with it to interact with the service. In the music player, user need the UI to shuffle the songs or select the songs but for listening it not required to be in front of the mobile. User may use another app while listening the songs.

3. Broadcast Receiver: While you are using the mobile, there may be lots of announcement in your mobile related to low battery, download complete, incoming call, incoming SMS, availability of WI-FI Spot are initialed by the system. Some announcements are initiated by the app itself to let the other app understand. For Example: After completion of the download and is available of used.

4. Content Provider:  The data or content of the mobile app and is accessible across apps is the important aspect of mobile app development. However , due to security, any app required permission to access other app data . These data sharing after taking permission is done by using content provider. For example: for call a person whose detail is already saved in the contacts app, then contact app work as a content provider for calling , email and message app.
 

Video for the concept of Array and pointers

Example Program of Array and Pointers (Video)

https://www.youtube.com/watch?v=lT5D08ofRBQ

Some Important conceptual output based questions of Arrays and Pointers in C lnaguage

Some Important conceptual output based questions of Arrays and Pointers in C language 

1. 
void main()
{
   int Blog[]={1,2,3};
   printf("%d %d %d",Blog[1],Blog[2],Blog[3]);
}

Output: 2 3 0

Explanation: Here Blog[0],Blog[1] and Blog[2] will be initialized with 1,2 and 3 respectively. and rest are initialized with 0.

2.
void main()
{
   int Blog[]={33,44};
   printf("%x",Blog);
 }

Output: Base address of Blog

Explanation: The array name always holds the base address of an array. If we print *Blog then output will be the first value.

3.void main()
{
  int Blog[4]={22,33,44,55},*ptr,T;
  ptr=Blog;
  T=++(*ptr);
  printf("%d %d",*ptr,T);
 }

Ans: 23 23

Exlanation: *ptr points to the first element of an array Blog. After ++(*ptr) , the value 
of first element is increased by 1 that is 23 and also updated to the array. Hence the output will be 23 23.

4.
void main()
{
  int Blog[4]={22,33,44,55},*ptr,T;
  ptr=Blog;
  T=*(ptr++);
  printf("%d %d",*ptr,T);
 }

Ans: 33 22

Explanation: *ptr points to the first element of an array Blog. After *(ptr++), the pointer ptr points to next element that is second element of array but due to post increment the variable T contains the first element of an array Blog.

Sunday, August 21, 2016

String in Java

Strings in Java

1. int n;
char chr;
String st1=”Rakesh Roshan”;
n=st1.indexOf(‘e’);
chr=st1.charAt(5);

what will be the value of n and chr?

2. int n;
String str1=”Rakesh”;
String str2=”Roshan”;
n=str1.compareTo(st2);

what will be the value of n ?

Saturday, August 20, 2016

Android Mobile Application Development

Android Mobile Application development is very easy. Mobile Application Development can be done by any body who have a basic programming knowledge of Java, XML, HTML. The tools required to develop a Mobile Application are:
1. Eclipse or Android Studio
2. Android SDK
3. jdk 1.7 and above

In next post I will give you step by step procedure to develop first mobile application.