C/C++ :: Dividing 100 Customers Into Three Clusters

Apr 4, 2015

I wrote the following code to divide 100 customers into three clusters but it kept on hanging during execution. I used while loop. Attached is the text file to use. and the code below :

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
#include <math.h>

[Code] ....

Attached File(s)
c201.txt (7.13K)

View 1 Replies


ADVERTISEMENT

C :: Dividing Two Integers

May 14, 2014

i am relatively new to C programming so i run into problems on daily basis. But this time i have something i just cant figuer out and i was hoping you could point me towards the right track. I am trying to divide two integers.DevValue by KpTotal. for some reason my micro controller allways crashes.Y is a variable of a distance measuring sensor. i have a 4x4 keypad to enter a three digit number (e.i 123) so Kp1 = 1 Kp2 = 2 Kp3 =3.

Code:

int kp1, kp2, kp3, kpTotal = 0;
char txt[6] = ""
int keypadPort at PORTD;
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
}

[code]....

i think it has something to do with the format of the value. i read that the micro controller crash when dividing by zero.

View 1 Replies View Related

C++ :: Dividing String Into Pieces?

Jun 21, 2013

i made a calculator that you have to give terms and operators one by one but now i want to improve it. the user now should be able to type something like 5*78+325/sin(3*pi)-1 and the program should be able to calculate it. but i don't know how to use the signs '*','+','-' and '/' as delimiters and turn the input string into a string array. i mean the string "5*78+325/sin(3*pi)-1" will become a string array like "5,*,78,+,325,/,sin(3*pi),-,1,"

View 2 Replies View Related

C++ :: Customers Plan - Output Name And Two Digit Number Next To It?

Nov 8, 2013

//using bloodshed dev c++ compiler
//How can I output the name and a two digit number next to it
//example would be Indiana Jones 20
#include<iostream>
#include<string>
using namespace std;
class Customer {

[Code] .....

View 3 Replies View Related

C :: Dividing Time Variable - Always Prints 0

Mar 2, 2013

So i have this -

time_t t4 = time(NULL);

//and then some stuff

time_t t5 = time(NULL);

iElapsedYah = t5-t4;

fElapsedYah2 = iElapsedYah/iNumTimes;

printf("It took %f seconds", fElapsedYah2);

but it always prints 0.0000000, and i dont know why even though individually

iElapsedYah = not zero and iNumTimes = not zero

I am using windows 7 and m complier is Dev C++

View 3 Replies View Related

C/C++ :: Dividing Number By Float Integer?

May 5, 2014

I need to read a float number and show the rest of his division by an integer, but i'm having the following error message:

Quote

error: invalid operands of types 'float' and 'int' to binary 'operator%'

View 8 Replies View Related

C/C++ :: Dividing Two Integers Will Return Integer Value?

Dec 2, 2014

So I have a simple calculator that does a few operations (+ - * / %) Pretty basic stuff

I declared int x, y for the numbers, char operation, and float result.

the code is based on switch(operation)

The program is running alright, but when I divide 8/7 it returns 1 as the result, I tried changing the x and y to float but that won't work because of the case '%'

I also tried making local float variables in the case'/' but it won't compile "E2126 Case bypasses initialization of a local variable"

How can I make the division work and return a float value?

View 3 Replies View Related

C++ :: Program To Simulate Customers Lining Up To Buy Tickets For Some Event

Oct 17, 2013

Create a line class using a linked list that acts as a queue (first in, first out) both enqueue and dequeue. Complete the line class so that customers can be added or removed from the line. Implement the line as a linked list of customer objects that you have developed yourself or use the vector class.

View 2 Replies View Related

C++ :: Program That Keeps Track Of Social Security Numbers Of Customers

Jun 27, 2013

I am trying to write a program that keeps track of social security numbers of customers I have to assume that its a four-digit number. When the program runs,it has to prompt that the user should enter a 4-digit number to record, or 0 to exit.

The program also needs to be able to give an error message if a certain number is entered more than once.

After all the numbers have been saved and you finally end it by pressing 0, it needs to be able to output all the entered SSN's.

Here is my code so far:

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
bool isExist(int ssn, int records[], int numberOfRecords);

[Code] ......

View 3 Replies View Related

C++ :: Country Population - Storing Values And Dividing

Mar 12, 2014

I'm supposed to store the value of a countrys population. Then gather out the percentage that countrys population holds when compared with the global population.

Anyway here's the code:

Code:
#include <iostream>
long swe_pop = 9644864;
int main ()

[Code] .....

The result I'm getting is 0%.

I was under the impression that long (or long long) integers could hold high values. And that I could then divide these and answer with a float type value. Giving space for the decimals.

View 3 Replies View Related

C++ :: Dividing Two Floats Not Giving The Required Quotient

Jan 9, 2014

Im using the remquo function in the cmath library as follows:

int quotient;
double a = remquo (10.3, 4.5, "ient);

This gives the correct remainder (a = 1.3) and quotient (quotient = 2).

Infact about 50% of the answers are right when I play around, however, trying something like:

int quotient;
double a = remquo (2.25, 1.5, "ient);

yields an incorrect quotient of 2 and remainder of 0.

I do think this has something to do with float arithmetic. I recall tinkering with the float number 0.500 and that the CPU actually saves it as 0.50000000000000231. However if my suspicion of float arithmetic as the suspect is correct, I do not understand why a tenth decimal would make such a drastic difference as changing the quotient result.

View 10 Replies View Related

C++ :: Program To Keep Track Of Social Security Numbers Of Customers Of A Bank

Oct 4, 2014

In this assignment, you are going to write a program that keeps track of the social security numbers (SSN) of customers of a bank. Please notice that we are going to assume that SSN is a four-digit number (e.g., 1234. 0123 is not allowed.). When the program runs, it prompts that the user should enter a 4-digit SSN number to record, or 0 (zero) to exit.

So far I have this:

#include <iostream>
using namespace std;
bool isExist(int ssn, int records[], int numberOfRecords);
int main(){
int ssn = 0;
int records[32];

[Code] .....

View 16 Replies View Related

Visual C++ :: Keep Track Of Social Security Numbers (SSN) Of Customers Of Bank

Jun 26, 2013

I am trying to write a program that keeps track of social security numbers (SSN) of customers of a bank. I have to assume that SSN is a four-digit number (e.g., 1234. 0123 is not allowed.). When the program runs,it has to prompt that the user should enter a 4-digit SSN number to record, or 0 (zero) to exit.

The program also needs to be able to give an error message if a certain number is entered more than once.

After all the numbers have been saved and you finally end it by pressing 0, it needs to be able to output all the entered SSN's.

Here is my code so far :

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
bool isExist(int ssn, int records[], int numberOfRecords);
void listRecords(int records[], int numberOfRecords);
int main()

[Code]...

View 2 Replies View Related

C++ :: Tourist Agency - Calculate Total Price For Customers For A Package Of Vacation?

Apr 25, 2013

SYNOPSIS : KBJ tourist agency Sdn. Bhd wants you to write an application program to calculate the total price for their customers for a package of vacation. The following table shows the price for three destinations (transportation and accommodation) offered by the agency:

Destination TransportationAccommodation
Pulau Redang Child RM15.00
Adult RM30.00RM95 per day
Pulau Perhentian Child RM20.00
Adult RM30.00 RM100 per day
Pulau Kapas Child RM10.00
Adult RM20.00 RM120 per day

This agency company will give some discount to a group of customers with is:

a.10% discount will be given for the group that has a least 5 adults.

b.25% discount will be given for the group that has more than 5 persons (adults and children)

c.30% discount will be given for the group that has at least 15 persons.

Your application program has to display the output using this following screen layout:

KBJ TOURIST CUSTOMER INFORMATION

Customer’s name: XXXXXXXXXXXXX
Number of Children:XXXXX
Number of Adult: XXXXX
Transportation: RMXXX.XX
Accommodation: RMXXX.XX
Total price: RMXXXX.XX

This is the code i got so far but it doesn't work..:(

#include <iostream.h>
int main () {
char customerName,code,A,B,C;
int childNum,adultNum;
double rate,discount,totalPrice,a,c;

[Code] .....

View 8 Replies View Related

C++ :: Shop Database - Take Customers ID And Scan Through A Text File Then Print Out Info

Apr 10, 2013

I have to create a small data base for a shop. One of the functions i am creating is taking a customers ID and scanning that through a text file and to print out the info about that customer. What i am having trouble with is where do i insert the string compare in my program?

//declaring array for input of customer ID
int customer_ID [20];
printf("Please enter the customer ID:");
gets( customer_ID ); //users input stored in the array

[Code] .....

View 2 Replies View Related

C :: Calculate Final Grade By Adding 4 Numbers Minus Lowest Grade And Dividing By 3

Apr 7, 2013

I'm writing a program to calculate a final grade by adding 4 numbers minus the lowest grade and dividing by 3. My knowledge in c is not extensive I thought that a simple assigment operator would do the job but I'm getting a strange large numbers in the execution.

Code:
#include <stdio.h>
#include <stdlib.h>
main(){
int eg, g1, g2, g3, g4, fg, s1, s2, sg;

[Code] ....

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved