Write a C program, allow user to input elements.
Given a finite set of integers, find all the subsets with the sum of the elements greater than k.
#include <stdio.h>
//function to print the subset
void getSubset(int set[], int n, int r, int idx, int element[], int
i, int size)
{
if (idx == r)
{
int sum = 0;
for (int j = 0; j < r; j++)
{
sum = sum + element[j];
}
if(sum>size)
{
printf("{ ");
for (int j = 0; j < r;
j++)
{
printf("%d ",
element[j]);
}
printf("}");
printf("\n");
}
return;
}
if (i >= n)
return;
element[idx] = set[i];
getSubset(set, n, r, idx + 1, element, i + 1,
size);
getSubset(set, n, r, idx, element, i + 1, size);
}
//function to display the subset
void displaySubset(int set[], int n, int r, int size)
{
int element[r];
getSubset(set, n, r, 0, element, 0, size);
}
int main()
{
//variable declaration
int setSize, k;
//input the set size
printf("Enter the size of the set: ");
scanf("%d", &setSize);
int set[setSize];
//input the set element
printf("Enter the set elements: ");
for(int i=0; i<setSize; i++)
{
scanf("%d", &set[i]);
}
//input the maximum sum of the elements
printf("Enter the maximum sum of the elements: ");
scanf("%d", &k);
//display the subset
printf("The subsets are: \n");
for(int size=1; size<setSize; size++)
displaySubset(set, setSize, size, k);
return 0;
}
OUTPUT:

Write a C program, allow user to input elements. Given a finite set of integers, find...
Subset Sum-2 Write an algorithm (in comments) and specify the big O, and a C program to solve the problern below. Read the input for the set elements, the value of K from the user. Assume the size of the set is not bigger than 20. Subset Sum-3 Write an algorithm (in comments) and specify from the user. Assume the size of the set is not bigger than 20 1. Given a finite set of integers, is there a subset...
Write a MARIE program to allow the user to input eight integers (positive, negative, or zero) and then find the smallest and the largest and print each of these out. Please I need this program in MIPS language. ASSEMBLY language. Thank you
Write a (C program) having the following features: Scan two user input integers Output the sum of all the integers (including bounds) within this range
Write a c++ program to accept user input of a long string with spaces that ends with ā\nā, and then calculate the sum of all even numbers in the string. You may assume the input string is less than 1000 characters, and all numbers are integers.
EVERYTHING IN C# Write a program that includes a method that returns the sum of all the elements of an ArrayList of Integer Objects. Allow the user to enter the integers to be added to your ArrayList from the console (max of 10 integers). And also write a program that includes a method that returns the sum of all the elements of a Linked List of Integers. Allow the user to enter the integers to be added to your Linked...
Write a program that prompts the user to input three different integers from the keyboard, then prints the sum, the average, and the product. The screen dialogue should appear exactly as follows: Enter three different integers: 13 27 14 Sum is 54 Average is 18 Product is 4914 Please code in c program
write a java program that will perform the following. Given two finite sets, list all elements in the Cartesian product of these two sets. Given a finite set, list all elements of its power set.
c++ Write a program that will use vectors to allow the user to input as many values as desired, and pass that vector to a function to search for a number. The function returns the index of where the number is found or that it didn't find the number. Uses Vectors and searching.
Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.
Write a program that will create an array of ten integers, allow the user to enter those integers, and eventually search through the array based on index position: 1. Declare the array. You cannot assign elements to an array until it has first been created. 2. Next, run a for loop so that the user can enter an integer to save in each index position of the array. Since you this array holds ten elements , the index position starts...