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
tigry1 [53]
3 years ago
9

Write the function setKthDigit(n, k, d) that takes three integers -- n, k, and d -- where n is a possibly-negative int, k is a n

on-negative int, and d is a non-negative single digit (between 0 and 9 inclusive). This function returns the number n with the kth digit replaced with d. Counting starts at 0 and goes right-to-left, so the 0th digit is the rightmost digit.
Computers and Technology
1 answer:
liq [111]3 years ago
6 0

Answer:

Explanation:

Let's do this in Python, first we need to convert the number into string in order to break it into a list of character, then we can replace the kth character with d. Finally we join all characters together, convert it to integer then output it

def setKthDigit(n, k, d):

n_string = str(n)

d_char = str(d)

n_char = [c for c in n_string]

n_char[k] = d_char

new_n_string = ''.join(n_char)

return int(new_n_string)

You might be interested in
If you could represent yourself with one object from your home what would it be ?
user100 [1]

Answer:

cross

bc im religous and stuff (0_0)

8 0
2 years ago
Read 2 more answers
Name any extension of MS word.
Svetradugi [14.3K]
Name any extension of MS word.

.doc
8 0
3 years ago
Read 2 more answers
Write a program that generates two 3x3 matrices, A and B, withrandom values in the range [1, 100] and calculates the expression½
Alex

Answer:

#include <bits/stdc++.h>

using namespace std;

int main() {

int A[3][3],B[3][3],res[3][3],i,j;

srand(time(0));//for seed.

for(i=0;i<3;i++)

{

   for(j=0;j<3;j++)

{

   int val=rand()%100+1;//generating random values in range 1 to 100.

   int val2=rand()%100+1;

   A[i][j]=val;

   B[i][j]=val2;

}

cout<<endl;

}

for(i=0;i<3;i++)

{

   for(j=0;j<3;j++)

   {

       res[i][j]=0.5*A[i][j]+3*B[i][j];//storing the result in matrix res.

   }

}

cout<<"Matrix A is"<<endl;

for(i=0;i<3;i++)

{

   for(j=0;j<3;j++)

   {

       cout<<A[i][j]<<" ";//printing matrix A..

   }

   cout<<endl;

}

cout<<"Matrix B is"<<endl;

for(i=0;i<3;i++)

{

   for(j=0;j<3;j++)

   {

       cout<<B[i][j]<<" ";//printing matrix B..

   }

   cout<<endl;

}

cout<<"The result is"<<endl;

for(i=0;i<3;i++)

{

   for(j=0;j<3;j++)

   {

       cout<<res[i][j]<<" ";//printing the result..

   }

   cout<<endl;

}

return 0;

}

Output:-

Matrix A is

13 95 83  

88 7 14  

24 22 100  

Matrix B is

11 13 95  

48 35 20  

68 100 18  

The result is

39.5 86.5 326.5  

188 108.5 67  

216 311 104  

Explanation:

I have created 2 matrices A and B and storing random numbers int the matrices A and B.Then after that storing the result in res matrix of type double to store decimal values also.Then printing the res matrix.

6 0
2 years ago
How can you achieve an effect like that shown in the image
Naily [24]
You can go into your bedroom on a dark night, then close your eyes, and press your face into the pillow. You will then see an exact copy of the image, in perfect detail.
8 0
3 years ago
Read 2 more answers
List 100 social media with functions​
olga55 [171]

Answer:

J

Explanation:

6 0
3 years ago
Other questions:
  • WHAT SHOULD YOU DO IF AN ONCOMING CAR AT NIGHT APPROACHES WITH ITS HIGH-BEAMS ON?
    6·1 answer
  • Interest rate risks would be most relevant to what purchase?
    7·2 answers
  • A user states that when they power on their computer, they receive a "Non-bootable drive" error. The user works with external st
    8·1 answer
  • In order to plan George’s birthday, his father gave him a list of people who attended his birthday for the last five years. What
    8·1 answer
  • A keyboard and touch screen are the most common of ________ devices. select one:
    11·1 answer
  • How often does colleges update the cost of attendance on their website?.
    13·1 answer
  • Write the line of Python code that calculates and prints the answer to the following arithmetic expressions.
    7·1 answer
  • Why optical disk is slower than magnetic disk.?​
    9·2 answers
  • How many 2/8 pound patties can she make from 7/8 of a pound of hamburger
    10·1 answer
  • swer from the options 1. How many basic input devices does a desktop computer have? a)2 b)3 c)1 d)4 2. The computer equipment wh
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!