Why am I getting 123.123000 in the output?
I'm trying to understand to why I'm not getting 123.123 in the output. Should I be using the f instead of lf ?
#include <stdio.h>
void main() {
double foo = 123.123;
int blah = 54321;
printf("%d\n", blah);
printf("%10d \n", blah);
printf("%08d\n",blah);
printf("%10d \n", blah);
printf("%010d \n", blah);
printf("%lf\n", foo); // Why am I getting 123.123000?
printf("%.4f\n", foo);
printf("%4.2f \n", foo);
}
Copyright License: Author:「Zack」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer. Link to:https://stackoverflow.com/questions/40352160/why-am-i-getting-123-123000-in-the-output
About “Why am I getting 123.123000 in the output?” questions
I'm trying to understand to why I'm not getting 123.123 in the output. Should I be using the f instead of lf?
#include <stdio.h>
void main() {
double foo = 123.123;
int blah = 5432...
|
int main()
{
int x;
float y;
char c;
x = -4443;
y = 24.25;
c = 'M';
printf("\nThe value of integer variable x is %f", (float)x);
printf("\nThe value of float variable y
|
import java.util.HashMap;
public class Map {
public static void main(String[] args) {
// TODO Auto-generated method stub
int arr[] = {10, 3, 34, 3, 10};
HashMap<Integ...
|
why am I getting 20 in the output as auto variables have block scope?
#include <stdio.h>
int main(void) {
int a=0;
{
int a=10;
printf("%d",a);
a++;&
|
#include <stdio.h>
#define MAX_SIZE 1000 // Maximum array size
int main() {
int arr[MAX_SIZE], size, i;
int max1, max2;
scanf("%d", &size);
max1 = max2 = ...
|
This is my C++ program:
#include <iostream>
using namespace std;
int main()
{
int a = 1;
int b = 2;
if(a-- > 0 || ++b > 2){
cout << "
|
I have a pretty simple question really - why am I getting no output? This is the site: https://riven.market/list/PC/Veiled. I thought the problem was the spaces in class name but turns out its natu...
|
Whenever I am writing this following code, I am getting garbage(unexpected) output in some online compiler, but if I use code block then getting satisfied output. So my question is why I am getting...
|
So I'm trying to swap two numbers without using a third variable. I pass the two numbers I'm trying to swap by reference. When the same number is to be swapped (like 1 is to be swapped with 1), I g...
|
I am executing
git branch --contains d54ede4e40364def648b30f7a8c567e1240c1225
this git command it should give me the branch name for the specified commit Id only as per my knowledge.
The output I...
|
|
|