Each question is C++ based. I did question 1, but could someone please check tho
ID: 3572518 • Letter: E
Question
Each question is C++ based.
I did question 1, but could someone please check those answers. Also, I need help with questions 2-7. How are they done? (C++)
1. Write c statements to accomplish each of the following a) Display the value of the seventh element of character array A. cout KA[6] Kendl, b) Input a value into element 4 of single-subscripted floating-point array B. cin>>B(3): c) Initialize each of the 50 elementa of eingle-eubecripted integer array Cto 8. for (index 0: index 50: index C[index 8 d) Total and print the elements of floating-point array Dof 100 elements. float D[100] fo (index 0, index 99: index++) sum D[index l, e) Copy array C into the first portion of array D for(index 0; index -49; index Clindex D index]. Determine and print the smallest values contained in a 100-element floating-point array F for(index 1, indexo-99, index if Flindex kemalleat) smallest F[index] Else if (F index Plargest) Largest F[indexExplanation / Answer
2)i)int total(0)//there is error
It should be int total=0;
ii)
cout(num);
Here it should be cout<<num;
iii)int for loop ,
a[i]/=total
you are modifying a which not possible as it declared constant.
================================================================================
#include <bits/stdc++.h>
using namespace std;
void remove_first_ele(int a[],int& size)
{
cout<<"Removing first element ";
for (int i = 0; i <size; ++i)
{
a[i]=a[i+1];
}
size--;
}
void input_1Darray(int a[],int size)
{
cout<<"enter 10 elements ";
for (int i = 0; i <size; ++i)
{
cin>>a[i];
}
}
void print_1Darray(int a[],int size)
{
cout<<"Elements are ";
for (int i = 0; i <size; ++i)
{
cout<<a[i]<<endl;
}
}
void Larger_1Darray(int a[],int size)
{int ele;
cout<<"Enter number to find larger elements than it ";
cin>>ele;
cout<<"Larger elements than "<<ele<<" are ";
for (int i = 0; i <size; ++i)
{
if(a[i]>ele)
cout<<a[i]<<endl;
}
}
int main(int argc, char const *argv[])
{
int _1Darray[10];
int size=10;
input_1Darray(_1Darray,size);
print_1Darray(_1Darray,size);
remove_first_ele(_1Darray,size);
print_1Darray(_1Darray,size);
Larger_1Darray(_1Darray,size);
return 0;
}
============================================================================
Output:
akshay@akshay-Inspiron-3537:~/Chegg$ g++ arr.cpp
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
enter 10 elements
1
2
3
4
5
6
7
8
9
10
Elements are
1
2
3
4
5
6
7
8
9
10
Removing first element
Elements are
2
3
4
5
6
7
8
9
10
Enter number to find larger elements than it
5
Larger elements than 5 are
6
7
8
9
10
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.