turbo c switch statement - PINOYDEN


Go Back   PINOYDEN > PC Zone > Programming

Welcome to PinoyDen Forums.

You are currently browsing our forum as a guest, please consider registering to get full access to all of our forum features, download free games, get help for your pc and cellphone problems and learn new mobile tricks like how to browse the internet using your cellphone for free. All that and more, so what are you waiting for, JOIN us now!!!! Click here to register...
 Topic: turbo c switch statement  (Read 5225 times)
0 Members and 1 Guest are viewing this topic.
Pages: [1]   Go Down
10-20-10 10:36 PM
  • Full Member
  • ***
  • Offline
 
Posts: 960
Thank You: 137
Reputation: 0
cloudzz has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
please help me! i'm begging you.
can someone explain this to me further?
by syntax po.

write a program that accepts dates written in numerical formand outputs in complete form.
ex: 2 26 1986
output - February 26, 1986

#include<stdio.h>
main()
{
int m, d[2], y[4], i;
clrscr();
i=0;
printf("Enter date in numerical form:\n");
scanf("%d %d %d", &m, &d, &y);
switch (m) {
case 1: printf("January %d, %d", d, y); break;
case 2: printf("February %d, %d", d, y); break;
case 3: printf("March %d, %d", d, y); break;
case 4: printf("April %d, %d", d, y); break;
case 5: printf("May %d, %d", d, y); break;
case 6: printf("June %d, %d", d, y); break;
case 7: printf("July %d, %d", d, y); break;
case 8: printf("August %d, %d", d, y); break;
case 9: printf("September %d, %d", d, y); break;
case10:printf("October %d, %d", d, y); break;
case11:printf("November %d, %d", d, y); break;
case12:printf("December %d, %d", d, y); break;
default:printf("error"); break;
}
getch();
}

thanks in advance. i need it asap.

Reply #1
10-21-10 05:45 PM
  • Full Member
  • ***
  • Male Offline
 
Posts: 1110
Thank You: 191
Reputation: 10
zoneraider has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
Wrong board ka po. May programming board po tayo. Dun ka po magtanong.
Reply #2
10-21-10 08:49 PM
  • [あ 私] Psychic Module system "I ♥ PD"
  • Moderator
  • *
  • Male Offline
 
Posts: 18702
Thank You: 4495
Reputation: 192
archive has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
Awards Medal Of Contribution Member of the Month Medal of Appreciation
thread move to pc programming board para dun mas maaccommodate concern mo.
Reply #3
10-22-10 06:09 AM
  • Full Member
  • ***
  • Offline
 
Posts: 960
Thank You: 137
Reputation: 0
cloudzz has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
Quote:
Originally Posted by : archieve on 10-21-10 08:49 PM
thread move to pc programming board para dun mas maaccommodate concern mo.
sorry po kung wrong board po sa pag move astig talaga :pdflag:
Reply #4
11-04-10 07:48 AM
  • Full Member
  • ***
  • Male Offline
 
Posts: 1248
Thank You: 240
Reputation: 12
jamsubzero has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
..advice ko lang ha..
isa-isahin mo ang papaenter ng data, dun kasi sa code mo pinagsabay mo eh..di ako marunong sa c (c++ lang alam ko) pero halata naman sa code mo..
ex..
enter month..
ipasa sa variable..
enter day..
ipasa sa variable..
and so on..

tsaka ka magswitch..

..at isa pa, dapat sana di kana gumamit ng arrays sa mga variable mo..
halimbawa, dun sa year, kaya namang ihandle ng isang int ang 4 digit number..

hope it helps..
Reply #5
11-06-10 09:48 AM
  • ^_^v
  • PinoyDen Agent
  • *
  • Male Offline
 
Posts: 3585
Thank You: 352
Reputation: 6
rajahboy has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
Quote:
#include<stdio.h>
main()
{
int m, d[2], y[4], i;     
clrscr();
i=0;
printf("Enter date in numerical form:\n");
scanf("%d %d %d", &m, &d, &y);                            /* eto yung input mo for month,day,year */
switch (m) {                                                                 /* ibig sabihin nito eh yung variable mo na "m" yung gagamitin natin for
                                                                                       switching or comparing its value sa ating case */
case 1: printf("January %d, %d", d, y); break;         /* yung 1 sa case 1 mo eh yung value kung saan dapat mag-mamatch yung value
                                                                                       na inenter mo for month,at kapag nag-match sya dito eh ie-execute nya yung
                                                                                       statement under case 1 at mag-eend dun sa "break" */
case 2: printf("February %d, %d", d, y); break;       /* and so on..hehe.hanggang sa value ng 12 para sa december */
case 3: printf("March %d, %d", d, y); break;
case 4: printf("April %d, %d", d, y); break;
case 5: printf("May %d, %d", d, y); break;
case 6: printf("June %d, %d", d, y); break;
case 7: printf("July %d, %d", d, y); break;
case 8: printf("August %d, %d", d, y); break;
case 9: printf("September %d, %d", d, y); break;
case10:printf("October %d, %d", d, y); break;
case11:printf("November %d, %d", d, y); break;
case12:printf("December %d, %d", d, y); break;
default:printf("error"); break;                                         /* etong default naman eh for example, nag input tayo ng 13 1 1999,since walang
                                                                                       13 month sa case mo eh yun yung ieexecute nya kapag walang nagmatch sa
                                                                                       case mo */
}
getch();
}

siguro naman marunong ka ng C kaya di ko na ieexplain lahat..

at pagpasensyahan mo ng kung hindi masyadong clear ang explanation ko..hehe =)

tama din yung advise nila na pwede ka ng wag gumamit ng array sa variable mo...
Reply #6
11-06-10 12:21 PM
  • Full Member
  • ***
  • Male Offline
 
Posts: 1248
Thank You: 240
Reputation: 12
jamsubzero has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
ang logic ng switch statement ay katulad lang yan sa switch ng ilaw nyo...kung off, eh di patay, kung on eh di naka sindi..
ang ilaw ang a-aplyan mo ng switch, so ganito yun..

switch(ilaw){
case off:
nakapatay;
break;
case on:
nakasindi;
break;
default:
hindi on nor off;
break;
}

..sorry.! logic lang nabigay ko..

gudluck.!
Reply #7
11-10-10 09:51 AM
  • Full Member
  • ***
  • Offline
 
Posts: 316
Thank You: 13
Reputation: 0
xXlawlietXx has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
Ang logic lang nyan eh kunware dun sa month nilagay ng user eh "1" gagawin nya yung nakapaloob sa case 1 mo.
Reply #8
11-10-10 09:52 AM
  • Full Member
  • ***
  • Offline
 
Posts: 316
Thank You: 13
Reputation: 0
xXlawlietXx has no influence.barely matters.is working their way up.might someday be someone...is on the verge of being accepted.is a rising star!has a powerful will.is a force to reckon with.has great potential!has an aura about them.is leading the good life!is awe-inspiring!
Parang if-else-if statement lang ang logic nyan.
Pages: [1]   Go Up
 



All dates are GMT+8:00. The date now is 10-25-14 10:29 PM
WWW.PINOYDEN.COM.PH does not store any files on it's server, we are just indexing other sites contents!
WWW.PINOYDEN.COM.PH [Ang Tambayan ng pinoy!] copyright 2008-2009 All Rights Reserved.
Contents published on www.PinoyDen.com.ph requires permission for reprint.

Page created in 0.2 seconds with 22 queries.