Skip to content

Instantly share code, notes, and snippets.

@ChintanBharateeya
Created July 17, 2017 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChintanBharateeya/17dec9f62cf73c86ded9f9e74d1a525c to your computer and use it in GitHub Desktop.
Save ChintanBharateeya/17dec9f62cf73c86ded9f9e74d1a525c to your computer and use it in GitHub Desktop.
practice program on C
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
char pword[100];
int uc,d,sp,i=1,maxval=0,l;
printf("Please enter the password\n");
scanf( " %s", pword);
for ( l=0; pword[l]!= NULL;l++)
{
maxval++;
}
printf("maxval is %d\n",maxval);
// printf ("The entered password is %s\n",pword);
for(i=0;i<=maxval;i++)
{ uc=pword[i];
d=pword[i];
sp=pword[i];
if(isalpha(uc))
{if(isupper(uc))
{
uc=pword[i];
//printf("%c\n",uc);
//break;
}
}
else if (isdigit(d))
{
d=pword[i];
//printf("%c\n",d);
}
else if (sp=='$')
{
sp=pword[i];
//printf("%c\n",sp);
printf("Correct password\n");
break;
}else {printf("Error!!");break;}
/* if (isupper(uc)==uc && isdigit(d)==d && sp=='$')
{
printf("Correct password");
}else {i++;continue;printf("try again");}*/
}
return 0;
}
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
char pword[100];
int uc,d,sp,i=1,maxval=0,l;
printf("Please enter the password\n");
scanf( " %s", pword);
for ( l=0; pword[l]!= NULL;l++)
{
maxval++;
}
printf("maxval is %d\n",maxval);
// printf ("The entered password is %s\n",pword);
for(i=0;i<=maxval;i++)
{ uc=pword[i];
d=pword[i];
sp=pword[i];
if(isalpha(uc))
{if(isupper(uc))
{
uc=pword[i];
//printf("%c\n",uc);
//break;
}
}
else if (isdigit(d))
{
d=pword[i];
//printf("%c\n",d);
}
else if (sp=='$')
{
sp=pword[i];
//printf("%c\n",sp);
printf("Correct password\n");
break;
}else {printf("Error!!");break;}
/* if (isupper(uc)==uc && isdigit(d)==d && sp=='$')
{
printf("Correct password");
}else {i++;continue;printf("try again");}*/
}
return 0;
}
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
char pword[100];
int uc,d,sp,i=1,maxval=0,l;
printf("Please enter the password\n");
scanf( " %s", pword);
for ( l=0; pword[l]!= NULL;l++)
{
maxval++;
}
printf("maxval is %d\n",maxval);
// printf ("The entered password is %s\n",pword);
for(i=0;i<=maxval;i++)
{ uc=pword[i];
d=pword[i];
sp=pword[i];
if(isalpha(uc))
{if(isupper(uc))
{
uc=pword[i];
//printf("%c\n",uc);
//break;
}
}
else if (isdigit(d))
{
d=pword[i];
//printf("%c\n",d);
}
else if (sp=='$')
{
sp=pword[i];
//printf("%c\n",sp);
printf("Correct password\n");
break;
}else {printf("Error!!");break;}
/* if (isupper(uc)==uc && isdigit(d)==d && sp=='$')
{
printf("Correct password");
}else {i++;continue;printf("try again");}*/
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment