Question
Asked Mar 24, 2020
26 views

c programming

<stdio.h>

<string.h>

1 dimentional  array strings

output:

type any word: handsome
New word: smoenahd

type any word: beautiful
New word: ubeiflatu

check_circle

Expert Answer

Step 1: Note

In the question, the detail about how to get the new output word is missing. The below program is provided to randomly shuffle the characters in the given input string.

Step 2: Program

A C program that randomly shuffle the characters of the given string is as follows,

File name: “main.c”

#include <stdio.h>

//Define the method to print he character in the array

void viewDeck(const char deck[], int size){

    int i;

    for(i = 0;i<size;i++){

       printf("%c",deck[i]);

    }

    printf("\n");

}

//Define the method to randomly shuffle the characters

void shuffle(char deck[], int size){

    int n1, n2, i;

    srand((unsigned)time(NULL));

    for(i = 0;i<size;i++){

        n1 = rand() % size;

        n2 = rand() % size;

        char ch = deck[n1];

        deck[n1] = deck[n2];

        deck[n2] = ch;

   }

}

//Define the main() method

int main() {

    unsigned char data2[]=" ";

    printf("type any word: ");

    scanf("%s",&data2);

    shuffle(data2, 10);

    printf("\nNew Word: ");

    viewDeck(data2, 10);

    return 0;

}

Step 3: Screenshot of program

Screenshot #1:

Computer Science homework question answer, step 3, image 1

Screenshot #2:

Computer Science homework question answer, step 3, image 2

...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: A function can return a pointer to a local variable in the function? Why?

A: Pointer: - It stores the address of another variable. It is declared by putting a “*” before the var...

question_answer

Q: Consider the following c++ enumerated data type.A. Declare a variable.B. Write a for loop to properl...

A: //include the required header files #include &lt;iostream&gt;   //use the std namespace using namesp...

question_answer

Q: In Python 3, construct a for loop that calculates the sum of all odd or all even numbers starting wi...

A: Program Approach – Prompt the user to enter the number ranging between 1 and 50. If the user provid...

question_answer

Q: Describe the different types of Semantics, when and how are they applied, what are the advantages or...

A: Semantics is one of linguistics ' major branches, concerned with the understanding and meaning of wo...

question_answer

Q: please reply fast write a Python program that asks the user to enter a non-negative number (float). ...

A: Following is the python program that takes input from the user a non-negative number and prints the ...

question_answer

Q: Write a Java program that will ask the user for a starting number, ending number, and a decrement nu...

A: Java program to display the number from in the decremental order the user given starting number to t...

question_answer

Q: The coding language is python   The code in there may or not be correct I was playing around with it...

A: PROGRAM: # The user in prompted for input and stored in userInput   userInput = str(input("Enter the...

question_answer

Q: Database normalization is a very important process in designing and organizing tables (relations) an...

A: Database Normalization is a comprehensive means of ensuring that a database configuration is appropr...

question_answer

Q: //1. Declare an array arr1 and initialize it to 1, 2, 3, 4, 5, 6, 7, 8, and 9//2. Declare another ar...

A: //definition of "Test" class public class Test {     //definition of main method     public static v...