C Program Coin Change

sudhir sharma
Updated on 22-Nov-2019 09:28:52

2K+ Views

In this problem, we are given a value n, and we want to make change of n rupees, and we have n number of coins each of value ranging from 1 to m. And we have to return the total number of ways in which make the sum.ExampleInput : N = 6 ; coins = {1, 2, 4}. Output : 6 Explanation : The total combination that make the sum of 6 is : {1, 1, 1, 1, 1, 1} ; {1, 1, 1, 1, 2}; {1, 1, 2, 2}; {1, 1, 4}; {2, 2, 2} ; {2, 4}.Example#include ... Read More

Binomial Coefficient in C++

sudhir sharma
Updated on 22-Nov-2019 09:22:57

5K+ Views

Binomial coefficient denoted as c(n, k) or ncr is defined as coefficient of xk in the binomial expansion of (1+X)n.The Binomial coefficient also gives the value of the number of ways in which k items are chosen from among n objects i.e. k-combinations of n-element set. The order of selection of items not considered.Here, we are given two parameters n and k and we have to return the value of binomial coefficient nck .ExampleInput : n = 8 and k = 3 Output : 56There can be multiple solutions to this problem, General SolutionThere is a method to calculate the value ... Read More

Binary Search for Rational Numbers without using floating point arithmetic in C program

sudhir sharma
Updated on 22-Nov-2019 09:16:45

149 Views

In this problem, we are given a sorted array of rational numbers. and we have to search the given element using binary search algorithm for this rational number array without using floating point arithmetic.A Rational number is number represented in the form p/q where both p and q are integers. For example, ⅔, ⅕.Binary search is searching technique that works by finding the middle of the array for finding the element.for finding the element using binary search from a sorted array of rational numbers, where floating point arithmetic are not allowed. We will compare the numerators and denominators to find ... Read More

How to pass an image from one activity another activity in Android?

Azhar
Updated on 22-Nov-2019 09:15:35

4K+ Views

This example demonstrates how to do I pass an image from one Activity in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    public void SendImage(View view) {   ... Read More

How to disable ScrollView Programmatically in Android?

Azhar
Updated on 22-Nov-2019 09:14:54

2K+ Views

This example demonstrates how to do I disable ScrollView programmatically in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                                                                                           ... Read More

How to check the system version of Android?

Azhar
Updated on 22-Nov-2019 09:14:14

182 Views

This example demonstrates how to do I check the system version in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Build; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = findViewById(R.id.textView);       double ... Read More

How to disable Home and other system buttons in Android?

Azhar
Updated on 22-Nov-2019 09:13:01

875 Views

This example demonstrates how to do I in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import java.util.Timer; import java.util.TimerTask; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    @Override    public void onWindowFocusChanged(boolean hasFocus) {       super.onWindowFocusChanged(hasFocus);   ... Read More

How to retrieve shared preferences of other application in Android?

Azhar
Updated on 22-Nov-2019 09:12:19

676 Views

This example demonstrates how to do I in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                     Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    EditText etName, etEmail;    SharedPreferences sharedPreferences;    public static final String myPreference = "myPref";    public static final ... Read More

How to get the distance between two geographic locations in Android?

Azhar
Updated on 22-Nov-2019 09:11:33

952 Views

This example demonstrates how do I get the distance between two geographic locations in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.location.Location; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = findViewById(R.id.textView);     ... Read More

How do I delete SharedPreferences data for my Android App?

Azhar
Updated on 22-Nov-2019 09:10:49

179 Views

This example demonstrates how do I delete SharedPreferences data for my android app.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             Step 3 − Add the following code to res/strings.xml    Sample    player_name    country_name Step 4 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView, tvAfterDelete; ... Read More

Advertisements