C++ :: Positive And Negative Infinity
May 2, 2013
What are positive and negative infinity for different data types in c++, are they represent maximum and minimum limit of a type? or positive infinity is not a finite value.can some explain this positive and negative infinity paradigm
View 3 Replies
ADVERTISEMENT
Nov 26, 2013
int Fib1 = 1;
int Fib2 = 2;
int Fib3 = 0;
int randomynumber;
int Loop;
[code].....
this returns negative numbers sometimes.what did i do wrong side note this is not the complete program it is only the part with the problem because the complete code is sort of longish and very confusing
View 2 Replies
View Related
Jan 27, 2014
#include <iostream>
using namespace std;
int initialization (int []);
int identifying (int [],int);
[Code].....
View 8 Replies
View Related
Aug 18, 2014
Write a program to enter the number till 100 till the user want and at the end it should display the count of positive and negative and zero entered.
View 8 Replies
View Related
Feb 2, 2015
My program uses a while loop to eventually get to an error of zero and a root of sqrt(3). I'm not understand why after the third iteration the program fails to compute a new x value. I'm using Visual Studio 2013. The code tag instructions were dubious.
Code:
#include <stdio.h>
#include <math.h>
main() {
/*This program uses the Newton-Raphson method to solve y = (x^3)-3 for it's roots.*/
printf("This program uses the Newton-Raphson method to solve y = (x^3)-3 for it's roots. Enter your estimate of the root.
");
float x,y,z;
int num;
num = 0;
[Code]...
View 1 Replies
View Related
Jan 25, 2013
Consider a new data type, the mikesint, which can hold 9 bits.
(a) What is the largest integer that an unsigned mikesint can hold?
(b) What is the largest positive integer that a signed mikesint can hold?
(c) What is the largest negative integer that a signed mikesint can hold?
Not sure how to determine this. I'm stuck.
View 5 Replies
View Related
Nov 10, 2014
So I tried creating a test code for reading a negative number and positive number but whenever I enter a negative number it read it as being positive.
#include <stdio.h>
#include <iostream>
#include <iomanip>
[Code].....
PS: I am using char over int because the program that I am testing for requires me to use 8 bit variable.
View 2 Replies
View Related
Oct 21, 2014
I have a problem with my assignment. I would like to ask how to transfer positive and negative values from array temperature to arrays positive and negative?
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int n=0, d=0, temperature[20], sum;
int positive[], negative[];
float avg;
[code]....
View 5 Replies
View Related
Jan 19, 2014
I have an assigment and I don't know yet how to write this program :" I introduce the average monthly temperatures of a year(12 values for 12 months). When I compile the program it needs to show the highest negative temparature and the lowest positive temperature of that year.
Example: Entry data: -4 -6 0 5 10 20 24 25 17 8 -1 -7 exit data : max negative= -1 and min positive= 5 "
View 11 Replies
View Related
Jun 19, 2014
So I have to make a program that allows the user to enter both positive and negative numbers and the program is suppose to calculate the sum of only the positive values while ignoring the negative values. Also it is to be a sentinel-controlled loop with a number ending the set of values.
View 4 Replies
View Related
Dec 11, 2013
im supposed to create a program that reads in a list of integers from the terminal and writes the negative numbers to one file and the positive numbers to another file.
i got most of it doen but for some reason its not writting the negative numbers. on what im doing wrong?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
int pos_num = 0;
int neg_num = 0;
int positive_numbers = pos_num % 5;
[Code]...
View 2 Replies
View Related
Nov 18, 2013
I am trying to average the negative numbers and positive number and of course the total average.
This will read in a list of n values, where n is not known ahead of time. The number of values read into the array will be saved in n.
vector<int> readList() {
std::vector<int> result;
ifstream inFile;
inFile.open("setA.txt");
for (int x; inFile >> x; ) {
result.push_back(x);
[code]....
array is a one-dimensional array of integers and n is the number of elements in that array that contain valid data values. Both of these are input parameters to the function. The function must calculate 1) the average of the n integers in array, storing the result in ave; 2) the average of the positive numbers (> 0), storing the result in avePos, and 3) the average of the negative numbers (< 0), storing the result in aveNeg.
void avgs (std::vector &array, int &ave, int &avePos, int &aveNeg) {
int sum = 0, pos_sum = 0, neg_sum = 0, pos_count = 0, neg_count = 0;
for (auto i : array) {
sum += i;
if (i > 0) { pos_sum += i; ++pos_count; }
[code]....
View 1 Replies
View Related
May 15, 2013
ignoring negative numbers when I am trying to add up only positive numbers.
SAMPLE:
if (num>=0) {
sum= sum + num;
}
else
how would the else in this case being a negative number not be included in the sum
View 4 Replies
View Related
Aug 27, 2014
Having error . I multiplied 0 by -4 and my result is -0 instead of 0. I tried to change the data type put It won't work. This is my code:
#include <iostream>
int main () {
double b, c;
std::cout<<"b: ";
std::cin>>b;
std::cout<<"c: ";
std::cin>>c;
std::cout<<b*c<<std::endl;
return 0;
}
View 2 Replies
View Related
Jan 25, 2014
Create a program that keeps on reading positive numbers until user enters a zero value, and then outputs the last positive number entered.
I do not know how to output the 'last positive number' and I do not even know am I doing things correctly so far....
Code:
#include <stdio.h>
int main() {
double num;
for(;;) {
printf("Enter a positive number: ");
scanf("%lf",&num);
[Code] ....
View 9 Replies
View Related
Mar 27, 2013
I have written a function that takes in a positive decimal and returns its Binary equivalent; however, the output always adds an additional zero to the binary. What could I do to get rid of it?
If the number is 7, it outputs 0111 instead of 111.
Code:
#include <stdio.h>
void Dec(int n) {
if(n > 0)
Dec(n/2);
printf("%i", n%2);
[Code] ....
View 2 Replies
View Related
Nov 3, 2014
I have task to make program.. To enter 10 positive numbers in an array. Find three numbers that stand near each other and that have the maximum sum.
I understand how to make array, enter 10 number i find only one biggest number from 10.. How to find three max number sum that stand near each other..
View 10 Replies
View Related
Oct 29, 2014
I was going through the following statement in a c book:
"interpreting -1 as unsigned int leads to a big +ve number"
-1 is already unsigned .... then what does the above statement mean ??
View 3 Replies
View Related
Nov 1, 2013
I am having an error at line 21. Specifically the code where it says "list[num]=x"
How am I able to fix this code to do what I want? The purpose of my program is to enter in positive numbers in an array (and having it end when 0 is typed) My program also accepts negative values but will ignore them when it is outputted. I believe I have all the code right except for line 21.
#include<iostream>
using namespace std;
const int ARRAY_SIZE(25);
void read_list(const int list[],const int ARRAY_SIZE);
int main() {
int list[ARRAY_SIZE];
read_list(list, ARRAY_SIZE);
[Code] ....
View 2 Replies
View Related
May 3, 2014
Assume you want to make sure that the user enters a positive number that is divisible by 10 with no remainder. Write the condition you would use in the following do-while loop.
do {
cout << “Enter a positive number that is divisible by 10 with no remainder” << endl;
cin >> number;
}
while ( ____________________________________________________________);
View 2 Replies
View Related
Apr 24, 2012
If I have a positive double and cast it to an int. If it overflows, I know that most of the time, the value of the int becomes negative. If it overflows far enough, will it eventually become positive again?
Code:
double d = 34192384732194872394837249832743984738.;
int i = (int)d;
std::cout << i << std::endl;
Is there any value of d > INT_MAX that will cause i to be positive?
View 4 Replies
View Related
Jan 22, 2015
I have a program where the user inputs a line of numbers, and the two highest ones are displayed. It works fine, until negative values are entered at which point it shows 0 as the result.
Code: #include <iostream>
using namespace std;
int main( ) {
int num = 0;
int highest = 0;
[Code].....
View 6 Replies
View Related
Jul 12, 2013
I have a c program that I partially have working. The problem is basically writing a program that allows the user to input the amount of calories they plan to eat a meal and disperse the calories from top to bottom. My program produces the output in the example if I enter 1050 but the issue I noticed if the number of calories is just enough to cover the burgers I get negatives in the other variables.
For example, if I enter a total amount of calories of 1050, I can eat: Output: 2 burgers @ 770 calories (1050 - 770 = 280 calories remain) 1 bag of pretzles @ 170 calories (280 - 170 = 110 calories remain) 1 pear @ 80 calories (110 - 80 = 30 calories remain) 6 tsp. ketchup @ 30 calories If I input 1050 I get the above output but if I input a different integer such as 2000 this is my output 5 burgers @ 1925 calories 0 bag of pretzles @ 0 calories -1 apple @ -80 calories -35 tsp. ketchup @ -175 calories I can't give the full code since this assignment holds a lot of points and was up all night getting it work.
So I'll provide pseudocode
define all 4 variables burger 385, pretzel 170, pear 80, ketchup 5 print out text How many calories can you eat prompt user input
Divide user input into burger How many burgers can bet eaten subtract calories eaten from original user input
Divide calories left into pretzel How many bags can bet eaten subtract burger calories from pretzel calories
Divide calories left after preztel into pear How many pretzels can be eatn subtract pretzels calories from pear calories
Divide calories left over into ketchup how much ketchup can i use show on screen (int total)of burgers @ (int calorie total) calories show on screen (int total)bags of pretzels @ (int calorie total) calories show on screen (int total)pears @ (int calorie total) calories show on screen (int total)teaspoons of ketchup @ (int calorie total) calories
The problem I see is that subtracting the calories from the pear from the left over calories of the pretzel calories leads to a negative. If leftover calories minus 80(pear int) its less then 0 . The calculations from the pear onward to ketchup become incorrect resulting in negative output.
View 6 Replies
View Related
Sep 3, 2014
I nead to define an a negative number a normal posetive number i defined like #define RSSI_UP 1 can i write #define RSSI_DOWN -1???
View 2 Replies
View Related
Sep 21, 2014
how to use '+', '-', '*' as preprocessor directives??
I want to do the following work.
#define + 10
#define - 20
#define * 30
View 4 Replies
View Related
Sep 30, 2013
The code on lines 44-53 is suppose to display a message when the user enter a negative number, however, when a correct positive number is entered the message is display again.
#include<iostream>
#include<cctype>
using namespace std;
int main() {
char carType;
int A, B, C;
[Code] ....
View 2 Replies
View Related