[ create a new paste ] login | about

Link: http://codepad.org/Mk9SX85I    [ raw code | output | fork ]

C, pasted on Aug 3:
// 12 hours converter.c: Converts a 24 hours format to a 12 hours format
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[]){

	int hours, minutes;
	scanf("%d:%d", &hours, &minutes);

	switch (hours){
		case 13: printf ("1:%d PM", minutes); 
				 break;
		case 14: printf ("2%d PM", minutes); 
				 break;
		case 15: printf ("3:%d PM", minutes); 
				 break;
		case 16: printf ("4:%d PM", minutes); 
				 break;
		case 17: printf ("5:%d PM", minutes); 
				 break;
		case 18: printf ("6:%d PM", minutes); 
				 break;
		case 19: printf ("7:%d PM", minutes); 
				 break;
		case 20: printf ("8:%d PM", minutes); 
				 break;
		case 21: printf ("9:%d PM", minutes); 
				 break;
		case 22: printf ("10:%d PM", minutes); 
				 break;
		case 23: printf ("11:%d PM", minutes); 
				 break;
		default: printf ("%d:%d AM", hours, minutes);
				 break;
	}
	getch();
	return 0;
}


Output:
1
2
Line 19: error: stdafx.h: No such file or directory
Line 7: error: expected declaration specifiers or '...' before '_TCHAR'


Create a new paste based on this one


Comments: