This is one program; include the following methods: Write a method called create
ID: 3535727 • Letter: T
Question
This is one program; include the following methods: Write a method called createArithmeticSeq that prompts the user to input 2 numbers, first and diff. The method then creates a 1-D array called A of 16 elements ordered in an arithmetic sequence. For example, if first = 21 and diff = 5, the arithmetic sequence is: Write a method called matricize that takes a 1-D array of 16 elements and a 2-D array of 4 rows and 4 columns as parameters. This method puts the elements of the 1-D array into the 2-D array. Use the 1-D array A created in part and B is a 2-D array, then after putting the elements of A into B, the array B is:Explanation / Answer
pls check the following code in c as per ur requirement
#include<stdio.h>
#include<conio.h>
void createAirthemeticSeq(void);
void matrisize(int []);
int main()
{
createAirthemeticSeq();
system("pause");
}
void createAirthemeticSeq()
{
int first,diff,i=0;
int A[16];
printf("enter the first no ");
scanf("%d",&first);
printf("enter the difference ");
scanf("%d",&diff);
A[0]=first;
for(i=1;i<16;i++)
A[i]=A[i-1]+diff;
printf("1D Array ");
for(i=0;i<16;i++)
printf("%d ",A[i]);
printf(" ");
matrisize(A);
}
void matrisize(int A[])
{
int B[4][4],i,j,k=0;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
B[i][j]=A[k++];
printf("2D Array ");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf("%d ",B[i][j]);
printf(" ");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.