Public data members and private data members.

Assignment Help C/C++ Programming
Reference no: EM13167086

 Explain the difference between public data members and private data members. Give an example in the main function to show that one C++ statement is valid and the other is invalid (you can use Grade class in Problem 5.

 

2        What output would be produced by the following program?

#include <iostream>

using std::cout; using std::endl;

int main()

{

      int a[] = {3, 1, 0, 2, 4};

   int b[] = {50, 40, 30, 20, 10};

   for (int i=0; i<5; i++}

cout << b[ a[i] ] << endl;

   return 0;

     }

 

3        The following code has many errors. Please point out and correct them.

#include <iostream>

using namespace std;

class Date

{

public

      Date()

      {

month = day = 0;

}

      setDate(int m, int d)

      {

            month = m;

            day = d;

}

      int getDay();

{

            return day

}

private

int month, day;

}

 

int main()

{

      Date d;

      setDate(10,20);

      cout << getDay() << endl;

      return 0;

}

 

4        What output would be produced by the following program?

.........................

int main()

{

   ifstream fin;

   fin.open("list.dat");

   int count = 0;

   double next, total=0.0;

   cout << fixed << setprecision(2);

   while (fin >> next)

   {

     count++;

     total += next;

     cout << setw(7) << next << endl;

        }

        fin.close();

        cout << "The sum of " << count << " numbers is "

             << total << endl;

   return 0;

}

The file list.dat contains the following five numbers (and nothing more):

10.0001 1.1e2      1.0e-6

5.0007   -5.0008

 

 

Reference no: EM13167086

Questions Cloud

Write a program in which a ball is released : Write a program in which a ball is released from a user-defined height and free-falls to the ground. The ball is pulled by earth's gravity of 9.8 m/sec 2 . Assume that each pixel represents 1 cm. Once the ball hits the ground
For each of these four modifications : For each of these four modifications, compute and graph the effects on the original system. Explain in words the effect when the multiprogramming level, N , is small and when N is large.
C program to mips program : Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers $s0, $s1, $s2, $s3 already.
Python program that reads in a series of positive integers : Write a Python program that reads in a series of positive integers and writes out theproduct of all the integers less than 25 and the sum of all the integers greater than or equal to 25. Use 0 as a sentinel value
Public data members and private data members. : Explain the difference between public data members and private data members. Give an example in the main function to show that one C++ statement is valid and the other is invalid (you can use Grade class in Problem 5.
The goal of this project is to create : The goal of this project is to create a simple command line program that reads in a single word from the command line (use the "int argc, char * argv[]" approach discussed in class and in previous projects) and stores the unique letters of that wo..
Write a program that reads an array with wind-tunnel test : write a program that reads an array with wind-tunnel test data then allowss the user to enter a flight-path angle. If the angle is within the bounds of the data set, the program should then use linear inteerpolation to compute the corresponding coeff..
Generate a two-dimensional array : Generate a two-dimensional array of integers of 10 rows by 10 columns that contains 100 random numbers between 0 and 9. Print out the array (well formatted) and do the following computations
End to end encryption : How is end to end encryption different from other types of encryption? At what layer does it take place?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd