C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 2nd, 2012, 01:02 AM
vlador3 vlador3 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 3 vlador3 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 13 m 51 sec
Reputation Power: 0
Need help with C Project (Can't complete it)

Hello,

I have been working on this project; I am still very new to programming in general. I have been able to get parts of it right but the other parts I kept getting errors throughout, and have just given up a bit. Any help is appreciated thanks.

Problem:

URL

My Code so far:

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

void main()
{

int month,date,year;
char* arr[]={"january","Febaruary","March","April","May","June","July","August","September","October","November","December"};

clrscr();
printf("Please enter the date in the format dd,mm,yy\n");
scanf("%d %d %d",&date,&month,&year);
switch(month)
{
case 1:
printf("%s %d %d \n",arr[0],date,year);
break;
case 2:
printf("%s %d %d \n",arr[1],date,year);
break;
case 3:
printf("%s %d %d \n",arr[2],date,year);
break;
case 4:
printf("%s %d %d \n",arr[3],date,year);
break;
case 5:
printf("%s %d %d \n",arr[4],date,year);
break;
case 6:
printf("%s %d %d \n",arr[5],date,year);
break;
case 7:
printf("%s %d %d \n",arr[6],date,year);
break;
case 8:
printf("%s %d %d \n",arr[7],date,year);
break;
case 9:
printf("%s %d %d \n",arr[8],date,year);
break;
case 10:
printf("%s %d %d \n",arr[9],date,year);
break;
case 11:
printf("%s %d %d \n",arr[10],date,year);
break;
case 12:
printf("%s %d %d \n",arr[11],date,year);
break;
default:
printf("nothing else\n");

}

gotoxy(20,10);
printf("end program\n");
gotoxy(20,11);
printf("*************");
getch();

}


Thanks in advance!!

Reply With Quote
  #2  
Old November 2nd, 2012, 02:02 AM
vlador3 vlador3 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 3 vlador3 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 13 m 51 sec
Reputation Power: 0
Figured it out but need help with the easiest way to give user option to either exit program or to start back at the top with new date. Thanks

Code:
#include <stdio.h>

int main(void)

{
	int month, day, year;   // All the integers that are needed within the program.

	printf("Enter the date (MM/DD/YYYY): ");  // Asks the user to input the date in numeral format: MM/DD/YYYY.
	scanf("%d/ %d/ %d", &month, &day, &year); // Checks user input, and stores those inputs into the proper integer values.

	printf("The day is: ", month); // Prints out the month that corresponds to the numerical value inputted by the user above.
	switch (month) {               // Uses a switch statement to match numerical values with the spelled out versions of the month. 
	case 1:	  printf("January");    
	break;
	case 2:   printf("February");  
	break;
	case 3:	  printf("March");	    
	break;
	case 4:	  printf("April");	    
	break;
	case 5:	  printf("May");	    
	break;
	case 6:	  printf("June");	    
	break;
	case 7:	  printf("July");	    
	break;
	case 8:	  printf("August");	    
	break;
	case 9:	  printf("September");  
	break;
	case 10:  printf("October");    
	break;
	case 11:  printf("November");   
	break;
	case 12:  printf("December");   
	break;                           // Switch statement ends here.
	}      

	printf(" the ", day);            // Prints out the day in written form that corresponds to the numerical value inputted by the user above. 
	switch (day) {                   // Uses a switch statement to match numerical values with the spelled out versions of what day it is.
	case 1:   printf("first");           
	break;
	case 2:   printf("second");          
	break;
	case 3:   printf("third");           
	break;
	case 4:   printf("fourth");          
	break;
	case 5:   printf("fifth");           
	break;
	case 6:   printf("sixth");           
	break;
	case 7:   printf("seventh");         
	break;
	case 8:   printf("eighth");          
	break;
	case 9:   printf("ninth");           
	break;
	case 10:  printf("tenth");           
	break;
	case 11:  printf("eleventh");        
	break;
	case 12:  printf("twelfth");         
	break;
	case 13:  printf("thirteenth");      
	break;
	case 14:  printf("fourteenth");      
	break;
	case 15:  printf("fifteenth");       
	break;
	case 16:  printf("sixteenth");       
	break;
	case 17:  printf("seventeenth");     
	break;
	case 18:  printf("eighteenth");      
	break;
	case 19:  printf("nineteenth");      
	break;
	case 20:  printf("twentieth");       
	break;
	case 21:  printf("twenty first");    
	break;
	case 22:  printf("twenty second");   
	break;
	case 23:  printf("twenty third");    
	break;
	case 24:  printf("twenty fourth");   
	break;
	case 25:  printf("twenty fifth");    
	break;
	case 26:  printf("twenty sixth");    
	break;
	case 27:  printf("twenty seventh");  
	break;
	case 28:  printf("twenty eighth");   
	break;
	case 29:  printf("twenty ninth");    
	break;
	case 30:  printf("thirtieth");       
	break;
	case 31:  printf("thirty first");    
	break;
	}                                   // Switch statement ends.

	printf(" %.4d.\n", year);           // Prints out the year as the inputted by the user using 4 digit placement. 

	system ("pause");

	return 0;
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Need help with C Project (Can't complete it)


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap