Thursday, April 30, 2009

solution ecp1026 tut1

#include

int main ()
{
 int pw = 2210 ,num, loop ;
 char name[20] ;
 while (loop=1) {
 printf("Please Enter Your Name : ");
 scanf("%s",name);
 printf("Please Enter Your Password : ");
 scanf("%d",&num);
 if (num == pw ){
  printf("Welcome %s to ECP 1026 Programing Class\n",name);
  return 0;}
 else {
  printf("%s please login with correct password\n",name); 
  loop = 1 ;
 }}
 
 return 0 ; }



//////////////question 2//////////////////




#include

int main ()
{
 int i ,j ,n[10]={0,1,2,3,4,5,6,7,8,9};

 for ( i=0;i<10;i++){
  for ( j = 1; j <= n[ i ]; j++ ) {
  printf( "%c", '*' );
  } printf( "%d",i );
  printf( "\n" );
}
 
 return 0 ; }

No comments: