My First Program and have some compiling issues.

I will write a program here and please let me know what is the issue as it gives an error:
cc asgn2.c -o asign2
/tmp/cckFXXe0.o: In function `main':
asgn2.c:(.text+0x139): undefined reference to `print'
collect2: ld returned 1 exit status
The program I wrote as follows:
#include<stdio.h>
main()
{
int cust_id,counter;
float cur_bl,new_chgs,avail_crdt,crdt_lmt;
counter=0;
printf("Please Enter Customer ID or Enter 0 to terminate:\n",cust_id);
scanf("%d",&cust_id);
while(cust_id!=0)
{
printf("Enter Current Balance:",cur_bl);
scanf("%f",cur_bl);
printf("Enter New Charges:",new_chgs);
scanf("%f",new_chgs);
printf("Enter Credit Limit:",crdt_lmt);
scanf("%f",crdt_lmt);
cur_bl=cur_bl+new_chgs;
avail_crdt=crdt_lmt-cur_bl;
printf("For Customer ID:%d\n",cust_id);
printf("You now have a balance of :$%.2f\n",cur_bl);
printf("Your Credit Limit ïs:$%.2f",crdt_lmt);
if(avail_crdt>0)
print("Your available credit limit is now:$%.2f\n",avail_crdt);
else
printf("YOu have reached your credit limit\n");
counter++;
}
printf("This program will now terminiate\n");
printf("The total number of customers processed:%d\n",counter);
return 0;
}

Please tell what is wrong with the program.....................? Woudl really appreciate immediate help as I have to submit this assign...
The error points to the statement


print("Your available credit limit is now:$%.2f\n",avail_crdt);

where you made a typo. I think you meant printf instead of print

Also you shall not specify arguments for printf that are not used by the function. For example in thsi statement

printf("Please Enter Customer ID or Enter 0 to terminate:\n",cust_id);

argument cust_id shall be removed because it is not used.
Thanks so much for the prompy reply vlad..!
This was definitely helpful but I guess there is some logic error now.
As soon as I enter current balance , it says.."Segmentation fault".
Can i Send you the details of what i want to accomplish...?
In scanf you shall use addresses of variables that is instead of

scanf("%f",cur_bl);

you shall write

scanf("%f", &cur_bl);

Also function main shall be declared in C as

int main( void )
Last edited on
Thanks once again!
As you understood from my program, the output should be that once it tells me the balances and credt limit information, the program should ask me customer iD again and if I enter 0 , it should terminate it.
An also calculates the number of customers processed using that counter option...
However, my coding just updates the balance and available credit limit. It is not coming out of that loop...it does not ask me the customer id second time...and of course thus not adding up the number of customers processed.

I tried my best but to no avail :(..
Help!...!.!
I used goto function..........:) it works! yay!!!!!!!!!!!!!!
I have been told, I cannot use goto statement here in the program............but to use functions...........Can you help me..............?
This will be the last bit for thisprogram....
Help!
Topic archived. No new replies allowed.