Question

In: Computer Science

C Programming Language Title : Making wave In Physics, Mathematics, and related fields, a wave is...

C Programming Language

Title : Making wave

In Physics, Mathematics, and related fields, a wave is a disturbance of one of more fields such that the field values oscillate repeatedly about a stable equilibrium value. Waves are usually represented using mathematical functions of the form F (x, t), where x = position and t = time. Your task is to write a program that will visualize a given wave for exactly N seconds. You do not need to worry about evaluating the mathematical function F (x, t), as the wave will be given to you using its sample representation. The sample representation of a wave is a series of points that represents the result of the F(x, t) function at each given t. In this problem, you will be given N samples (one for each second) represented by N integers Yi , which represents the vertical coordinate of the wave at time i

Format Input

The first line contains a single integer N, the number of seconds you need to visualize the wave for. The next line contains N integers Y1,Y2,…,Yn as described in the problem statement.

Format Output

Visualize the wave given in the input. The wave should be visualized using a rectangle N characters long and 9 characters tall. Coordinates where the wave is currently in should be represented using the # (hash) character whilst empty coordinates should be represented using the . (dot) character. For clarity, please refer to the sample output section.

Constraints

• 1 ≤ N ≤ 10^4

• 1 ≤ Yi ≤ 9

Sample Input 1 (standard input)

9

1 2 3 4 5 6 7 8 9

Sample output 1 (standard output)

. . . . . . . .#

. . . . . . . # .

. . . . . . # . .

. . . . . # . . .

. . . . # . . . .

. . . # . . . . .

. . # . . . . . .

. # . . . . . . .

# . . . . . . . .

Solutions

Expert Solution

I have implemented the Program to print the Wave  per the given description.

Please find the following Code Screenshot, Output, and Code.

ANY CLARIFICATIONS REQUIRED LEAVE A COMMENT

1.CODE SCREENSHOT :

2.OUTPUT :

3.CODE :

#include <stdio.h>
#include <stdlib.h>
int main(){
        int n,i,j,t,k;
        //to read the value of 'N'
        printf("Enter N : ");
        scanf("%d",&n);
        //create a dynamic array of char
        char *arr[n],ch; 
    for (i=0; i<n; i++) 
         arr[i]=(char*)malloc(n*sizeof(char));
         //Initlize the array with .
        for(i=0;i<n;i++)
                for(j=0;j<n;j++)
                        arr[i][j]='.';
        //read the coordinate position
        printf("Enter %d Cordinate position : ",n);
        
        for(i=0,k=n;i<n;i++)
        {
                scanf("%d%c",&t,&ch);
                //Place the '#' sign at the position
                arr[k-t][i]='#';

        }
        //print the wave from the array
        printf("The Wave is : \n");
        for(i=0;i<n;i++){
                for(j=0;j<n;j++)
                {
                        printf(" %c",arr[i][j]);
                }
                printf("\n");
        }
}

Related Solutions

In Physics, Mathematics, and related fields, a wave is a disturbance of one of more fields...
In Physics, Mathematics, and related fields, a wave is a disturbance of one of more fields such that the field values oscillate repeatedly about a stable equilibrium value. Waves are usually represented using mathematical functions of the form F (x, t), where x = position and t = time. Your task is to write a program that will visualize a given wave for exactly N seconds. You do not need to worry about evaluating the mathematical function F(x,t), as the...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing chess himself to practice his abilities. The chess that Jojo played was N × N. When Jojo was practicing, Jojo suddenly saw a position on his chessboard that was so interesting that Jojo tried to put the pieces of Rook, Bishop and Knight in that position. Every time he put a piece, Jojo counts how many other pieces on the chessboard can be captured...
Programming Language: C# Person Class Fields - password : string Properties + «C# property, setter private»...
Programming Language: C# Person Class Fields - password : string Properties + «C# property, setter private» IsAuthenticated : bool + «C# property, setter absent» SIN : string + «C# property, setter absent» Name : string Methods + «Constructor» Person(name : string, sin : string) + Login(password : string) : void + Logout() : void + ToString() : string Transaction Class Properties + «C# property, setter absent » AccountNumber : string + «C# property, setter absent» Amount : double + «C#...
C Programming Language Problem Title : Take Three Jojo just graduated and moved up to grade...
C Programming Language Problem Title : Take Three Jojo just graduated and moved up to grade 4. Today is his first day in 4th grade. Unfortunately, the lessons are held online because of the pandemic. So that the quality of learning remains good, Jojo's teacher gives a hard task for 4th grader. After the 4th graders finished their first task which is prime factorization. Jojo's teacher set up a game for the stundets. The game is very simple. Given N...
C Programming Language Problem Title : 4th Grade Jojo just graduated and moved up to grade...
C Programming Language Problem Title : 4th Grade Jojo just graduated and moved up to grade 4. Today is his first day in 4th grade. Unfortunately, the lessons are held online because of pandemic. So that the quality of learning remains good, Jojo’s teacher gives a hard task for 4th grader. The first task is to find the prime factorization of a number. Prime number is a natural number greater than 1 that is not a product of two smaller...
GPA calculator in C language To understand the value of records in a programming language, write...
GPA calculator in C language To understand the value of records in a programming language, write a small program in a C-based language that uses an array of structs that store student information, including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,” etc.). Note:Code and Output Screenshots
in the c programming language input is given in the form The input will be of...
in the c programming language input is given in the form The input will be of the form [number of terms] [coefficient k] [exponent k] … [coefficient 1] [exponent 1] eg. 5 ─3 7 824 5 ─7 3 1 2 9 0 in this there are 5 terms with -3x^7 being the highest /* Initialize all coefficients and exponents of the polynomial to zero. */ void init_polynom( int coeff[ ], int exp[ ] ) { /* ADD YOUR CODE HERE...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
Programming in C language (not C++) Write a runction derinition for a function called SmallNumbers that...
Programming in C language (not C++) Write a runction derinition for a function called SmallNumbers that will use a while loop. The function will prompt the user to enter integers ine by one, until the user enters a negative value to stop. The function will display any integer that is less than 25. Declare and initialize any variables needed. The function takes no arguments and has a void return type.
In C programming language, write the program "3x3" in size, calculating the matrix "c = a...
In C programming language, write the program "3x3" in size, calculating the matrix "c = a * b" by reading the a and b matrices from the outside and writing on the screen?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT