Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 29, 2024, 05:44:29 17:44


Login with username, password and session length


Pages: [1]
Print
Author Topic: Counter-timer  (Read 3478 times)
0 Members and 1 Guest are viewing this topic.
Modernpromete
Guest
« on: December 04, 2007, 12:58:18 12:58 »

i need help with counters,
i want make a counter 0 to 10
this is simpla samples but i didn't make it
i use CCS and please write this compiler codes
thanks...
Logged
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #1 on: December 04, 2007, 05:16:49 17:16 »

Hello Modernpromete,

Quote
i want make a counter 0 to 10
this is simpla samples but i didn't make it

What's that  Huh Huh
Make sure you ask your questions clearly enough, if you expect answers from others  Angry

Quote
i use CCS and please write this compiler codes

Make sure you understand the fact that we're here to help each other & not to do your work for you.
Next time, try some things for yourself first, post some code that is giving trouble. I guess then only someone will bother to reply such posts.  Lips sealed

regards,
sam_des
« Last Edit: December 04, 2007, 05:24:41 17:24 by sam_des » Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
robban
Senior Member
****
Offline Offline

Posts: 265

Thank You
-Given: 34
-Receive: 38


Warrior


WWW
« Reply #2 on: December 05, 2007, 01:32:16 01:32 »

//Example of a counter from 1 to 10. It will output Yout deposit every year from year 1 to 10
//This I compiled with Bloodshed Devcpp(GNU) as a console project so You will be able to see the output through 'system("pause")'
//I guess You're quite new to C. so I suggest You download the free Devcpp. It's almost standard nowadays.
//This example could be written for CCS inside MPLAB since MPLAB has a debugging facility with a "virtual screen",
//but something You have to do for Yrself.

#include <stdio.h>   //All I/O operations(keyboard,screen a.s.o.)
#include <stdlib.h>  //necessary for system("pause")

#define NO_OF_YEARS 10  //regard all the '#define' as macro's
#define INTEREST 3.5  //fixed interest
int main ()
{
   float capital;   //does'nt have to be an integer
   int year;        //must be an integer
   printf("Deposited capital? "); scanf("%f", &capital);// here You key in Your deposit with scanf
   printf("\n Year     Holding\n ====     =======\n");// Just formatting
   
   for (year = 1;year <=NO_OF_YEARS; year++) //here's Your 1 to 10 counter
   {                                         //the '{' and finishing '}' make the for loop repeat 10 times
   capital = capital * (1 + INTEREST/100); //the actual calculation
   printf("%3d%13.2f\n", year, capital); //print according to the above format
}
   system("pause");
}  //Here You don't need any RETURN. main() doesn't expect any, but You have to have  one main() in Yr. program

//Cheers Robban...
« Last Edit: December 06, 2007, 01:42:52 01:42 by robban » Logged

Code Warrior
belinao
Newbie
*
Offline Offline

Posts: 16

Thank You
-Given: 1
-Receive: 12


« Reply #3 on: December 09, 2007, 06:57:10 06:57 »

do u want to display it?

be more specific...
Logged
charnyutk
Newbie
*
Offline Offline

Posts: 32

Thank You
-Given: 7
-Receive: 5


« Reply #4 on: December 24, 2007, 04:59:37 04:59 »

like this?
void main(void){
int8 i;
for(i=0;i<10;i++);
}
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC