In: Computer Science
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)
| 
 . . . . . . . .# . . . . . . . # . . . . . . . # . . . . . . . # . . . . . . . # . . . . . . . # . . . . . . . # . . . . . . . # . . . . . . . # . . . . . . . .  | 
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");
        }
}