My output doesn't match anything...and the program is pretty simple


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers My output doesn't match anything...and the program is pretty simple
# 1  
Old 09-21-2008
My output doesn't match anything...and the program is pretty simple

This is what I have:
#include <stdio.h>

int main (void)
{
int integerVar;
int floatingVar;
int doubleVar;
int charVar;

integerVar = 100;
floatingVar = 331.79;
doubleVar = 8.44e+11;
charVar = 'W';

_Bool boolVar;

boolVar = 0;

printf ("integerVar = %i\n", integerVar);
printf ("floatingVar = %f\n", floatingVar);
printf ("doubleVar = %e\n", doubleVar);
printf ("doubleVar = %g\n", doubleVar);
printf ("charVar = %c\n", charVar);

printf ("boolVar = %i\n", boolVar);

return 0;
}
And this is what I got:
integerVar = 100
floatingVar = 0.000000
doubleVar = 6.674375e-308
doubleVar = 6.67437e-308
charVar = W
boolVar = 0
I don't know why the floatingVar and doubleVar's don't work. Does anybody know why this is?

I'm supposed to get:

integarVar = 100
floatingVar = 331.790009
doubleVar = 8.440000e+11
doubleVar = 8.44e+11
charVar = W
boolVar = 0

-- I'm using something I have never used before about a week ago, a program called Dev-C++ to write and compile and I'm using Command Prompt's bash to run it.

If anybody can figure out why I can't compile and run through Dev-C++, that would also be very helpful.

Last edited by pwanda; 09-21-2008 at 08:28 PM.. Reason: Forgot what program output is supposed to look like.
# 2  
Old 09-21-2008
Code:
int integerVar;
int floatingVar;
int doubleVar;
int charVar;

Why have you declared them all as 'int's when they are not? Try:

Code:
int integerVar;
float floatingVar;
double doubleVar;
char charVar;

# 3  
Old 09-21-2008
Thanks. :]

Now I feel stupid for not seeing that--and even worse for reading the original program wrong. Smilie
# 4  
Old 09-21-2008
But that's what computers are for... to make us look stupid. Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Can C program put message to IBM MQ remotely, if local server doesn't have MQ library?

Can somebody know if it is possible to connect to remote IBM MQ, if local server using C, but don't have MQ library? Thanks for contribution (0 Replies)
Discussion started by: digioleg54
0 Replies

2. Shell Programming and Scripting

Sdiff doesn't try and compare to closest match

In the example below i would want the extensions to match. Is there any other utility or script to achieve this. Kindly help. Example: sdiff sourceFileNames targetFileNames 17021701P.blf | 17021901P.ibk 17021701P.chn | 17021901P.irk 17021701P.bmr | 17021901P.dyd 17021701P.dpf |... (7 Replies)
Discussion started by: jamilpasha
7 Replies

3. Linux

Ssh key doesn't match

I'm loged on server A as user infa8. I want to login via ssh key on server B as user ussdsc. destination server (B) is a redHat 6.2. Permissions for ussdsc@B for home, ssh and authorized_keys: $ ls -ltr | grep ussdsc drwxr-xr-x. 29 ussdsc mobifon 4096 Feb 18 11:43 ussdsc $ getfacl... (8 Replies)
Discussion started by: black_fender
8 Replies

4. Shell Programming and Scripting

Swap usage by top and free command doesn't match

Its rather confusing, the output of top command is below: The "swap" field of top is described by the manpage as: "The swapped out portion of a task's total virtual memory image." But the output of free command suggests something else and it does tally with the output of swapon... (3 Replies)
Discussion started by: proactiveaditya
3 Replies

5. Solaris

Error: svcs: Pattern 'pooladm.conf' doesn't match any instances

Hi, I got the following errors during zfs resource pool configuration. Please help. Thanks. # svcs *pool* svcs: Pattern 'pooladm.conf' doesn't match any instances STATE STIME FMRI # svcadm enable system/pools:default # svcs *pool* svcs: Pattern 'pooladm.conf' doesn't match any... (4 Replies)
Discussion started by: aixlover
4 Replies

6. Shell Programming and Scripting

Simple Pattern Match

Hello ! Experts, I saw a ton of postings here about Awk pattern matching and even after going through all of it, what I have concocted isnt working for me. Here is what I am after. I have a huge set of csv files and in the fifth column, I have text like this --- ANFD10239CS9 BCDD93948CS9... (5 Replies)
Discussion started by: PG3
5 Replies

7. Shell Programming and Scripting

Simple regexp doesn't work

I'm pretty experienced with regexps, but I just can't get this expression to work. The first line of my test file is this: **** info Fri Jun 04 12:37:58 PDT 2010 stuff I'm piping this file into this: egrep '^****\s++*Fri Jun 04' This returns 0 lines. If I change the... (7 Replies)
Discussion started by: dkarr
7 Replies

8. Shell Programming and Scripting

OS differences in simple pattern match

Hi folksSorry if code tags don't work out correctly but this PC does not have Java setup correctly to allow me to put them inproperly.I have a simple string pattern match behaving differntly on AIX and Solaris 10 and I don't understand why or what to do about it.This simple test: -) ]] && echo... (4 Replies)
Discussion started by: steadyonabix
4 Replies

9. UNIX for Dummies Questions & Answers

echo $PATH doesn't match $HOME/.profile

This is on a Solaris 9 box, but I feel like a noob, so I am posting here. When I echo $PATH I get a lot of duplicate paths and extra stuff I don't need. What I want is just what I set up in my home dir under .profile My login shell=/bin/bash I checked the following and there are no path... (1 Reply)
Discussion started by: Veestan
1 Replies

10. UNIX for Dummies Questions & Answers

HELP ASAP.. pretty simple..

Hey guys.... couple questions... I am working a problem set and can't answer this: 1) Suppose you are in a directory that contains a file called "foo." You want to create a new file called "bar" that contains the sorted contents of "foo" in the parent directory of the one you're in. How... (8 Replies)
Discussion started by: ugakid
8 Replies
Login or Register to Ask a Question