C/C++ :: Find Out Scientific Notation Of Numbers

Oct 21, 2014

how i solve this..?

View 1 Replies


ADVERTISEMENT

C++ :: Scientific Notation To Decimal?

Mar 12, 2014

I just wrote code that is a program for a relativity calculator. However many of my outputs (because the values tend to be large) end up in scientific notation. Although useful, its not great for the laymen, or nice looking.

How can I change it so that output is not in scientific notation? here is the code:

// This program/converter is designed to find the desired 'real' values using Einstein's theory of relativity

#include<iostream>
#include<math.h>
#include<stdlib.h>

[Code]....

View 1 Replies View Related

C++ :: Stop Scientific Notation

Jul 15, 2013

double number = 10000000;
int range;//the length of the string result
string result;//holds the number in a string
ostringstream convert; //stream used for the conversion
convert << number;
result = convert.str();

range = result.length();

I'm trying to convert a double to a string and when the number goes to ten million it goes to scientific notation and it shows it in the string. How do I stop it from do that?

View 2 Replies View Related

C++ :: Input Decimal Number And Output To Be Number Scientific Notation

Apr 26, 2013

I need to write a code in c++ , to input decimal number and the output to be number in Scientific notation with 32 bits .

View 1 Replies View Related

C++ :: Write Program To Convert Time From 24-hour Notation To 12-hour Notation

Dec 10, 2013

Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following function: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.)

Answer:

#include <iostream>
#include <iomanip>
#include <cmath>

[Code]....

It is showing error because may be I was not able to put that if statement inside any function. find out the error sand complete the program with corrected code.

View 2 Replies View Related

C++ :: Find Prime Numbers Between Given Pair Of Numbers And Store Them Into Array?

Apr 18, 2014

Find all the prime numbers between a given pair of numbers. Numbers should be read in from an input file called "numbers.txt" and find all the prime numbers between them. Store the prime numbers in an array, then sort the array from greatest to least. Display the array before and after the sort.

I'm stuck on how to put the prime numbers into an array.

The input file has the numbers 1 & 100.

Here's what I have so far.

#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin;
fin.open("numbers.txt");

[Code] .....

View 1 Replies View Related

C :: Find Duplicate Numbers And Numbers Found Once In Array

Dec 7, 2013

Question: How to find a duplicate numbers and numbers found once in array.

View 7 Replies View Related

C :: Convert Floating Point Scientific Precision

Mar 31, 2014

Can we change the floating point number format from scientific format to below example format ?

FROM TO
==========================
2.06374E-03 ---> 206370-8
-4.30311E-01 ---> -.430310
-4.28146E-04 ---> -42815-8
==========================

View 6 Replies View Related

C++ :: Find GCD Of Array Of Numbers

Aug 25, 2013

I wrote this GCD function to find gcd of an array of numbers . Here is the code:

long long GCD(long long min,int loc,long long b[]) {
for (long long i=min;i>0;i--) {
bool p=0;
for (long long x=0;x<loc;x++) {
if (b[x]%i!=0)

[Code] ....

Its returning wrong answers. When i tried 6 14 it returns 6

View 6 Replies View Related

C/C++ :: Program To Find The Sum Between Two Numbers

Sep 25, 2014

Q)Write a program to find the sum between (2 numbers )

what's the problem here !

#include<stdio.h>
main()
{
int a,b,c;
int sum=0;
for(a=0;b>a<c;a++)
{
printf(" number1=");

[Code]...

View 5 Replies View Related

C/C++ :: Algorithm To Find First N Odd Numbers

Jan 20, 2013

write algorith to display first n odd numbers ?

View 8 Replies View Related

C++ :: Plus Or Minus Notation

Aug 4, 2013

Is there a simple notation to check if a value is within a plus or minus range?

E.g.
//I read a value A. delay(50); //Read value again -calling this value B delay(50);
//Read value again -calling this value C delay(50); //Read value again -calling this value D delay(50);
//Read value again -calling this value E
Check IF first value A is within 5 of the value B and within 5 of value C, etc.

I can think of a few round about ways of doing this but is there any simple "equals to plus or minus" notation? (what I actually want to do is to check a lot more values than this and it will get very complicated with any of my solutions)....

View 4 Replies View Related

C :: Find Prime Numbers - How To Use Bit Array

Aug 19, 2013

I wrote some code for class to find prime numbers.The teacher says that I need to revise my code with the requirement below: use a bit array to store the prime number checking. The bit array will also be in the heap. Use the max value of an unsigned 32-bt integer (UINT_MAX) to be the maximum size of the prime number you want to check.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <getopt.h>
#include <ctype.h>
#include <stdint.h>

//function to set all non-primes to 0
void *zero_multiples(void *threadid);

[Code] .....

View 4 Replies View Related

C :: How To Use Loops To Find Numbers From A List

Apr 27, 2013

i have to make a program where a user inputs one number and i have to find the number of a certain amount of number in the program.
for example:

user input: 2349354787839
output: There are two sevens

i know it has the use of loops but i am having trouble finding a way to scan each individual digit in the input to find if it is a seven or not.

View 8 Replies View Related

C :: Find Average Of Random Numbers

Aug 17, 2013

I have the random values down but when I try to assign randValue to another integer I get an error.I want to make an inner loop where I find 5 random number 50 times and print the average of those numbers.

I know I have the bare bones of the below, but without giving me a huge shove in the right direction can I have a poke? I have been programing for three months now. I have noticed when I do simple fun projects I learn more then what my professor assigned to me. The class is over but I want to keep building.C++ starts in one week...

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUMBERS 5

int main(int argc, const char * argv[]) {
float randValue = 0.0;
int i;

[code]....

View 9 Replies View Related

C++ :: Find All Prime Numbers In A Range

Oct 17, 2013

I am trying to create a program that lists all prime numbers within a range of two number. Why the below program isn't working?

#include <iostream>
using namespace std;
int main(){
int high_range;
int low_range;
int w;

[Code] .....

View 3 Replies View Related

C++ :: Find All Prime Numbers From 1 To 1000?

Jan 9, 2013

#include<iostream>
#include <cstdlib>
using namespace std;

[Code].....

View 10 Replies View Related

C++ :: Find The Prime Numbers Between Two Values?

Jan 26, 2013

i did a code that determine if the number is prime or not, and i have to do a one that finding the prime numbers between two variables .

the first code:

#include<iostream>
using namespace std;
int main(){

[Code].....

View 4 Replies View Related

C++ :: Find Remainder Of Two Many-digit Numbers

Aug 25, 2013

if i have two integers, say number1 and number2, stored in arrays where each index is a digit of the number (i.e. if my numbers are 321 and 158, then number1 = {3,2,1} and number2 = {1,5,8}), can i find the remainder of number1/number2? assume number1 > number2.

View 1 Replies View Related

C++ :: How To Find The Smallest Number Amongst 4 Numbers

Nov 28, 2013

How to find the smallest number amongst 4 numbers

View 10 Replies View Related

C/C++ :: Find Second Smallest Number Out Of 4 Numbers

Oct 23, 2014

I'm trying to find the second smallest number out of 4 numbers. I produced some code that does that but it doesn't work if i have duplicate numbers.

secondSmallest = a;
if(b > secondSmallest) {
secondSmallest = b;
}
if(c < secondSmallest) {

[Code] ....

View 1 Replies View Related

C/C++ :: Receive 20 Numbers Or Less And Find Average?

Apr 27, 2015

I made a program that is suppose to receive 20 numbers or less and find the average, then show all numbers entered but my average does not show. It shows as 0 and a line pops up after every number returned. I am stuck and dont know how to fix the logical errors.

#include <iostream>
#include <cmath>
using namespace std;
int main() {
float num[20];
int amount_num;

[Code] ....

View 3 Replies View Related

C/C++ :: Find Maximum Of Three Numbers Given By User?

Jan 25, 2014

I'm new to C++ and I'm trying to solve the question but there is just something wrong somewhere.

#include <iostream>  
using namespace std;  
int main() {
    int largest;
    int a;
    int b;
    int c;  
    cout<< "Enter first value";

[Code] ....

View 1 Replies View Related

C++ :: Find Smallest In Array Of 7 Numbers

Jul 17, 2012

When I run my program it just gives me 'The smallest number is: 2682760' which isn't true obviously.

Code:
#include <iostream>
int main() {
using namespace std;
int x, smallest;
int Array[7] = {7, 5, 10, 13, 3, 15, 54};
x = Array[0];

[Code] .....

View 3 Replies View Related

C/C++ :: Calculate Postfix Notation

Feb 15, 2015

My program suppose calculate postfix expression.

Ex. 5 4 + 3 10 * + the answer is 39 because if I change it to infix, it's (5 + 4) + (3 * 10)

I need to use vector to compute the value. Here is what I think. First, I save leftmost from the string. If it is a number, I push. If that is a operation, I pop twice and push the result. By doing it until the string is emptied, the vector will only contain the final answer. And here is my code

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
vector<int> stack;
string input;

[Code] .....

When I put 1 1 + or 2 2 +, it showing me a correct answer, but when I put the above example which is 5 4 + 3 10 * +, it shows 30 instead of 39.

View 8 Replies View Related

C/C++ :: Infix To Postfix Notation

Sep 14, 2014

I'm trying to make an infix to postfix notation calculator. The difficult thing is th stack class is custom. It's not to hard to understand, I don't know if the fact that it is that way will not allow me to receive support. The difference is that the pop functions is as such:

stack<char> conversion;
char temp;
conversion.pop(temp);//It receives a parameter and puts the popped element in there.
conversion.peek(temp);//Places the top element in said parameter

not only that... but these are boolean functions. they return true if the operation was completed. So they can be used as conditions.

#include<iostream>
#include<string>
#include<stdio.h>
#include"stack.h"
using namespace std;
int main(void) {
Stack<char> conversion;
string infix,inter,temps;

[Code] .....

The error is that i am mismanaging parenthesis handling and i can't seem to grasp where and how.

An example input is:(35+7)-(9-2)
that input gives me:35 7 + 9 2 ) -
but another input such as :(35+7)/7
outputs as: 35 7 + 7 /. Totally fine.

View 3 Replies View Related







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