Answer:
im working on this too but i think this is d
Explanation:
Answer:
The first one. Important notice sum should be equal to zero before calculating the total sum.
D I would think……… good luck
Answer:
Explanation:
Here is the code
#include<iostream>
using namespace std;
template <class myType>
int generic(myType *a, myType b)
{
int i;
for(i=0;a[i]!=-1;i++)
{
if( b == a[i])
return i;
}
return -1;
}
int main()
{
int a[]={1,2,3,4,5,6,7,8,-1};
float b[]={1.1,2.1,3.1,4.1 ,5.1,6.1,7.1,-1};
if(generic(a,5)>0)
{
cout<<" 5 is foundin int at index "<<generic(a,5)<<endl;
}
else
{
cout<<" 5 notfound "<<endl;
}
if(generic(b,(float)5.1)>0)
{
cout<<" 5.1 isfound in float at index "<<generic(a,5)<<endl;
}
else
{
cout<<" 5.1 notfound "<<endl;
}
system("pause");
}
/*
sample output
5 is found in int at index 4
5.1 is found in float at index 4
*/
Answer:
Explanation:
#include <iostream>
using namespace std;
int main ()
{
int responses[30],count[6];
int score = 0;
string resp = " ";
for (int i = 0; i < 30; i++)
{
responses[i] = 0;
}
for (int i = 0; i < 6; i++)
{
count[i,1]=0;
count[i,2]=0;
count[i,0]=0;
}
while ((resp != "Y") && (resp != "y"))
{
for (int i = 0; i < 30; i++)
{
while ((score > 5) || (score < 1))
{
cout << "Student " << (i+1)<< " please enter a value (1-5):";
cin >> score;
}
responses[i] = score;
if((score > 5)||(score<1))
{
if(score==1) count[1]++;
if(score==2) count[2]++;
if(score==3) count[3]++;
if(score==4) count[4]++;
if(score==5) count[5]++;
}
score = 0;
}
cout<< "Response Frequency Percentage"<<endl;;
cout<< " 1 "<<count[1]<<" "<<(count[1]/30)<<"%"<<endl;
cout<< " 2 "<<count[2]<<" "<<(count[2]/30)<<"%"<<endl;
cout<< " 3 "<<count[3]<<" "<<(count[3]/30)<<"%"<<endl;
cout<< " 4 "<<count[4]<<" "<<(count[4]/30)<<"%"<<endl;
cout<< " 5 "<<count[5]<<" "<<(count[5]/30)<<"%"<<endl;
cout<< "Do you want to exit? Press Y to exit any other key to continue: ";
cin>> resp;
}
return 0;
}