PinoySource Forum - Computer & Technology Community Philippines
Register Blogs Groups Albums Arcade Members Mark Forums Read

Important Annoucement: Merging of PinoySource.org to FOS2.com (Click Here!)
Go Back   PinoySource.org > Computer & Technology Board > General Technology > Programmers Lounge
Reload this Page C Programming
C Programming within the Programmers Lounge forums - Discussion on Java, C, C++, C# and any other programming languages you can think of.

PinoySource - Computer and Technology Community Philippines

The Pinoy Source is an Information Technology Community of All Filipinos dedicated to the exchange of ideas and information relating to all aspects of Technology such as Tech News, Computer Hardware, Mobile & Gadgets, Internet & World Wide Web, Graphics, PSP, Pinoy Bloggers, Friendster, Music & anything and everything. PinoySource is also a social networking place where people chat, add friends, get to know our each other & form friendship. PinoySource is Powered by WordPress Blog for our homepage & Vbulletin for our forum discussions.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), Play Arcade, Chat using PS Chatbox, respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please,
join our community today!

If you have any problems with the registration process or your account login, please contact contact us.


Reply
 
Thread Tools Display Modes
  (#11) Old
romayne15 View romayne15's Photo Album is Offline
Junior Member
romayne15 is an unknown quantity at this point
 
romayne15's Avatar
 
Posts: 29

Referrals: 0
Thanks: 0
Thanked 0 Times in 0 Posts

Join Date: Jun 2008
Location: taguig city..
Age: 18
  Send a message via Yahoo to romayne15  
Points: 63.90
Default Re: C Programming - 06-13-2008, 06:34 AM

Age Calculator


#include <stdio.h>


main()
{
float years;
clrscr();
printf("Enter your age in years: ");
scanf("%f",&years);
printf ("\nYou are %.0f months old", years * 12);
printf ("\nYou are %.0f weeks old", years * 48);
printf ("\nYou are %.0f days old", years * 365);
printf ("\nYou are %.0f hours old", years * 8760);
printf ("\nYou are %.0f minutes old", years * 525600);
getch();
}


--xxpsychologicxx--
  
Reply With Quote
]
  (#12) Old
romayne15 View romayne15's Photo Album is Offline
Junior Member
romayne15 is an unknown quantity at this point
 
romayne15's Avatar
 
Posts: 29

Referrals: 0
Thanks: 0
Thanked 0 Times in 0 Posts

Join Date: Jun 2008
Location: taguig city..
Age: 18
  Send a message via Yahoo to romayne15  
Points: 63.90
Default Re: C Programming - 06-13-2008, 06:35 AM

Using strcmp or String Compare


#include<stdio.h>
#include<conio.h>
#include<string.h>


main()
{
char s1[20],s2[20];
clrscr();
printf("Enter a word:");
gets(s1);
printf("Enter a word:");
gets(s2);
if(!strcmp(s1,s2))
{
printf("The two words are equal");
}
else
printf("The two words are not equal");
getch();
}


--xxpsychologicxx--
  
Reply With Quote
]
  (#13) Old
romayne15 View romayne15's Photo Album is Offline
Junior Member
romayne15 is an unknown quantity at this point
 
romayne15's Avatar
 
Posts: 29

Referrals: 0
Thanks: 0
Thanked 0 Times in 0 Posts

Join Date: Jun 2008
Location: taguig city..
Age: 18
  Send a message via Yahoo to romayne15  
Points: 63.90
Default Re: C Programming - 06-13-2008, 06:44 AM

Salary Calculator


#include<stdio.h>
#include<conio.h>


main()
{
char name[80];
float workhrs, overtime, salary;
clrscr();

printf("\n Enter name: ");
scanf("%s",&name);
printf("\n How many hours have you been working\? ");
scanf("%f",&workhrs);
printf("\n\n\n Press any key to compute salary...");
getch();

if(workhrs>45)
{
if(workhrs>=45 && workhrs<=55)
{
overtime=workhrs-45;
salary=1350+(overtime*40);
printf("\n\n\n Hello %s! Your salary for this month is P%.2f",name,salary);
}
else
{
overtime=workhrs-45;
salary=1350+(overtime*40)+200;
printf("\n\n\n Hello %s! Your salary for this month is P%.2f",name,salary);
}
}
else
{
salary=workhrs*30;
printf("\n\n\n Hello %s! Your salary for this month is P%.2f",name,salary);

}

getch();
}


--xxpsychologicxx--
  
Reply With Quote
]
  (#14) Old
romayne15 View romayne15's Photo Album is Offline
Junior Member
romayne15 is an unknown quantity at this point
 
romayne15's Avatar
 
Posts: 29

Referrals: 0
Thanks: 0
Thanked 0 Times in 0 Posts

Join Date: Jun 2008
Location: taguig city..
Age: 18
  Send a message via Yahoo to romayne15  
Points: 63.90
Default Re: C Programming - 06-13-2008, 06:50 AM


Using Do While..


#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
char menu, a, b, c, d, e, A, B, C, D, E;
int x,y;
do{
clrscr();
textcolor(LIGHTBLUE);
gotoxy(25,9); cprintf("[A] SNOOPY ");
gotoxy(25,10); cprintf("[b] MICKEY MOUSE ");
gotoxy(25,11); cprintf("[C] HELLO KITTY ");
gotoxy(25,12); cprintf("[D] TAZMANIA ");
gotoxy(25,13); cprintf("[E] EXIT ");
gotoxy(22,16); cprintf("ENTER YOUR CHOICE: ");
menu=getche();
if(menu=='a' || menu=='A'){
clrscr();
gotoxy(25,12);printf("HAPPINESS\r");
printf("\xAA");}
if(menu=='b' || menu=='B'){
clrscr();
gotoxy(25,12);printf("BEAUTY");}
if(menu=='c' || menu=='C'){
clrscr();
gotoxy(25,12);printf("TRUST");}
if(menu=='d' || menu=='D') {
clrscr();
gotoxy(25,12); printf("LOVE");}
if(menu=='e' || menu=='E') {
clrscr();
gotoxy(25,12); printf("BYE"); }
getch();
}
while(menu!='e' && menu!='E');

getch();
}


--xxpsychologicxx--
  
Reply With Quote
]
  (#15) Old
flint0131 View flint0131's Photo Album is Offline
Junior Member
flint0131 is an unknown quantity at this point
 
flint0131's Avatar
 
Posts: 10

Referrals: 0
Thanks: 0
Thanked 0 Times in 0 Posts

Join Date: May 2008
Age: 17
  Send a message via Yahoo to flint0131  
Points: 27.12
Default Re: C Programming - 06-24-2008, 11:29 PM

Wow!! nice codes!! i added this topic on my bookmarks.. ;P

hmm..

guys, may problem ako installing Borland C++

pag inopen ko ung compiler, magoopen xa tapos biglang sasara..

huhuhu...
  
Reply With Quote
]
  (#16) Old
kenmuyot2628 View kenmuyot2628's Photo Album is Offline
Junior Member
kenmuyot2628 is an unknown quantity at this point
 
kenmuyot2628's Avatar
 
Posts: 3

Referrals: 0
Thanks: 0
Thanked 0 Times in 0 Posts

Join Date: Jun 2008
Location: Pateros, Metro Manila
Age: 17
  Send a message via Yahoo to kenmuyot2628  
Points: 8.10
Default Re: C Programming - 06-25-2008, 09:03 AM

#include<stdio.h>
#include<conio.h>
void main (void)
{
int b, h, s1, s2, s3, per;
float area;
char compute;
clrscr();
printf("\nWhat do you want to compute? [p=perimeter, a=area]");
scanf("%c",&compute);
if (compute=='p') {
printf("\nEnter one side of the triangle. ");
scanf("%d",&s1);
printf("\nEnter another side of the triangle. ");
scanf("%d",&s2);
printf("\nEnter the last side of the triangle. ");
scanf("%d",&s3);
per=s1+s2+s3;
printf("\nThe perimeter of your triangle is %d",per);
}
else if (compute=='a') {
printf("\nEnter the base of your triangle. ");
scanf("%d",&b);
printf("\nEnter the height of your triangle. ");
scanf("%d",&h);
area=0.5*b*h;
printf("\nThe area of your triangle is %.2f",area);
}
else
printf("Invalid Choice.");
getch();
}

hehehe simple lang muna.... hello carla! c janessa ang may kasalanan kung bkt nand2 ako. heheh


hello guyZ... add naman sa friendster. =) kim_muyot@yahoo.com ! wahaha
  
Reply With Quote
]
  (#17) Old
littlecut View littlecut's Photo Album is Offline
Super Moderator
littlecut is an unknown quantity at this point
 
littlecut's Avatar
 
Posts: 286

Referrals: 6
Thanks: 13
Thanked 3 Times in 3 Posts
Blog Entries: 6

Join Date: May 2008
Location: Inside a Cup
  Send a message via Yahoo to littlecut  
Points: 753.56
Default Re: C Programming - 07-23-2008, 02:01 PM

Convertion Program
Base N to Base 10
Base 10 to Base N

#include<stdio.h>
int convert(char Input);
char revert(int Input);

void main(){
char Choice,InputS[255];
int Base,InputD=0,Ctr,Max,Flag,Idx=1;
do{
clrscr();
printf("<---------Base Convertion Program--------->\n\n [A] Any Base to Base 10 (BN to B10)\n [b] Base 10 to Any Base (B10 to BN)\n\n [E] xit\n\n");
printf("Enter Choice: ");
scanf("%c",&Choice);
switch(toupper(Choice)){
case 'A': do{
printf("Enter Base and a Value of that base [B:N] ");
scanf("%d:%s",&Base,&InputS);
Max=strlen(InputS);
for(Ctr=Max-1,Flag=0;Ctr>=0;Ctr--){
if(convert(InputS[Ctr])>=Base){
printf("Error! Invalid Character Detected!\nRe-");
Flag=1;
Ctr=-1;
}
else{
InputD+=Idx*convert(InputS[Ctr]);
Idx*=Base;
}
}}while(Flag!=0);
printf("Output Value is %d in base 10",InputD);
break;
case 'B': printf("Enter Value of Base 10: ");
scanf("%d",&InputD);
printf("Enter Base of Output: ");
scanf("%d",&Base);
for(Ctr=0;InputD>0;Ctr++){
InputS[Ctr]=revert(InputD%Base);
InputD/=Base;
}
Max=Ctr-1;
while(Max>=0){
printf("%c",InputS[Max]);
Max--;
}
break;
}
getch();
}while(toupper(Choice)!='E');
}


int convert(char Input){
switch(toupper(Input)){
case '0':return 0;
case '1':return 1;
case '2':return 2;
case '3':return 3;
case '4':return 4;
case '5':return 5;
case '6':return 6;
case '7':return 7;
case '8':return 8;
case '9':return 9;
case 'A':return 10;
case 'B':return 11;
case 'C':return 12;
case 'D':return 13;
case 'E':return 14;
case 'F':return 15;
}
}
char revert(int Input){
switch(Input){
case 0:return '0';
case 1:return '1';
case 2:return '2';
case 3:return '3';
case 4:return '4';
case 5:return '5';
case 6:return '6';
case 7:return '7';
case 8:return '8';
case 9:return '9';
case 10:return 'A';
case 11:return 'B';
case 12:return 'C';
case 13:return 'D';
case 14:return 'E';
case 15:return 'F';
}
}


  
Reply With Quote
]
  (#18) Old
bluefox201 View bluefox201's Photo Album is Offline
Senior Member
bluefox201 is an unknown quantity at this point
 
bluefox201's Avatar
 
Posts: 120

Referrals: 0
Thanks: 1
Thanked 0 Times in 0 Posts

Join Date: Jun 2008
   
Points: 193.76
Default Re: C Programming - 07-23-2008, 09:38 PM

hehehe dko mxado kbsado 2, ms prefer ako s c++ hehe

pro mejo naintndhan ko rn ang ibang code, my pgkasimilarity dn kc.
  
Reply With Quote
]
  (#19) Old
bluefox201 View bluefox201's Photo Album is Offline
Senior Member
bluefox201 is an unknown quantity at this point
 
bluefox201's Avatar
 
Posts: 120

Referrals: 0
Thanks: 1
Thanked 0 Times in 0 Posts

Join Date: Jun 2008
   
Points: 193.76
Default Re: C Programming - 07-23-2008, 09:45 PM

Quote:
Originally Posted by flint0131 View Post
Wow!! nice codes!! i added this topic on my bookmarks.. ;P

hmm..

guys, may problem ako installing Borland C++

pag inopen ko ung compiler, magoopen xa tapos biglang sasara..

huhuhu...
dude bka virus hehehe
  
Reply With Quote
]
  (#20) Old
salbahe View salbahe's Photo Album is Offline
Junior Member
salbahe is an unknown quantity at this point
 
salbahe's Avatar
 
Posts: 15

Referrals: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Blog Entries: 1

Join Date: Aug 2008
Location: plaridel bulacan
Age: 21
  Send a message via Yahoo to salbahe  
Points: 39.86
Default Re: C Programming - 08-30-2008, 09:31 PM

turuan nyo nmn ako mga master sa C Programming =D gusto ko pa ma enhance nalalaman ko sa C Programming..thnks po
  
Reply With Quote
]
Reply

Tags
programming, turbo c

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

PinoySource.org Computer & Technology Community Philippines, Copyright ?2008, by johnxarce

Online Users