Simple program - Where have i gone wrong?
From: ali (tj_at_raha.com)
Date: 10/31/04
- Next message: Alwyn: "Re: Simple program - Where have i gone wrong?"
- Previous message: James Dennett: "Re: declaration vs. defintion"
- Next in thread: Alwyn: "Re: Simple program - Where have i gone wrong?"
- Reply: Alwyn: "Re: Simple program - Where have i gone wrong?"
- Reply: Pedro Graca: "Re: Simple program - Where have i gone wrong?"
- Reply: Kevin Anthoney: "Re: Simple program - Where have i gone wrong?"
- Reply: ali: "Re: Simple program - Where have i gone wrong?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 31 Oct 2004 16:15:16 -0500
Hi,
I've got this simple program i'm trying to run, but am not getting the
correct answer. Will appreciate if someone could help me out..
I'm compiling this using gcc under linux
==============
#include <stdio.h>
int main()
{
int counter=0;
double sum=1;
double a;
int b;
scanf("%f", &a);
scanf("%i", &b);
while(counter<b)
{
sum = sum * a;
counter ++;
}
printf("%f\n", sum);
return 0;
}
If i run this, and enter 2 2, i get 4, but if i try to run 3 3, it
gives me 32768.00000
Thanks,
Ali
- Next message: Alwyn: "Re: Simple program - Where have i gone wrong?"
- Previous message: James Dennett: "Re: declaration vs. defintion"
- Next in thread: Alwyn: "Re: Simple program - Where have i gone wrong?"
- Reply: Alwyn: "Re: Simple program - Where have i gone wrong?"
- Reply: Pedro Graca: "Re: Simple program - Where have i gone wrong?"
- Reply: Kevin Anthoney: "Re: Simple program - Where have i gone wrong?"
- Reply: ali: "Re: Simple program - Where have i gone wrong?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|