NO

Author Topic: a simple program - help  (Read 4522 times)

boral

  • Guest
a simple program - help
« on: December 24, 2011, 12:27:43 PM »
I am new to pellesc.When I compile the following program an error occurs. What is my fault?


int main()
{
   int p,n;
   float si,r;
   p=1000;
   n=3;
   r=8.5;
   /*formula for simple interest*/
   si=p*n*r/100;
   int printf("%f",si);
}

The following error is shown
Building programbs.obj.
C:\Users\user\Documents\programbs.c(12): error #2001: Syntax error: expected ')' but found 'string constant'.
*** Error code: 1 ***
Done.

What I will do?If possible please give a link to a guide book on c programming language that is compatible with Pellesc Version 6.50.8

czerny

  • Guest
Re: a simple program - help
« Reply #1 on: December 24, 2011, 01:07:21 PM »
Hallo,

you do not define or declare the function printf. But you USE it!
Therefore you should remove the 'int' in front of the printf.
To avoid the warning you get then, you should additionaly include the header file stdio.h.

Code: [Select]
#include <stdio.h>

int main()
{
   int p,n;
   float si,r;
   p=1000;
   n=3;
   r=8.5;
   /*formula for simple interest*/
   si=p*n*r/100;
   printf("%f\n",si);
}

czerny

boral

  • Guest
Re: a simple program - help
« Reply #2 on: December 24, 2011, 03:08:46 PM »
Thank you czerny for your effort.
Can anyone provide me a link to an ebook which helps in learning programming in C and is compatible with pellesc version 6.50.8 ?

Online Vortex

  • Member
  • *
  • Posts: 797
    • http://www.vortex.masmcode.com
Re: a simple program - help
« Reply #3 on: December 24, 2011, 03:45:11 PM »
Have a look at this one :

theForger's Win32 API Programming Tutorial

http://www.winprog.org/tutorial
Code it... That's all...

CommonTater

  • Guest
Re: a simple program - help
« Reply #4 on: December 24, 2011, 04:39:18 PM »
Thank you czerny for your effort.
Can anyone provide me a link to an ebook which helps in learning programming in C and is compatible with pellesc version 6.50.8 ?
The winpog tutorial is rather advanced.
 
If you're looking for beginning C ... which is usually done in console mode, you can try
http://en.wikibooks.org/wiki/C_Programming
 
 Then follow it with Vortex's suggestion for GUI mode windows programs. 
 
C is very standardized so both will work for you.  If you encounter something that isn't quite "as advertised" use the Pelles C help file (Press F1) as your final authority.

 

 
« Last Edit: December 24, 2011, 05:07:40 PM by CommonTater »