I just wanted to know how to round my result to 2 decimal places.
Code:
#include <stdio.h>
#include <stdlib.h> /* For atoi() */
#include <ctype.h> /* For toupper() */
#include <string.h> /*For string operations*/
#include<iostream>
using namespace std;
int main() {
char* money1= "3.05";
char* money2= "2.56";
float avg = strtod(money1,NULL)/strtod(money2,NULL);
cout << avg <<endl;
}
This gives the result of 1.19141 but the answer i want is just 1.19, how do I get the number rounded to 2 decimal places?
Thanx again, u guys been really helpful