Lab 13 For this lab, you will Csc 17OL Computer Programming Lab or not, need to
ID: 3778083 • Letter: L
Question
Lab 13 For this lab, you will Csc 17OL Computer Programming Lab or not, need to implement e of the steps below. It is your choice whether you use function comment that each of the steps below must be properly and your code must compile and tun implement functions for the entire program will receive extra credit. You must also put a indicates which step you are implementing above the co I/Step7 Step 1: Start a project and name your source file Lab14.cpp Step 2: Enter the skeleton code into your source file. include ki ostream> #includeExplanation / Answer
Note :- Each and every Step completion state provided in the command lines.Save as Lab14.cpp(Step 1).
Solution :-
#include<iostream.h>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
int i,even=0;
float sum=0.0,qArray[10]={3.7,12.3,4.5,10.6,2.3,5.4,9.8,15.2,7.7,19.8}; //Step 3 Completed.
qArray[2]=75.6; //Step 4 Completed.
for(i=0;i<10;i++)
cout<<qArray[i]<<" "; // Step 5 Completed.
for(i=0;i<10;i++)
{
if(qArray[i]>=7.6 && qArray[i]<=10.5) // Step 6 Completed
{
cout<<endl<<"Enter the number to replace : ";
cin>>qArray[i];
}
//Step 7 Completed
}
for(i=0;i<10;i++)
cout<<qArray[i]<<" ";
for(i=0;i<10;i++)
{
sum=sum+qArray[i];
}
cout<<"The sum of the all components : "<<sum; //Step 8 Completed.
for(i=0;i<10;i++)
{
if(fmod(qArray[i],2)==0)
{
cout<<endl<<"The even numbers are : "<<qArray[i]<<endl;
even++;
}
}
cout<<"The number of even numbers present in the list are : "<<even; // Step 9 Completed.
for(i=0;i<10;i++)
{
cout<<endl<<"Enter a number :"<<endl; // Step 10 completed.
cin>>qArray[i];
}
for(i=0;i<10;i++)
{
cout<<qArray[i]<<" "; // Step 11 Completed.
}
return 0;
}
Output :-
3.7 12.3 75.6 10.6 2.3 5.4 9.8 15.2 7.7 19.8
Enter the number to replace : 6.0
Enter the number to replace : 8.0
3.7 12.3 75.6 10.6 2.3 5.4 6 15.2 8 19.8 The sum of the all components : 158.9
The even numbers are : 6
The even numbers are : 8
The number of even numbers present in the list are : 2
Enter a number :
2.5
Enter a number :
6.4
Enter a number :
.3
Enter a number :
9.1
Enter a number :
10.5
Enter a number :
15
Enter a number :
65.4
Enter a number :
41.3
Enter a number :
4.32
Enter a number :
1.6
2.5 6.4 0.3 9.1 10.5 15 65.4 41.3 4.32 1.6
I hope the above code was help you ,it explains each and every step that provided in the question.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.