#include #include //user-defined functions question! using namespace std; struct Books { char title[50]; char author[50]; char subject[100]; int book_id; }; int main() { double array1[5]= {13.768,4.0,88.7689,9.12,}; struct Books Book1; strcpy( Book1.title, "C++ Programming"); strcpy( Book1.author, "D.S Malik"); strcpy( Book1.subject, "C++ basics"); Book1.book_id = 6495407; ////Block#1////// int x=4; for (x; x>=0; x--){ cout<(array1[i])<<" "; sum= sum+array1[i]; cout<
#include <iostream>
#include<string.h>
//user-defined functions question!
using namespace std;
struct Books
{
char title[50];
char author[50];
char subject[100];
int book_id;
};
int main()
{
double array1[5]= {13.768,4.0,88.7689,9.12,};
struct Books Book1;
strcpy( Book1.title, "C++
strcpy( Book1.author, "D.S Malik");
strcpy( Book1.subject, "C++ basics");
Book1.book_id = 6495407;
////Block#1//////
int x=4;
for (x; x>=0; x--){
cout<<array1[x]<<endl;
////////////////////////////////
}
cout<<"///////////////////////"<<endl;
////end of Block#1//////
////Block#2//////
int sum=0, i=0;
for (i; i<5; i++){
cout<<static_cast<int>(array1[i])<<" ";
sum= sum+array1[i];
cout<<sum<<endl;
}
cout<< "final value of sum="<<" "<<sum<<endl;
cout<< "the average value ="<<" " <<sum/5 <<endl;
cout<<"//////////////////////"<<endl;
//
Step by step
Solved in 4 steps with 3 images