programming with c language (2)

/*
 program to accept a character from keyboard.
 It then prints out its ASCII value and the
 character itself
*/
#include<stdio.h>
main(){
 char ch;
 printf("Enter a character:");
 ch=getchar();
 fflush(stdin);
 printf("%c ascii value is %d\n",ch,ch);
}

/*
 maximum field width is specified by
 placing a number between the % symbol and the
 conversion character
*/

#include<stdio.h>
main(){
 int x,y,z;
 scanf("%3d %3d %3d",&x,&y,&z);
 fflush(stdin);
 printf("%d %d %d\n",x,y,z);
}

/*
 Program to accept input the the format
 12/03/1999
*/
#include<stdio.h>

main(){
 int dd,mm,yy;
 scanf("%d/%d/%d",&dd,&mm,&yy);
 fflush(stdin);
 printf("date is %d-%02d-%04d\n",dd,mm,yy);
}
 


Click here to go back to 'C' programming
If you have comments or suggestions, email me at nicholas@tm.net.my

This page created with Netscape Navigator Gold (17/9/1999)