C++ :: Float Function Of Percentage

May 28, 2013

Below is the code of a program using classes and functions ,, my float function doesn't show answer in fractions ,, show something else...

#include <iostream>
using namespace std;
class khan{
public:
void print(){
cout<<"welcome to the online Addition System!!!" <<"

[Code] ...

View 6 Replies


ADVERTISEMENT

C++ :: Making Float To String Function

Jan 23, 2015

I have this:

void reverse(char *in, int isize) {
char t = 0;
for( int a = 0; a < isize / 2; a++ ) {
t = in[a];
in[a] = in[(isize - 1) - a];
in[(isize - 1) - a] = t;
[Code] .....

s:
float:123456
s:123456

The function i made is working fine, exacly how cout << float is working. The problem is i think my function is not really effective. By that i mean my function is doing alot of useless stuff to do what i want and there have to be a better way.

The rule is that you can not use other functions, only playing with loops and operators.

View 5 Replies View Related

C :: Convert Float To String In Order To Use Strlen Function

Apr 4, 2013

Any really simple way of converting the following float to a string so I can take strlen()?

float a = 53213421;

strlen(a)?

I have looked up solutions but they are either too long or they confuse me.

View 2 Replies View Related

C :: Passing Int And Float Variables From Main And Getting Values From Another Function

Feb 3, 2015

I have the main() - which has entries like

Code:

main() {
int ss, ret, z;
float yy;
ret = function1(&yy, &ss, &z);
//int function1(flat *cc, int *dd, int *k) - is it correct?

[Code]...

View 5 Replies View Related

C++ :: Turning A Limited Float Into Another Float?

Nov 20, 2013

I can do the folowing:

float var1 ;
var1 = 9.12345 ;
printf("%.2f",var1) ;

the output will be 9.12. What if I wanted to save that as another separate float with displaying it on screen?

View 1 Replies View Related

C/C++ :: Cannot Convert Float To Float Assignment

Jun 8, 2014

#include <iostream>
#include <string.h>
#include <sstream>

[Code]....

View 1 Replies View Related

C++ :: Create Main Function With One Dimension Dynamic Array With Float Data Type

Dec 4, 2013

I need to create a main function with a one dimension dynamic array with float data type. The total number of array elements must be controlled by a user input from the keyboard. Test data is three different lengths 3,6,9 of the array. The lengths have to be set up at run time from users input. I understand how to create dynamic array but not where the user inputs the length of the array. How would I implement this?

View 6 Replies View Related

C++ :: Looping And Calculate The Percentage?

Mar 7, 2013

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

[Code].....

I AM HAVING TROUBLE CALCULATING THE PERCENTAGE. I HAVE TO CALCULATE THE AMOUNT OF MONEY FOR 6 YEARS.

View 1 Replies View Related

C++ :: Show Percentage When File Is Being Updated

Jun 19, 2014

I want to update a file but I want to show the percentage when it is being updated. How can I do this? Do I need to use threads?

View 2 Replies View Related

C++ :: Program To Display Percentage Of Calories Come From Fat

Mar 18, 2013

Write a program that asks the user to enter the number of calories and fat grams in a food item. The program should display the percentage of the calories that come from fat. One gram of fat has 9 calories, so:

(Calories from fat) = (fat grams) * 9

The percentage of calories from fat can be calculated as:

(Calories from fat) / (total calories)

Extend as follow

1. The user first enters from a menu whether it is breakfast (B or b), lunch (L or l) or dinner (D or d). Use character and process by a switch.
2. The threshold for low calorie is different, for breakfast 10%, lunch 20%, dinner 30% (this value has to be assigned to some threshold variable in the above switch).
3. Include validation of menu choice.
4. In case any validation fails, display detailed error and exit the program by calling return 1 or return EXIT_FAILURE
5. Display the % from fat with one decimal digit.

Example 1:
What you have to eat:
B - breakfast
L - lunch
D - dinner
What you have: C
Error: C is not a valid menu choice

Example 2:
What you have to eat:
B - breakfast
L - lunch
D - dinner
What you have: L
How many calories: 600
How many grams of fat: 10
Your food has 15.0% calories from fat
It is a low calories food

Process the menu in a switch, setting the threshold as either 10, 20, or 30%. The rest of the program will be the same regardless what was the menu choice.

Incremental development: first do the textbook problem without input validation, then extend with validation, then extend for the additional parts.

View 4 Replies View Related

C# :: Progress Bar Percentage Disappears When Loading

Mar 1, 2014

Why does my progressbar percentage text disapear when progressbar starts loading?? Am I missing out anything?

int percent = (int)(((double)(progressBar1.Value - progressBar1.Minimum) /
(double)(progressBar1.Maximum - progressBar1.Minimum)) * 100);
using (Graphics gr = progressBar1.CreateGraphics()) {
gr.DrawString(percent.ToString() + "%",
SystemFonts.DefaultFont,

[Code] ....

View 1 Replies View Related

C :: User Inputted Validated Grade As Percentage

Jan 2, 2014

I am trying to get this program to accept two inputs Student number and grade and validate them both

However the program skips over the student number

Code attached AssignmentProgram.c

View 1 Replies View Related

C++ :: How To Compare Two Files And Display Their Comparison Percentage

Feb 10, 2013

How to compare two files(two texts documents) and display their similarity percentage by using C++?

View 10 Replies View Related

C# :: Constant Read CPU Percentage And Display It To Textbox?

Feb 18, 2015

What I need to do Is constantly read the cpu percentage and display it to a textbox, but the issue is I am using the windows form not the console so I cant use a while loop. I think my best bet is to use an event, but I am not sure how.

View 6 Replies View Related

C/C++ :: Calculate Cost From Wholesale To Final With Percentage Markup

Apr 15, 2014

Program calculates cost from wholesale to final cost with percentage markup!

#include <iostream>
using namespace std;
int calculate_retial(int,int);
int main () {
int wholesale;
int markup;
int cost;

[Code] ....

View 5 Replies View Related

C/C++ :: Calculate Percentage Of Even Numbers Entered By User In Array

Nov 18, 2014

exercise in c: write a program which calculates % of even numbers entered by a user in an array;

1) check if user hasn't entered float value; if has issue warning;
2) give the option for user to press "stop" to exit program any time.

int c,sk[100],i,sum1=0, sum2=0, rel;
printf ("How many numbers will you enter?
");
scanf ("%d", &c);
printf ("Enter %d numbers (to exit program press - stop)
", c);

[Code] ....

View 1 Replies View Related

C/C++ :: Create Program To Calculate A Percentage For Commission And Bonus?

Feb 11, 2014

I am using codeblocks for school and I am trying to create a program to calculate a percentage for commission and a bonus. I have tried using a decimal for percentage, int and floats with casting. Every time it I try it displays 0 or just the bonus. I even took and did a test page. My head is about to pop.

Write an algorithm that can be used to calculate the commission earned in a real estate transaction. The chart below describes the formulas used to calculate the commission.

Sales Price Commission
Less than $100,000 5% of Sales Price
$100,000 to $300,000 $5,000 + 10% of Sales Price over $100,000
More than $300,000 $25,000 + 15% of Sales Price over $300,000

// Commission and Bonuses.
#include <iostream>
#include <iomanip>

[Code].....

View 2 Replies View Related

C++ :: Program To Calculate Total Grade For N Classroom Exercises As Percentage

Mar 5, 2013

Write a program that calculates the total grade for N classroom exercises as a percentage. The user to input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total point possible) and output it as a percentage. Sample input and output it as a percentage. Sample input and output is shown below.

How many exercises to input?
score1: 10
total points possible: 10
score2: 7
total points possible: 12
score3: 5
total points possible: 8

Code:
# include <iostream>
using namespace std;
int main () {
double N=0, score, total, totalScore=0, totalGrade=0, GRADE;
cout<<"How many excersices will be scored?/n";

[Code] .....

Error:
1>------ Build started: Project: HOMEWORK5, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:UsersWORKHOMEWORK5DebugHOMEWO… : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

View 4 Replies View Related

C++ :: Calculate Percentage Of Times Coin Flipped Either Heads Versus Tails

Feb 10, 2015

I'm having trouble getting the program to calculate the percentage of times it flipped either heads versus tails. I realize what I currently have doesn't work because above I initialized heads and tails by giving them values of 0, but I'm unsure of how to fix it.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main () {
srand(time(0));

[Code] .....

View 2 Replies View Related

C++ :: Dice (with Varying Number Of Sides) Program To Calculate Percentage Of Results

Oct 28, 2013

I am trying to code and compile a program that requests a uses to first inpu the number of sides they wish for a dice to have and secondly input the number of dice throws they would like to calculate the value for. The program will print an error message and default the number of sides the dice has to 5 if the number entered is below 4. Finally it will print out a percentage figure for each value that results from all the the dice rolls.

I have attached my header, driver and class files below along with accompanying error messages below them

// file name Exercise.cpp
#include <iostream>
#include "Die.h"
using namespace std;
int main() // the main program begins here
{
char restart = 'y'; // declare variables
double numRolls = 0.0;
int diceTot = 0;

[Code] .....

View 5 Replies View Related

C++ :: How To Covert Int To Float

Oct 12, 2013

I have a question here

How I want to convert an int to float in the middle of the program

#include <iostream>
using namespace std;
int main()
{
int x;
float y;
cin>> x;
y= (float)x;
cout<< y;
}

is this line correct y= (float)x;?

View 2 Replies View Related

C++ :: Determining If A Float Is Odd / Even

Oct 22, 2013

determining if a value entered in loop is an odd or even number. Also, the value can't be int because it may be a decimal value(therefore i cant use the if(x%==0).

I need to replace the if(value%2 ==0) else num_even++ statement in my code with something else that will work with float to determine odd vs even.

#include <iostream>
using namespace std;
int main() {
int num_values;
float sum_values = 0;
int num_neg_values = 0;
int num_pos_values = 0;

[code]....

View 1 Replies View Related

C/C++ :: Integer And Float Value?

Feb 28, 2014

this is my code

#include<stdio.h>
main()
{

[Code]....

N=1st number M=2nd number(accrding to my prof we will name it N and M
ctr= increment of factorial of N, ctr2= increment of factorial of (N-M)

the problem is when i got the factorial of N / factorial of (N-M) i need to get the last non zero digit. so i use mod if it has zero in it. but mod can be only used with an int value. and when i change it to int value, the value of fact1 which is a float change

View 14 Replies View Related

C++ :: 32 / 64 / 80 Bit Float Conversion?

Feb 14, 2012

I am looking for a math/big num library, that allows me to convert 32/64/80 bot float numbers to string and vice versa.

Precision & accuracy is of importance here, and since this is an IEEE standard, i have high hopes that there are libraries for this out there, which would save me the hassle of trying to implement this myself...

View 1 Replies View Related

C :: Can't Show The Proper Float Value

Jul 7, 2014

I am working from my "ansi c" book by steven lawlor, page 73 program 2. write a program that accepts two numbers from the keyboard and prints the following information.

variables
first
second
execution
First number ? 7
Second number ? 2
the second goes into the first 3 times
with a remainder of 1.
the quotient is 3.5.

Code:
#include <stdio.h>
main() {
int first, second;
scanf(" %1i %1i", &first, &second);
printf("First number ? %1i

[Code] ....

//I included this as I had some error message come up
// before, not sure if this is correct though?
} it shows what is expected but I cant get the 3.5.

I have tried %f and variations of width/precision but still not luck. Also, when I click on the application and put in the variables I press enter, the program executes and disappears so I cant see the result. how do I get the program to stay up until I want to get rid of it?

View 1 Replies View Related

C :: Float Showing Nothing In Printf

Oct 6, 2014

I just checking but confused with float. in that code same size int, and same type double are working but float showing nothing in printf..why?? i'm using GCC compiler int 32bit win7 os

Code:
#‎include <stdio.h>
int main() {
char arr[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
printf("Size of char=%c
", ((char *) (&arr[0]))[1]);

[Code] ....

View 14 Replies View Related







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