Monday, November 17, 2014

Password for Validation of User name



C Program to Input Password for Validation of User name

#include
#include
 void main()
{
   char password[25], ch;
   int i;

   clrscr();
   puts("Enter password : ");
    while (1)
    {
      if (i < 0)
     {
         i = 0;
      }
      ch = getch();

      if (ch == 13)
         break;
      if (ch == 8)
       {
         putch('b');
         putch(NULL);
         putch('b');
         i--;
         continue;
      }

      password[i++] = ch;
      ch = '*';
      putch(ch);
   }
    password[i] = '\0';
   printf("\nPassword Entered : %s", password);
   getch();
}

Output

Enter password : ******
Password Entered : rakesh

C Program to Count number of digits in number without using mod operator

#include
#include

int main() {
   int num, digits;
   char ch[10];

   printf("\nEnter the Number : ");
   scanf("%d", &num);

   sprintf(ch, "%d", num);

   digits = strlen(ch);
   printf("\nNumber of Digits : %d", digits);

   return(0);
}
Output
Enter the Number : 1234
Number of Digits : 4

C Program to Write inline assembly language code in C Program

#include
#include 
void main()
{
  int a = 3, b = 3, c;

   asm {
      mov ax,a
      mov bx,a
      add ax,bx
      mov c,ax
   }
   printf("%d",c);
}

C Program to Accept Paragraph using scanf
#include
#include 
int main()
{
   char para[100];
   printf("Enter Paragraph : ");
   scanf("%[^\t]s", para);
   printf("Accepted Paragraph : %s", para);
   return 0;
}
Output
Enter Paragraph : Pritesh Taral is author
of c4learn
Accepted Paragraph : Pritesh Taral is author
of  c 4learn

No comments:

Post a Comment