473,387 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

inserting integers in a list and displaying their sum

11
The program asks the user to enter the inegers (up to 30) and display their sum, by using List.h and then List.cpp. Help please.
Sep 28 '06 #1
3 2577
tyreld
144 100+
Are List.h and List.cpp code supplied to you, or code that you are supposed to write yourself. I'm assuming probably write yourself. You should take a stab at writing the code yourself and asking for help once you become stuck. There are several ways to implement a list. As an array, as linked list of pointers, etc. You need to ask more specific questions, and supply code you are having problems with.
Sep 28 '06 #2
Anjola
11
I wrote this listA.h and ListA.cpp. I am not sure if it is right or not. Anybody can offer some help. The user has to enter 30 integers and he program has to store and display the list as well as the sum of integers. Help.
# ifndef ListA_H
#define ListA_H

const int MAX_LIST=30;
typedef int ListItemType;

class List
{

public:

List();
bool IsEmpty();// const;
int Length() const;
void Insert (int NewPosition, int NewItem, bool& Success);
void Retrieve (int & DataItem, int Sum, bool& Success);
private:
ListItemType Items[MAX_LIST];

int Size;
int sum;
};
#endif

# include <iostream.h>
#include <conio.h>
# include <iomanip.h>
# include "f:\listA.h"

List::List():size(0) {}
bool List::isEmpty() const
{
return bool (size==0);
}

int List::getLength() const{
return size;
}

void List::insert(int index, double sum, bool & success)
{
sucess=(index>=1)&&(index<=size+1) && (size<MAX_LIST);
if (success)
{
for (int position=size; position>=index; --position)
++size;
}

void List::retrieve(int index, sum, bool & success) const{
success=(index>=1) && (indexx<=size);
if (success)
sum= sum[sum];
}
Sep 29 '06 #3
Banfa
9,065 Expert Mod 8TB
Please don't double post!

Have you compiled this and tried to fix the errors?
Sep 29 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Thomas Guettler | last post by:
Hi, Simple excerise: You have a sorted list of integers: l= and you should fill all gaps: result ==
13
by: Jeff Melvaine | last post by:
I note that I can write expressions like "1 << 100" and the result is stored as a long integer, which means it is stored as an integer of arbitrary length. I may need to use a large number of...
16
by: aruna | last post by:
Given a set of integers, how to write a program in C to sort these set of integers using C, given the following conditions a. Do not use arrays b. Do not use any comparison function like if/then...
4
by: John Wildes | last post by:
Hello I have a small program that I've created to generate accounting statements out of our policy managment system. The first part of the process is selecting the customer to create the...
11
by: krishnakant Mane | last post by:
hello, I finally got some code to push a pickled list into a database table. but now the problem is technically complex although possible to solve. the problem is that I can nicely pickle and...
3
by: Jeff | last post by:
....still new to vb.net 2005 I understand the concept of arrays, and have used them in other languages, but was hoping that someone could get me started with something. I have a fairly long...
14
Parul Bagadia
by: Parul Bagadia | last post by:
Here is the code i hav written for inserting a no., after given no. in a link list; i guess the logic is ofcourse right. there is no error in it, but at the time of display its not displaying the...
10
by: Clamato | last post by:
Good Morning, I'm working with a form that basically add's a users windows logon ID, first name, and last name to a table. A list box on this form is then requeried once added displaying the...
13
by: rohit | last post by:
Hi All, I am new to C language.I want to read integers from a text file and want to do some operation in the main program.To be more specific I need to multiply each of these integers with another...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.