1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
koban [17]
2 years ago
12

Write a c program to print all possible marking schemes of 15 questions each with 3.

Computers and Technology
1 answer:
andrey2020 [161]2 years ago
3 0

Answer:

#include <math.h>

#include <stdio.h>

#include <string.h>

#define BASE 3

#define NRQUESTIONS 15

void toABC(int n, char* buf, int base, int size) {

   memset(buf, 'A', size);

   buf[size] = 0;

   while (n && size) {

       buf[--size] = 'A' + (n % base);

       n /= base;

   }    

}

int main()

{

   char buf[16];

   for (int i = 0; i < pow(BASE, NRQUESTIONS); i++) {

       toABC(i, buf, BASE, NRQUESTIONS);

       printf("%s\n", buf);

   }

}

Explanation:

Assuming 3 is the number of possible answers to choose from for each question.

I tackled this by having an integer counter enumerate all values from 0 to 3^15, and then convert each integer to a base-3 representation, using ABC in stead of 012.

You might be interested in
The decimal equivalent of the product of 1011 and 1100 is
faltersainse [42]

Answer:

132

Explanation:

We convert each number to base 10 (decimal) and multiply.

So 1011₂ = 1 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰

= 1 × 8 + 0 × 4 + 1 × 2 + 1 × 1

= 8 + 0 + 2 + 1

= 11₁₀

1100₂ = 1 × 2³ + 1 × 2² + 0 × 2¹ + 0 × 2⁰

= 1 × 8 + 1 × 4 + 0 × 2 + 0 × 1

= 8 + 4 + 0 + 0

= 12₁₀

So, 1011₂ × 1100₂ = 11₁₀ × 12₁₀ = 132₁₀

So, the decimal equivalent of the product of 1011 and 1100 is 132

3 0
2 years ago
The function below takes one parameter: an integer (begin). Complete the function so that it prints the numbers starting at begi
arlik [135]

Answer:

Program is in C++

Explanation:

C++ Code

1) By using For Loop

void forLoopFunction(int value){

for(int start=value; start>0; start--){

 cout<<start<<endl;

}

}

Explanation

Start for loop by assigning the loop variable to parameter value and condition will be that loop variable will be greater then 0 and at the end decrements the loop variable.

2) By usin WhileLoop

void whileLoopFunction(int value){

 while(value>0){

 cout<<value<<endl;

 value--;

 }

}

Explanation

In while loop first add the condition as variable must be greater then 0 and then print the value with endl sign to send the cursor to next line and at the end of the loop decrements the variable.

8 0
2 years ago
A vending machine that serves coffee pours a varying
babunello [35]
Is that the whole question? or
8 0
2 years ago
Output values below an amount
valina [46]

Answer:

Explanation:

The following code is written in Python and it is a function called filter, which takes in the requested inputs. It then places the threshold in its own variable and pops it out of the array of inputs. Then it loops through the array comparing each element with the threshold and printing out all of the ones that are less than or equal to the threshold.

def filter():

   num_of_elements = input("Enter a number: ")

   count = 0

   arr_of_nums = []

   while count <= int(num_of_elements):

       arr_of_nums.append(input("Enter a number: "))

       count += 1

   threshold = arr_of_nums[-1]

   arr_of_nums.pop(-1)

   print(threshold)

   for element in arr_of_nums:

       if int(element) < int(threshold):

           print(element)

       else:

           continue

7 0
2 years ago
For questions 19 - 21, assume that Student, Employee and Retired are all subclasses of Person, and all four classes have differe
Helga [31]

Answer:

Person

Explanation:

At

Person p = new Person(...);

int m1 = p.getMoney( ); // assignment 1

Person class which is base class for all sub class (Student, Employee and Retired ) creates an object which referenced is stored in p variable, and  getMoney()  is method which refereed Person's getMoney() method, so Person is the answer of above question

6 0
3 years ago
Other questions:
  • What are the purpose of Keyframes,
    11·1 answer
  • PLEASE HURRY
    6·1 answer
  • Is it okay to leave your car running while parked?
    15·1 answer
  • In several languages, the visual development environment is known by the acronym ____.
    12·1 answer
  • Draw a logic circuit for the function F = (A + B)(B + C)(A + C), using NOR gates only. ​
    9·1 answer
  • In a folder hierarchy, the top level is referred to as which of the following?
    7·1 answer
  • Henry conducted a survey on an ad done by his company. In the survey, he asked people to evaluate the ad and state whether they
    8·1 answer
  • A term to describe articles that can be displayed in their entirety,as opposed to abstract and references only
    11·1 answer
  • Which of the following is an example of group dynamics?
    8·1 answer
  • Why is it good to be a computer programmer?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!