新手c语言求教
1.Writetwoseparatevoidfunctions:onevoidfunctioncallit“initialized”andthesecondfunctio...
1. Write two separate void functions: one void functioncall it “initialized” and the second function call it “print”.
A.Inside your initialized void function, you will need to pass the list array andsize as a formal parameters. Within this functions body, you will need to initializea variable called count as intdatatype. Initialize the array so that the first 25 components are equal to thesquare of the index variables. The second 25 components are equal to three times the index variable. Thethird 25 components are equal to fourtimes the index variable. The last 25 components are equal to five times the index variable.
B.In regards to the print void function, you will need to pass the list array andsize as a formal parameters. Output the array so the 10 elements per line areprinted. This function requires you to create ten columns with set width of 5positions. Please use the appropriate commands and pre-processor library filesfor this alignment.
2. Write your function prototypes for the two functions.
3. Inside the main function, write a C++ programming thatdeclares an array alpha of 100components of type double, then callthe both the functions and pass the appropriate parameters.
得出的答案应该是这样的:
万分感激 展开
A.Inside your initialized void function, you will need to pass the list array andsize as a formal parameters. Within this functions body, you will need to initializea variable called count as intdatatype. Initialize the array so that the first 25 components are equal to thesquare of the index variables. The second 25 components are equal to three times the index variable. Thethird 25 components are equal to fourtimes the index variable. The last 25 components are equal to five times the index variable.
B.In regards to the print void function, you will need to pass the list array andsize as a formal parameters. Output the array so the 10 elements per line areprinted. This function requires you to create ten columns with set width of 5positions. Please use the appropriate commands and pre-processor library filesfor this alignment.
2. Write your function prototypes for the two functions.
3. Inside the main function, write a C++ programming thatdeclares an array alpha of 100components of type double, then callthe both the functions and pass the appropriate parameters.
得出的答案应该是这样的:
万分感激 展开
展开全部
#include <iostream>
#include <iomanip>
using namespace std;
void initialized(double array[],int size){
int count;
for(count=0;count<size;count++){
if(count<25)
array[count]=count*count;
else if(count<50)
array[count]=3*count;
else if(count<75)
array[count]=4*count;
else
array[count]=5*count;
}
}
void print(double array[],int size){
int i;
for(i=0;i<size;i++){
cout<<setw(5)<<array[i];
if((i+1)%10==0)
cout<<endl;
}
}
int main(){
double alpha[100];
initialized(alpha,100);
print(alpha,100);
return 0;
}
更多追问追答
追问
感谢,在问一下,第二和三的答案有包括在里面吗,还是你只回答了第一题?
追答
包含全部的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询