diff --git a/Store_Display_Information_Using_Structure b/Store_Display_Information_Using_Structure new file mode 100644 index 0000000..2d4d6ac --- /dev/null +++ b/Store_Display_Information_Using_Structure @@ -0,0 +1,41 @@ +#include +using namespace std; + +struct student +{ + char name[50]; + int roll; + float marks; +} s[10]; + +int main() +{ + cout << "Enter information of students: " << endl; + + // storing information + for(int i = 0; i < 10; ++i) + { + s[i].roll = i+1; + cout << "For roll number" << s[i].roll << "," << endl; + + cout << "Enter name: "; + cin >> s[i].name; + + cout << "Enter marks: "; + cin >> s[i].marks; + + cout << endl; + } + + cout << "Displaying Information: " << endl; + + // Displaying information + for(int i = 0; i < 10; ++i) + { + cout << "\nRoll number: " << i+1 << endl; + cout << "Name: " << s[i].name << endl; + cout << "Marks: " << s[i].marks << endl; + } + + return 0; +} diff --git a/coin_change.cpp b/coin_change.cpp new file mode 100644 index 0000000..c11c020 --- /dev/null +++ b/coin_change.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + + +int minCoins(int coins[], int total_coins, int N) // Function to return the minimum // coins needed +{ + if (N == 0) // If we have a combination then + return 0; + + int result = INT_MAX; // Currently result is initialised as INT_MAX + + for (int i = 0; i < total_coins; i++) // run until availability of coins + { + if (coins[i] <= N) { // Add to the list of counting + int sub_res = 1 + minCoins(coins, total_coins, N - coins[i]); // add 1 due to the coin inclusion + // see if result can minimize + if (sub_res < result) + result = sub_res; + } + } + return result; +} + +int main() +{ + int coins[] = { 10, 25, 5 }; + int sum = 30; // the money to convert + int total_coins = 3; // total availability of coins + cout << "Minmum coins needed are " << minCoins(coins, total_coins, sum); +}