C Programming Tutorial – 33 – isupper and Challenge #1!

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Comments

Dan hHao says:

guys, i’ve written this, but it doesnot work, please help:

#include
#include
#include
#include

#include

int main()
{
char password[30];
int passwordstrength=0;
printf(“type in your password:n”);
scanf(“%s”, password);

int i;
int j;
int k;

for(i=0;i<=30;i++){ if(isupper(password[i])){ passwordstrength++; break; } else{ printf("there is no upper case in your password!n"); break; } } for(j=0;j<=30;j++){ if(islower(password[j])){ passwordstrength++; break; } else{ printf("there is no lower case in your password!n"); break; } } for(k=0;k<=30;k++){ if(isdigit(password[k])){ passwordstrength++; break; } else{ printf("there is no digit in your password!n"); break; } } printf("your password is %s with %d strengthpointn",password,passwordstrength); return 0; }

J Blackburn says:

//Boi

#include
#include
#include

int main()
{

char password[20];
char character;
char num_of_digits;
char num_of_uppercase;
char num_of_dollar;

printf(“Password checker v1.0n”);
printf(“Enter password: n”);
scanf(” %s”,password);

for(int i=0; i

Michi Cst says:

Here a quick version for the challenge, if you have any tips to make it better feel free to comment

#include
#include
#include

//Contains boolean data type
#include

int main()
{
int length;
bool upper;
bool lower;
bool number;

printf(“How long shall your password be? n”);
scanf(” %d”, &length);

char password[length];

printf(“Enter a password: n”);
scanf(” %s”, &password);

for(int i = 0; i < length; i++){ if(isupper(password[i]) && !upper) upper = true; if(isdigit(password[i]) && !number) number = true; if(islower(password[i]) && !lower) lower = true; } if(upper && lower && number) printf("You have entered a strong password."); else printf("You have entered a weak password."); return 0; }

Arnav Garg says:

here is my piece of code for this challenge.I may have used some features which were not taught here but i think my code is good

#include
#include
#include

#include
#include
#include
//i tried to use bool instead of x,y,z but didn’t know syntax /-:
//like my comment if you liked my code

int main()
{
char a[100],l;
int x=0,y=0,z=0;

printf(“type a strong password:n”);
scanf(“%s”,a);

l=strlen(a)-1;
// strlen gives you the length of the string.

for(int i =0; i< =l; ++i) { if(isupper(a[i])){ x++; } if (isdigit(a[i])){ y++; } if(a[i]==36){ z++; } //36 is the ascii value for $ sign. } if (x>=1 && y>=1 && z>=1)
{
printf(“hey!nice password.n”);
}else{
printf(“be aware of getting your password hacked.n”);
}
return 0;
}

Jan says:

Hi guys, I am currently working on the Challenge, but somewhere a bug flew in…. my “low”-value varies depending on how long the password is. value “low” counts the lower case letters, “up” the upper case ones. Can you please help me? I don’t know where to look anymore…

Thank you guys!!!!

#include
#include
#include
#include
#include

int main (){

int up = 0, low = 0 , sonder = 0, i;
char intpw [21];

printf(“Please typein your password: nPassword:”);
scanf (” %s”, intpw);

for (i=0; i<=20; i++){ if (isupper(intpw[i])){ up++; }} for (i=0; i<=20; i++) { if (islower(intpw[i])) { low++; } } printf("up %d, ", up); printf("low %d, ", low); return 0; }

איתי לופו says:

It was not as simple as the first exercise and it was mostly difficult to define the length of the loop along the password but with the help of the clips and comments I was able to. More or less, my solution:

#include
#include
#include
#include

int main()
{
int i = 0;int a =0 ; int b = 0; int c =0;int pasL = 0;
char pas[50];
printf(“print password n it must have a symbol a uppercase later and a number. n “);
scanf( ” %s”, pas);
pasL = strlen(pas);
printf(” t t %d”, pasL);
for (i=0; i < pasL; i++ ){ printf("n %d t %dn",c+b+a, i); if(isalpha(pas[i])){ if(isupper(pas[i])){ a = 1; printf("tt #1"); i +=i; continue; }else{ printf("tt #L"); continue;}} if(isdigit(pas[i])){ b = 2; printf("tt #2"); continue; } if(isdigit(pas[i]) || isupper(pas[i]) || pas[i] == ""){ printf("tt #d s"); continue; } else if(c==0){ c = 3; printf("tt #%d ",c); continue; } } if(a*b*c == 6){ printf("n that work"); }else{ printf("n not good"); } return 0; }

Ketan Lambat says:

As simple possible…

#include
#include
#include
#include

#include

int main()
{
int i;
char pass[15];
int Ucase =0;
int num =0;
int sym =0;

printf(“Enter new password n Requirements n UPPERCASE, Number, $ signn : “);
scanf(” %s”, &pass);

for(i=0; i<=15; i++) if ( isupper(pass[i])){ Ucase ++; } for(i=0; i<=15; i++) if (isdigit(pass[i])){ num ++; } for(i=0; i<=15; i++) if (pass[i] == '$'){ sym ++; } if((Ucase*num*sym)!=0){ printf("Good Password");} else{printf("Try Again");} return 0 ; }

dev02ify says:

Here’s mine. I have a lot of experience with Python and a lot of peripheral knowledge of C concepts from trying to read source code, so there’s some more advanced concepts:
#include
#include
#include

int main()
{
printf(“Enter your password. Must contain one uppercase letter, one lowercase, one digit, and one special character, like !@#$%^&* (excuse my language)n”);
printf(“Keep it 20 characters or under cause I’m a bad programmer:n”);
// 0 is false, anything else is true
while(1){
char input[21];
scanf(” %s”, input);

// this technique is known as a bit field. Each bit of the number reprents a conditon. If that bit is 0, the condition is false, otherwise it’s true.
// using a char instead of int because we don’t have more than 8 conditions (char is 8-bits, int is 64, might as well not waste space)
char conditions = 0;

// i is the index in the string. If input[i] is 0 (the null character) then we’ve reached the end of the string so stop there.
// Also stop if we’ve already met all the necessary conditions (1 | 2 | 4 | 8 == 15)
for(int i=0; (input[i] != 0) && (conditions != 15); i++){
if(isalpha(input[i])){
// If there’s only one line you don’t need braces. I come from python so I hate the braces.
if(isupper(input[i]))
// this is a bitwise OR.
conditions |= 1;
else
conditions |= 2;

}else if(isdigit(input[i]))
conditions |= 4;
else
conditions |= 8;
}
if(conditions != 15)
printf(“Your password sucks. Try again:n”);
else
break;
}
}

mohamed mohsen says:

#include
#include
#include
int main()
{
char num[20];
int i,upper=0,lower=0,integer=0,s_c=0;
printf(“please give me your password(up to 19 character)n”);
scanf(“%s”,num);
for(i=0;i<19;++i)
{
if (num[i]=='')
{
break;
}
if(isalpha(num[i]))
{
if(isupper(num[i]))
{
upper++;
}
else
{
lower++;
}
}
else if(isdigit(num[i]))
{
integer++;
}
else if(num[i]!='')
{
s_c++;
}
else
{
}
printf("%c",num[i]);
}
printf("n");
if(upper>0&&lower>0&&integer>0&&s_c>0)
{
printf(“right password! %d upper character%s %d lower character%s %d integer%s %d special character%s)”,upper,(upper==1)?””:”s”,lower,(lower==1)?””:”s”,integer,(integer==1)?””:”s”,s_c,(s_c==1)?””:”s”);
}
else
{
printf(“please retype your password (your password must contain at least 1 uppercase and 1 lower case alphaphet and 1 integer and 1 special character “);

}
return 0;
}

JJAcke NG says:

#include
#include
#include
#include
int main()
{
char password[11];
int a,b,c,i = -1;
printf(“please enter your passwordn”);
scanf(” %s”,password);

do{
i++;
}while(password[i]!=’’);
a=b=c=0;

for(a=0;a<=i-1;a++){ if(isupper(password[a])){ break; } } for(b=0;b<=i-1;b++){ if(isdigit(password[b])){ break; } } for(c=0;c<=i-1;c++){ if(password[c]=='$'){ break; } } if( (isupper(password[a])) && (isdigit(password[b])) && (password[c]=='$') ){ printf("your password is good to go"); }else{ printf("change your password"); } return 0; } it took me a long time to complete..

Arvind Vats says:

Here’s my code.. It works just perfect 🙂 it has some advanced concepts but that’s because i’m also learning from book.. please review 🙂 (try running it on your code blocks )-
#include
#include
#include
#include

int main()
{
char x[18];
char y[18];
int upp;
int low;
int dig;
char ch;
int l;
int error;

printf(” LOGIN SITEn”);

for(int j=0; j< =95; j++) { printf("_"); } do { error=0; do { upp=0; low=0; dig=0; printf("nCreate your password. nIt should be strong (Least Requirement: 1 upper, 1 lower, 1 digit and more than 8 characters)nEnter your New Password here:"); scanf("%s", x); l=strlen(x); for(int i=0; i<=l; i++) { if(isupper(x[i])) { upp++; } else if(islower(x[i])) { low++; } else if(isdigit(x[i])) { dig++; } } printf("nUpper: %d Lower: %d Digit: %d Length: %dn", upp, low, dig, l); if(l<8) { printf("nINVALID PASSWORD! Your Password Length is less than: 8"); } if(upp==0) { printf("nINVALID PASSWORD! There is no upper case in your password"); } if(low==0) { printf("nINVALID PASSWORD! There is no lower case in your password"); } if(dig==0) { printf("nINVALID PASSWORD! There is no digit in your password"); } if(upp!=0&&low!=0&&dig!=0&&l>=8)
{
printf(“your Password is strong!”);

printf(“nNow Re-Type your Password to CONFIRM:”);
scanf(” %s”, y);

if (strcmp(x,y)==0)
{
printf(“Password MATCHED! Your New Password has been set!n”);
break;
break;
}
else
{
printf(“Password INCORRECT! you made a mistake in typing!n”);
error++;
break;
}
}

printf(“nnDo you want to Write a different password?(Y/N):”);
scanf(” %c”, &ch);
}while(ch==’Y’||ch==’y’);

}while(error!=0);

for(int j=0; j<=90; j++) { printf("-"); } printf("n"); for(int j=0; j<=30; j++) { printf("x"); } printf("THANKS FOR VISITING!"); for(int j=0; j<=39; j++) { printf("x"); } printf("n"); for(int j=0; j<=90; j++) { printf("-"); } return 0; }

Ujwal Bhagat says:

#include
#include
#include
#include
#include

int main()
{
printf(“This program will run continuously, to exit out of the loop, press Ctrl + Cn”);

while(1==1){
char passwd[20];
int i=0;
int hasUpper = 0;
int hasDigit = 0;
int hasDollar = 0;
printf(“Please enter a password: n”);
scanf(“%s”,passwd);

for(i=0; i< =19; i++){ if(isupper(passwd[i])){ hasUpper ++; } if(isdigit(passwd[i])){ hasDigit ++; } if(passwd[i] == '$'){ hasDollar ++; } } (hasUpper>0 && hasDigit>0 && hasDollar>0) ? printf(“Your password is strongn”) : printf(“Your password is weakn”);
}

return 0;
}

Olimjon Matniyazov says:

Here is what i just wrote. I just indicated as 4 digits. But possible as much as needed.
#include
#include
#include
#include
#include

int main () {

printf(“Password should contain Upper & lower case letters, number, symbol. Upto 4 digits.n”);
printf(“Enter a password: n”);
char password[4];
int i,a = 0,b = 0,c = 0,d = 0;
for (i=0;i<4;i++) {
scanf("%c",&password[i]);
}

for (i=0;i<4;i++) {
if (isalpha(password[i])) {
if (isupper(password[i])) {
a++;
} else {
b++;
}
} else {
if (isdigit(password[i])) {
c++;
} else {
d++;
}
}
}
if (a!=0 & b!=0 & c!=0 & d!=0) {
printf("password accepted! n");
} else
printf("password sucksn");
return 0;
}

Matthew says:

This code is absolute TRASH, but here goes:

#include
#include
#include
#include
#include

int main()
{
int i;
char password [8];

printf(“Enter your password to test its strength! n”);
scanf(“%s”, password);

if( isalpha(password[0]) && isupper(password[0]) || password[0] == ‘$’ || isdigit(password[0]) &&
isalpha(password[1]) && isupper(password[1]) || password[1] == ‘$’ || isdigit(password[1]) &&
isalpha(password[2]) && isupper(password[2]) || password[2] == ‘$’ || isdigit(password[2]) &&
isalpha(password[3]) && isupper(password[3]) || password[3] == ‘$’ || isdigit(password[3]) &&
isalpha(password[4]) && isupper(password[4]) || password[4] == ‘$’ || isdigit(password[4]) &&
isalpha(password[5]) && isupper(password[5]) || password[5] == ‘$’ || isdigit(password[5]) &&
isalpha(password[6]) && isupper(password[6]) || password[6] == ‘$’ || isdigit(password[6]) ){
printf(“Password is strong”);
}else{
printf(“Password is weak”);
}

return 0;
}

Bibek Subedi says:

#include
#include
#include

int main()
{
char input[50];
int alpha,upper,lower,spchar,digit=0;
printf(“Enter your password containing uppercase, digits, lowercase and special characters.n”);
scanf(” %s”,input);
int i;
for(i=0;i<50;i++){
if(isalpha(input[i])){
if(isupper(input[i])){
upper++;
continue;
}else{
lower++;
continue;
}
}
else if(isdigit(input[i])){
digit++;
continue;
}
else{
spchar++;
}
}
if((upper>=1) && (lower>=1) && (spchar>=1)&& (digit>=1)){
printf(“your password is valid.”);
}
else{
printf(“your password is not valid.”);
}
return 0;
}

mohamed khaled says:

Very simple and easy to understand 🙂

#include
#include
#include

#include
#include

int main()
{

char password[20];

int i,lower,upper,digit;
lower=upper=digit=0;

do{
lower=digit=upper=0;
printf(“Enter Strong Password tt [L:%d] [U:%d] [D:%d]n >”,lower,upper,digit);
scanf(” %s”,password);

for(i=0;i

Mansi D says:

#include
#include

#include
#include
#include

int main()
{ char pass[6];
int i=0;
int j=0;
int k=0;
int p=0;

printf(“enter your passwordn”);
scanf(“%s”,pass);
int l = strlen(pass);
for(i=0;i<=6;i++) { if(isupper(pass[i])) {p++; } else if(isdigit(pass[i])) {k++;} else if (pass[i]=='$') {j++;} } if(p&&k&&j&&l==6) printf("your passowrd is goodn"); else printf("password not set,set it again"); return 0; }

Geeta Verma says:

#include
int main(){

char pass=’w’;
int code=1;
int a=0;

printf(“put passcoden”);

do{

scanf(“%s%d”, &pass, &code);
if((code==1)&&(pass==’w’)){
printf(“ok”);
}
else{

printf(“try againn”);}
}
while(pass!=’w’);
{}}

Nacho Libre says:

Here’s

princess lilo says:

i tried this why is’nt my code working
#include
#include
#include
#include
#include

int main()
{
char password[11];
int i = 0;
int low =0;
int upper =0;
int num =0;
int dollar_sign= 0;
printf(“Enter Passwprd: “);
scanf(” %s “, password );
for (i =0 ; i <= 11 ; i++) { if (isalpha(password[i])) { if (isupper(password[i])){ upper = 1; } else { low = 1; } } else if(isdigit(password[i])){ num = 1; } else if(password[i] == '$'){ dollar_sign = 1 ; } else{ printf("Enter a password that contain an upper and lower case letters n"); break; } } if ( num * low * upper * dollar_sign != 0){ printf("you have a strong password n"); } else{ printf("you have a weak password try again n"); } return 0; }

pranav gupta says:

#include
#include
#include

int main()
{
int ee=0;
while(ee==0){
char pass[20];
int aa,bb,cc,dd,i;
aa=bb=cc=dd=0;

printf(“nEnter paswoord with 1 upper and lower letter, 1 number and ‘$’ sign:n”);
scanf(“%s”, pass);

for (i=0; i

dylan huyghebaert says:

This code is very easy to understand and uses everything we have seen in the tutorials, hope this code can help someone.

#include
#include
#include
#include
#include

int main()
{
char password[20];
int counter=0;
int upper=0;
int lower=0;
int digit=0;
int dollarsign=0;

printf (“password must contain at least one digit, an upper & lowercase letter and a dollar sign.n”);
printf (“Type your password here: “);
scanf (” %s”, &password);

for (counter; password[counter]; counter++){

if (isupper(password[counter])){
upper=1;}
if (islower(password[counter])){
lower=1;}
if (isdigit(password[counter])){
digit=1;}
if ((password[counter] == ‘$’)){
dollarsign=1;}
}
if (upper==1 && lower ==1 && digit==1 && dollarsign==1){
printf (“Good password.”);}

else printf (“Try again.”);

return 0;
}

Karan Rawat says:

Here is mine
Short and simple with one loop.

#include
#include
#include
#include
int main()
{
char pass[20];
int i,u=0,d=0,o=0,c=0;
printf(“Type your passwordn”);
scanf(” %s”,pass);
if(strlen(pass)<20)
{
for(i=0;i< =strlen(pass);i++) { if(isupper(pass[i])) { u++; }else if(isdigit(pass[i])){ d++; }else if(pass[i]=='$'){ o++; }else{ c++; } } if(u>0 && d>0 && o>0){
printf(“Password OK”);
}else{
printf(“Weak Password”);
}

}else{
printf(“Too Long”);
}
return 0;
}

Felix Junious says:

Is this Correct guys ?

#include
#include
#include

#include
#include

int main()
{
int password[20];
char checkAlpha = ‘f’;
char checkNum = ‘f’;
char checkUpper = ‘f’;
int i;

printf(“Whats your password hoss (max 20 Characters): “);
scanf(” %s”,password);

for(i=0;i<=20;i++){ if(isalpha(password[i])){ checkAlpha = 't'; }else if(isalnum(password[i])){ checkNum = 't'; }else if(isupper(password[i])){ checkUpper = 't'; } } if(checkAlpha =='t' && checkNum == 't' && checkUpper=='t'){ printf("Your Password is working hoss (%s)",password); }else{ printf("Your Password Sucks"); } return 0; }

Science & travel says:

#include
#include

int main()
{
char pasword[20];
int a,d,s,checker,try=0;
;
do{
try=0;

printf(“enter a password which should include upper case number and symbol n”);
scanf(“%s”,pasword);
for(int loop1=0; loop1<20;loop1++){
if(isalpha(pasword[loop1])){
if(isupper(pasword[loop1])){
a++;
}
}
else if(isdigit(pasword[loop1])){
d++;

}
else{
s++;

}
if(s>=1&&d>=1&&a>=1){

printf(“okey password include correct letters n”);
checker++;

break;
}
}
if(checker==0){

printf(“try again “);

try=1;
}
}while(try==1);

return 0;
}

Sayan Banerjee says:

I did not hear so i mistakenly developed a different code however it is similar in approach. It asks for a 8 character password then if atleast 1 upper lower digit and special characters are present then counts them or else shows that password is missing something. Please suggest how to make this program better or more user friendly.I know I am an amateur 🙂 and am open to suggestions.
#include
#include
#include
#include
#include

int main()
{
char in[9];
int i=0;
int u=0;
int l=0;
int n=0;
int s=0;
int a=0;

printf(“Enter your password of 8 characters. n”);
printf(“Remember to enter atleast 1 uppercase 1 lowercase 1 special and 1 digit character.n”);
scanf(” %s”,in );
for( i=0;i< =7;i++) { a=in[i]; if( isalpha(a)){ if( isupper(a)){ u++; } else{ l++; } }else{ if( isdigit(a)){ n++; } else{ s++; } } } if((u>=1)&&(l>=1)&&(n>=1)&&(s>=1) ){
printf(“Your Password is hard to crack since it has %d upper case %d lower case %d digits and %d special characters”,u,l,n,s);
}
else{
printf(“Your password is missing something!!!”);
}
return 0;
}

Ryan Kung says:

#include
#include
#include
#include
#include

int main(int argc, const char * argv[]) {
// use 0 and 1 to represent false and true
int upperCheck = 0;
int numCheck = 0;
int dollarCheck = 0;

char pw[] = “34E4ffd$”;

for (int i=0; i < strlen(pw); i++){ //check if it is a letter if (isalpha(pw[i])){ //Check if the letter is an upper case letter if(isupper(pw[i])){ upperCheck = 1; } continue; //check if it is a number }else if(isdigit(pw[i])){ numCheck = 1; continue; //check if it is a dollar sign }else if(pw[i] == '$'){ dollarCheck = 1; continue; } //any other symbols are simply ignored } if(upperCheck && numCheck && dollarCheck){ printf("Your password is safe!!! you are good to go!"); }else{ printf("You need to reset your passsword!"); } }

Zeyad Ahmed says:

This’s mine and it works fine with me.

#include
#include
#include
#include

int main()
{
while(1)
{
int i;
char a, b, c;
a = b = c = ‘f’;
char password[10];
printf(“Enter your passwordn”);
scanf(“%s”, password);
for(i=0; i

Falcon says:

#include
#include
#include
#include
#include

int main()
{
int a=0;
int b=0;
int c=0;
int i=0;
int len;
char d=”$”;
char password[50];
printf(“Please type your Password”);
scanf(“%s”, password);
len=strlen(password);
for(i=0;i<=len-1;i=i+1) {if (isupper(password[i])) {a=1; printf("%cn",password[i]);} else {if (isdigit(password[i])) {b=1; printf("%cn",password[i]);} else {if(password[i]==d) {c=1; printf("%cn",password[i]);} } }; }; printf("a=%d,b=%d,c=%d",a,b,c); if (a*b*c==1){printf("Your password is good to go");} else {printf("Please check your password");}; return 0; }

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!