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

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

48 responses to “C Programming Tutorial – 33 – isupper and Challenge #1!”

  1. Ryan Kung Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    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!");
    }
    }

  2. Ly Kurgos Avatar

    I tried to keep it short as possible:

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    int main () {
    int a,b,c = 0;
    int d;
    char password[20];
    printf("Enter your password:n");
    scanf(" %s", password);
    for(d=0; d <=20; d++) {
    if(password[d]=='$')
    a++;
    if (isdigit(password[d]))
    b++;
    if (isupper(password[d]))
    c++;
    }
    if (a > 0 && b > 0 && c > 0)
    printf("The password is valid");
    else
    printf("It is not valid");
    return 0;
    }

  3. harry krishton Avatar

    Hi guys!This is the simplest solution to understand how we go about to carry out this function!You can try it yourself and compare with this!

    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    char x[14];
    //chart y[];
    int z;
    int a;
    int b;
    int c;

    printf("Please Enter the Password(Max15): ");
    scanf(" %s",&x);

    for(z=0;z<14;z++){
    if(x[z]=='$'){

    a=1;
    }
    if(isupper(x[z])) {

    b=1;
    }
    if(isdigit(x[z])){

    c=1;
    }
    }

    if(a==1 && b==1 && c==1)
    {
    printf("nThank you!That is correct!");

    }
    else{

    printf("nSorry thats just not right.Please try again");
    }

    return 0;
    }

  4. pranav gupta Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    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<strlen(pass);i++){//strlen to scan length of array.

    if(isupper(pass[i])){
    aa=1;
    }
    if(islower(pass[i])){
    bb=1;
    }
    if(isdigit(pass[i])){
    cc=1;
    }
    if(pass[i]=='$'){
    dd=1;
    }
    }
    printf("nPassword Review:n");
    aa==1 ? printf("&n") : printf("add upper lettern") ;
    bb==1 ? printf("&n") : printf("add lower lettern") ;
    cc==1 ? printf("&n") : printf("add number n") ;
    dd==1 ? printf("&n") : printf("add '$' symboln") ;

    aa==1&&bb==1&&cc==1&&dd==1 ? (ee=1) : (ee=0) ;
    ee==0 ? printf("nYour password can be hacked so see the review given and try againnnn") : printf("Good passwordnn") ;
    }
    return 0;
    }

  5. Science & travel Avatar

    #include <stdio.h>
    #include <stdlib.h>

    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;
    }

  6. Falcon Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    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;
    }

  7. Immortal Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include<ctype.h>
    #include<string.h>
    int main()
    {

    char pass[10] ;
    int a ;
    int num=0;
    int num1 ;

    printf("Choose a password that doesn't exceed 10 charactersn ");
    scanf("%s", pass);

    for (a=0;a<=10;a++){

    if(isupper(pass[a]) || isdigit(pass[a]) || ispunct(pass[a]) ){

    num++ ;
    }

    if(islower(pass[a]) ){

    num1++ ;

    }

    }

    if (num<=3){
    printf("Weak but Good passwordn");
    }
    else if (num<=5) {
    printf("fairly strong but Good passwordn") ;
    }
    else if (num<=10) {
    printf("Wow strong and Good passwordn") ;

    }

    if (num+num1>10){
    printf("password should not be more than 10 charactersn");

    main() ;
    }

    return 0;

    }

  8. A. Hamdani Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    int main()
    {
        int i=0;
    char password[12];

    printf(" enter a password: n");
    scanf("%s",password);

    if(isalpha(password[i])) {

    }else{
        printf("must contain an alphapet n");
    }
     if(isupper(password[i])){
     }
    else{
           printf("must contain an upper case letter n");
        }

    if(isdigit(password[i]) ) {
    }

    else{

    printf("must contain a number n");
    }

     return 0;
    }
    HELP:(EVEN IF I ENTER A NUMBER I STILL GET THE "MUST CONTAIN A NUMBER" CAN ANYONE HELP TELL WHAT'S WRONG?!

  9. Konda Rohith Avatar

    //any comments to make my program better are welcome :)//

    #include<stdio.h>
    int main()
    { int a=0;
    char password[20];
    char d,b;
    int c;

    printf("enter the password:");
    scanf(" %s",&password);

    while(a<=20){ if(isalpha(password[a]) && isupper(password[a]) ){
    d=password[a];
    break;}
    a++;}
    while(a<=20){ if(isdigit(password[a]) ){
    c=password[a];
    break;}
    a++;}

    while(a<=20){ if(password[a]=='$' ){
    b=password[a];
    break;}
    a++;}

    if( isalpha(d) && isupper(d) && isdigit(c) && b=='$' ){
    printf("your password is good!");
    }else{ printf("try another one");}

    return 0;
    }

  10. Technology Mania Avatar

    sir, i cant download C# 2010…please help me sir…please

  11. Yeshwanth Sai Yerra Avatar

    challenge Program in 2018.
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
    #include <ctype.h>

    int main()
    {
    int a,N=0,U=0,L=0,D=0,S=0;
    printf("Enter 14 digits of password which includes a Lower,Upper Case letter, number & '$' sign n ");
    char password[14];
    printf("Enter your password : n");
    scanf("%s",password);
    for(a=0;a<=14;a++)
    {
    char letter = password[a];
    if (isalpha(letter))
    {
    if(isupper(letter))
    {
    U=1;
    }
    else
    if(islower(letter))
    {
    L=1;
    }
    }
    else
    if(isdigit(letter))
    {
    D=1;
    }
    else
    if(letter = '$')
    {
    S=1;
    }
    }
    N=U+L+D+S;
    if (N==4)
    {
    printf("Password is valid");
    }
    else
    printf("password is invalid");
    return 0;
    }

  12. Durga prasad P Avatar

    My attempt Challenge #1!
    #include"stdio.h"
    #include"conio.h"
    #include"ctype.h"
    void main()
    {
    char user[20],pass[20];
    int a=0,b=0,c=0,i,d=0;
    clrscr();
    printf("Enter your user name for Registation:n");
    scanf("%s",user);
    printf("Enter your user password for that user_id:n");
    scanf("%s",pass);
    for(i=0;pass[i]!='';i++)
    {
    if(isalpha(pass[i]))
    {
    if(isupper(pass[i]))
    a++;
    else
    b++;
    }
    else if(isdigit(pass[i]))
    {
    c++;
    }
    else
    {
    d++;
    }

    }
    printf("These is the number of character in each typen");
    printf("Number of upper case %dn",a);
    printf("Number of lower case %dn",b);
    printf("Number of nos used in string %dn",c);
    printf("Symbol are used in string %dn",d);
    if(a>0 && b>0 && c>0 && d>0)
    {
    printf("User_id successfully created");
    }
    else
    {
    printf("Your password isn't strong so your user_id rejected so please try late with new password");
    }
    getch();
    }

  13. MK_Freestyle Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>
    #include <ctype.h>
    #include <string.h>

    int main()
    {
    char pwd[26];
    bool containsUpper = false, containsNum = false, containsDollar = false;
    printf("Please enter your password. It should contain at least 8 characters. Max number is 25nPassword: ");
    scanf(" %s", pwd);

    int i;
    for (i = 0; i < strlen(pwd); i++)
    {
    //check for the upper case
    if (!containsUpper && isupper(pwd[i]))
    {
    containsUpper = true;
    continue;
    }
    //check for the number
    if (!containsNum && isdigit(pwd[i]))
    {
    containsNum = true;
    continue;
    }
    //check for the number
    if (!containsDollar && pwd[i] == '$')
    {
    containsDollar = true;
    continue;
    }

    //Break out of the loop if all required numbers are found
    if (containsUpper && containsNum && containsDollar) break;
    }

    //Print results on the screen
    if (containsUpper && containsNum && containsDollar) printf("Your password is secure");
    else
    {
    if (!containsUpper) printf("No upper case. ");
    if (!containsNum) printf("No number. ");
    if (!containsDollar) printf("No dollar sign ($).");
    }

    return 0;
    }

  14. nazan h-va Avatar

    too hard to see

  15. Ahtemarul Hasan Rokon Avatar

    i better do my homework lol

  16. Osama Elgabry Avatar

    #include <stdio.h>
    #include <ctype.h>
    #include <string.h>
    int main()
    {
    char pass[20];
    int i,alpha=0,upperr_alpha=0,digit=0,special_char=0;
    while (1){
    printf("enter your password n");
    scanf(" %s",pass);

    for ( i=0;i<strlen(pass);i++){

    if (isalpha(pass[i])){

    alpha=1;
    if (isupper(pass[i])){

    upperr_alpha=1;
    }
    }
    if (isdigit(pass[i])){
    digit=1;
    }
    if (!isalpha(pass[i])&&!isupper(pass[i])&&!isdigit(pass[i])) {
    special_char=1;
    }
    }
    if (alpha&&upperr_alpha&&digit&&special_char&&strlen(pass)>=8){

    printf("n your password is strongn");
    break;
    }
    if (strlen(pass)<8){

    printf("password must contains at least 8 charactern");
    }
    if (!alpha){
    printf("password must contains charactern");
    }
    if (!upperr_alpha){
    printf("password must contains upper charactern");
    }
    if (!digit){
    printf("password must contains digitsn");
    }
    if (!special_char){
    printf("password must contains special charactern");
    }

    }
    }

  17. CrazyPasha Boy Avatar

    /*CAN ANYONE PLEASE POINT OUT THE FLAW….
    THE COMPILER DOES NOT SHOW ANY ERROR BUT THE CODE DOESN'T SEEM TO WORK WHEN NO LOWER CASE CHARACTER OR NO SPECIAL CHARACTER IS ENTERED,IT PRINTS THAT THE PASSWORD IS ACCEPTED*/

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    int main()
    {
    char password[21];
    printf("Note:the password must contain 8-20 digits.n");
    printf("Enter a password with upper and lowercase characters,digits and at least 1 special character.n");
    scanf("%s",password);
    int i;
    int up=0;
    int low=0;
    int dig=0;
    int spcl=0;
    for(i=0;i<=21;i++){
    if (isalpha(password[i]))
    {
    if (isupper(password[i])){
    up++;
    }
    else{
    low++;
    }
    }
    else if (isdigit(password[i])){
    dig++;
    }
    else{
    spcl++;
    }
    }
    if (strlen(password)>20){
    printf("password not accepted:it should not contain more than 20 characters");
    }
    if (strlen(password)<8){
    printf("password not accepted:it should not contain less than 8 characters");
    }
    if (up<1){
    printf("password not accepted:it must contain at least 1 upper case character");
    }
    if (low<1){
    printf("password not accepted:it must contain at least 1 lower case character");
    }
    if (dig<1){
    printf("password not accepted:it must contain at least 1 digit");
    }
    if (spcl<1){
    printf("password not accepted:it must contain at least 1 special character");
    }
    if (up>0&&low>0&&dig>0&&spcl>0){
    printf("CONGRATULATIIONS:your password is accepted");
    }
    return 0;
    }

  18. Abhisek C Avatar

    How can i stop this loop? help pls.

    #include <stdio.h>
    #include <stdlib.h>
    #include<ctype.h>

    int main()
    {
    int password;

    do{
    printf("Enter your passwords (Only one letter max) : ");
    scanf(" %c", &password);

    if (isalpha (password)){
    if(isupper (password)){
    printf("Your password rocks. n");
    }else{
    printf("Average Password. n");
    }
    }else{
    if(isdigit(password)){
    printf("Your password is numerical. n");
    }else{
    printf("Your password sucks. n");
    }
    }
    printf("Enter 0 to stop. n");
    }while(password != 0);

    return 0;
    }

  19. Luca Besana Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>

    int main()
    {
    char password[20];
    int i;
    int uppercase;
    int digit;
    int dollar;
    dollar=digit=uppercase=0;

    do{ printf("enter a password with at least 5 characters, which includes an upper case letter, a number and a $nn");
    scanf("%s", password);
    } while(strlen(password )<6);

    for(i=0; i<strlen(password) ;i++){
    if (isalpha(password[i])){
    if (isupper(password[i])){
    uppercase++;
    }
    continue;
    }

    if (isdigit(password[i])){
    digit++;
    continue;
    }

    if(password[i] == '$'){
    dollar++;
    }
    }
    if((uppercase>=1) && (digit>=1) && (dollar>=1)){
    printf("your password is fuckin' good!n");
    }
    else printf("your password sucks!n");

    return 0;
    }

  20. Jemmeh Avatar

    I made my code using only things we have learned in these tutorials so far. If you don't understand the loop part with int k, then go back to video #27 and rewatch the for Loop video.

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    int main(){

    //Practice for Learning C Tutorials from "The New Boston".
    //Some things can be improved, but I tried to limit to things the tutorials had taught so far.
    //Added PasswordStrength to measure Weak,Medium,Strong and also using OR to allow multiple symbols.

    printf("PASSWORD STRENGTH TESTn======================n");
    printf("A strong password can help protect your account better!nType your password below to test it's strength.nn");
    printf("Password must contain:nAn UpperCase Letter nA number nA $, !, or #n");
    printf("Please enter a strong password now:nn");

    char passwordToTest[50];
    scanf(" %s", &passwordToTest);
    printf("You entered: %sn", passwordToTest);

    int k;
    int PasswordStrength = 0;

    for(k=1; k<=50; k++){
    if(isupper(passwordToTest[k])){
    printf("Password contains an uppercase letter.n");
    PasswordStrength++;
    break;
    }
    }

    for(k=1; k<=50; k++){
    if(isdigit(passwordToTest[k])){
    printf("Password contains a number.n");
    PasswordStrength++;
    break;
    }
    }
    for(k=1; k<=50; k++){
    if(passwordToTest[k] == '$'|| passwordToTest[k] == '!' || passwordToTest[k] == '#')
    {
    printf("Password contains $,!, or #");
    PasswordStrength++;
    break;
    }
    }

    printf("PasswordStrength: %dn", PasswordStrength);

    switch(PasswordStrength){
    case 1 : printf("Password strength is Weak. Please try again.");
    break;
    case 2 : printf("Password strength is Medium. Please try again.");
    break;
    case 3 : printf("Password strength is Strong. Good job!");
    break;
    default : printf("Error.");
    break;
    }

    return 0;
    }

  21. Chevv Paperchaser Avatar

    #include<stdio.h>
    #include<conio.h>
    #include<stdlib.h>

    typedef struct membership{
    int memID;
    char memName[30];
    int memAge;
    }MEMBER;

    void loadFile();
    void checkAge();
    void addMember();
    void menu();

    void main()
    {
    loadFile();
    }

    void loadFile() //initializes the file with 100 blank records
    {
    FILE *ptr;
    int i;
    MEMBER member;

    ptr=fopen("nightcrawlers.dat","wb");
    if(ptr==NULL)
    {
    printf("Error loading file…");
    getch();
    }
    else
    {
    printf("nnLoading file…");
    getch();
    for(i=0;i<100;i++)
    {
    member.memID=0;
    member.memName[30];
    // strcpy("unassigned",member.memName[30]);
    member.memAge=0;
    //fwrite(member,1,sizeof(member),ptr);
    }
    }

    fclose(ptr);
    menu();
    }

    void menu()
    {
    int ans;

    system("cls");
    printf("tttWelcome to Night Crawlers!nn");
    printf("Please select an option:n");
    printf(" n1)Add members");
    printf(" n2)Check a member's age");
    printf(" n3)Exitnn");

    scanf("%d",&ans);
    switch(ans)
    {
    case 1: addMember(); break;
    case 2: checkAge(); break;
    case 3: exit(1); break;
    default:menu(); break;
    }
    }
    void checkAge() //checks the age of a specific member and ether grants or denies access
    {
    system("cls");

    int key, posi=-1, i;
    FILE *ptr;
    MEMBER mem[5];

    ptr=fopen("nightcrawlers.dat","rb");

    printf("Please enter the ID# of the member's age you'd like to check: ");
    scanf("%d",&key);

    for(i=0;i<5;i++)
    {
    if(key==mem[i].memID)
    {
    posi=i;
    }
    }

    if(posi!=-1)
    {
    if(mem[posi].memAge>=18)
    {
    printf("nACCESS GRANTED!nn");
    printf("nnMember ID#: %d",mem[posi].memID);
    printf("nMember Name: %s",mem[posi].memName);
    // fflush(stdin);
    // puts(mem[posi].memName);
    printf("nMember Age: %d",mem[posi].memAge);
    }
    else
    {
    printf("nACCESS DENIED!nn");
    printf("nnMember ID#: %d",mem[posi].memID);
    printf("nMember Name: ");
    fflush(stdin);
    puts(mem[posi].memName);
    printf("nMember Age: %d",mem[posi].memAge);
    }
    getch();
    menu();
    }
    else
    {
    printf("Invalid input! Please try again!");
    checkAge();
    }
    }

    void addMember() //alows the user to add 5 members
    {
    FILE *ptr;
    MEMBER mem[5];
    int i;

    ptr=fopen("nightcrawlers.dat","wb");
    if(ptr==NULL)
    {
    printf("Error loading file…");
    getch();
    }
    else
    {
    for(i=0;i<5;i++)
    {
    printf("nnMember ID#: ");
    scanf("%d",&mem[i].memID);
    printf("nMember Name: ");
    fflush(stdin);
    gets(mem[i].memName);
    printf("nMember Age: ");
    scanf("%d",&mem[i].memAge);

    //fwrite(mem,sizeof(MEMBER),1,ptr);
    }
    }
    fclose(ptr);
    menu();
    }

  22. Nicholas Archibong Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    #define TRUE 1
    #define FALSE 0

    int main()
    {
    // checks for uppercase letter, a number, and a dollar sign

    char password[20];
    int upperFlag = FALSE;
    int numberFlag = FALSE;
    int dollarFlag = FALSE;
    int i = 0;
    char buffer;

    printf("Please enter a password that contains a uppercase letter, number, and dollar signn");

    scanf(" %s", password);

    while(password[i] != ''){
    buffer = password[i];
    printf("Buffer is: %cn", buffer);

    if(isupper(buffer)){
    upperFlag = TRUE;
    }

    if(isdigit(buffer)){
    numberFlag = TRUE;
    }

    if(buffer == '$'){
    dollarFlag = TRUE;
    }

    i++;
    }

    if(upperFlag && numberFlag && dollarFlag){
    printf("Your password checks out!n");
    }
    else{
    printf("Wrong password! Try again!n");
    }

    return 0;
    }

  23. skull fudger Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    int main()
    {
    int gay1 ='a',gay2 = 'Y',gay3 = '7',gay4 = '@',cod = 0,cod1 = 0,cod2 = 0,cod3 = 0;
    printf(" Your password is : %c %c %c %c nnn ",gay1,gay2,gay3,gay4);
    if(isalpha(gay1))
    {
    cod1 = 1;
    if(isupper(gay1))
    cod2 = 1;
    }
    else
    {
    cod = 1;
    }
    if(isalpha(gay2))
    {
    cod1 = 1;
    if(isupper(gay2))
    cod2 = 1;
    }
    else
    {
    cod = 1;
    }
    if(isalpha(gay3))
    {
    cod1=1;
    if(isupper(gay3))
    cod2=1;
    }
    else
    {
    cod = 1;
    }
    if(isalpha(gay4))
    {
    cod1 = 1;
    if(isupper(gay4))
    cod2 = 1;
    }
    else
    {
    cod = 1;
    }
    if (isdigit(gay1))
    cod3 = 1;
    else
    cod = 1;

    if (isdigit(gay2))
    cod3 = 1;
    else
    cod = 1;

    if (isdigit(gay3))
    cod3 = 1;
    else
    cod = 1;

    if (isdigit(gay4))
    cod3 = 1;
    else
    cod = 1;

    if(cod == 1 && cod1 == 1 && cod2 == 1 && cod3 == 1)
    printf("Ya Passward iz gud ! 🙂 nn");
    else
    printf( "Ya passward ZUCKS ! 🙁 nn");

    if(isalpha(gay1) && isalpha(gay2) && isalpha(gay3) && isalpha(gay4) )
    printf(" There are only letters in this password : %c t %c t %c t %c nn",gay1,gay2,gay3,gay4 );
    if(isdigit(gay1) && isdigit(gay2) && isdigit(gay3) && isdigit(gay4) )
    printf(" There are only number in this password : %c t %c t %c t %c nn",gay1,gay2,gay3,gay4 );

    return 0;
    }
    BALLZ TO YA

  24. Amanda Mthamalala Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    // HOW TO CODE A PASSWSORD

    int main(){
        setbuf(stdout, 0);
       char password[100];
     int count;
          printf("Please enter a password(the password must contain at least one number,upper case and $ ):n ");
           scanf(" %s", password);
      for(count=0; count<=100; count++){
            if(isupper(password[count]) || isdigit(password[count]) || password[count]=='$'){
                if (count<=100){
                    printf("Your password is awesome!n");
                    break;
                }
            }      else{
                printf("Please try again n");
                break;
            }
       }
       return 0;
    }

  25. Pen Lavits Avatar

    it works like it should well at least I think it does

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    int main(){

    char password[4];//array to store password
    int count;

    printf("Please enter a password of four characters long (which contains numbers/uppercaseletters/Dallorsign ) ");
    scanf("%s",password);// stores users password

    for(count=0; count<=4; count++){
    //below checks for uppercase letters /numbers/Dallor sign
    if(isupper(password[count]) || isdigit(password[count]) || password[count]=='$'){
    //check if condition is true and outputs message
    if (count==3){
    printf("Your password is awesome!n");
    break;
    }

    }else{
    //if the "if condition" is false it outputs this by default
    printf("Your password sucks! n");
    break;

    }

    }

    return 0;
    }

  26. Ahmed Mahmoud Avatar

    #include <stdio.h>
    #include <stdlib.h>

    #include <ctype.h>
    int main()
    {
    int x , y = 0 , q = 0 , r = 0 ;
    char c[6] ;
    printf("please enter your password n");
    printf("notice that the password max length is 6 and must have at least 1 upper case letter and 1 number and 1 $ n");

    scanf(" %s",c);

    for ( x = 0 ; x < 6 ; x++ )
    {
    if (c[x] == '$' )
    {
    y = y +1 ;
    }
    else if (isdigit(c[x]) )
    {
    q = q +1 ;
    }
    else if ( isupper(c[x]) )
    {
    r = r +1 ;
    }
    }

    if (q>0 && r>0 && y>0)
    {
    printf("congrats , you've entered a correct password n") ;
    }
    else {
    printf("please follow the instructions above n") ;
    }

    return 0;
    }

  27. Rutvik Gohil Avatar

    //may be unique One

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>

    int main()
    {

    char pass[20];
    int a, b, c ;
    int i ;

    printf("Note:Your Password must contain atleast one UPPERCASE Letter,Didit & $ sign !n");
    printf("Enter Password : ");

    do{
    scanf("%s",pass);

    for(i=0; i<=20; i++){
    if(isupper(pass[i])){
    a=1;
    }

    if(isdigit(pass[i])){
    b=1;
    }

    if(pass[i]=='$'){
    c=1;
    }
    }
    if(a!=1 || b!=1 || c!=1){
    printf("Ups ! try again : ");}

    }while(a!=1 || b!=1 || c!=1);

    if(a==1 && b==1 && c==1){
    printf("Great job ……..!");
    }
    return 0;
    }

  28. Abood Hussein Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <math.h>
    #include <string.h>

    typedef int bool;
    #define true 1
    #define false 0

    int main()
    {
    bool upper , alpha , digit , sympol;
    upper = alpha = digit = sympol = false;

    char pass[10];
    printf("Please enter a password: n");
    scanf("%s",pass);

    int i;

    for(i=0; i<=10; i++)
    {
    if(isalpha(pass[i]))
    {
    alpha = true;
    if(isupper(pass[i]))
    {
    upper = true;
    }
    }else if(isdigit(pass[i]))
    {
    digit = true;
    }else if(pass[i]=='$')
    {
    sympol = true;
    }
    }

    if( upper && digit && alpha && sympol )
    printf("You are good to go!");
    else printf("Your password is weak");

    return 0;
    }

  29. Md. Arman Hossen Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>

    int main()
    {
    char pass[30];
    int x, y, z, w;
    printf("Enter your password: ");
    scanf("%s", &pass);

    for(x=0; x<=30; x++){

    if (isupper(pass[x]))
    break;
    }

    for(y=0; y<=30; y++){

    if (islower(pass[y]))
    break;
    }

    for(z=0; z<=30; z++){

    if (isdigit(pass[z]))
    break;
    }

    for(w=0; w<=30; w++){
    if(pass[w]== '$')
    break;}

    if(x<30&&y<30&&z<30&&w<30)
    printf("password is good");
    else
    printf("Passwords must include Uppercase, Lowercase, digit & $ sign");
    return 0;
    }

  30. Sabya Bhoi Avatar

    I've kept it as simple as possible. Although I couldn't figure out how to check for the dollar sign :/

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>

    int main(){

    int containUpper = 0, containLower = 0;
    char password[12];

    printf("Enter your Passwordn");
    scanf("%s", password);

    for(int i=0;i<=sizeof(password);i++){
    if(isupper(password[i])){
    containUpper = 1;
    printf("Your password contains uppercase lettern");
    break;
    }
    }

    for(int i=0;i<=sizeof(password);i++){
    if(islower(password[i])){
    containLower = 1;
    printf("Your password contains lowercase lettern");
    break;
    }
    }

    if((containUpper == 1) && (containLower==1)){
    printf("Congrats! Your Password is Valid");
    }

    }

  31. Ahmed Abd El Salam Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <ctype.h>
    #include <string.h>

    int main()
    {
    char password[20];
    int i,j,k;
    i=j=k=0;
    int counter;
    printf("enter your password: maximum 20 in length make sure it has at least on special character ($ @ # _ &) n");
    scanf(" %s",password);

    for(counter=0;counter<=20;counter++){
    if(isupper(password[counter])){
    i++;
    }
    if(isdigit(password[counter])){
    j++;
    }
    if(password[counter]=='$' || password[counter]=='@'|| password[counter]=='#' || password[counter]=='_' || password[counter]=='&'){
    k++;
    }
    }
    if(i>=1 && j>=1 && k>=1){
    printf("this is a good password");
    }
    else{
    printf("this is a weak password");
    }
    }

  32. Skylar Kenneth Avatar

    For all of those who are studying programming, take a look at all these codes. Notice how unique they are. Look at the variable names, setup, and comments. Appreciate the different minds who tackle problems in their own understanding. Who knows, you may just learn something new. 🙂 Plus, it's easy to spot plagiarism

  33. Kendots Avatar

    #include<stdio.h>
    #include<string.h>
    #include<ctype.h>

    int main (){

    char s[20];
    int i,n,k=1;

    printf("Enter a passwordn");
    fgets(s,20,stdin);
    n=strlen(s);
    if (s[n-1]='n') s[–n]='';

    for (i=0; i<n; i++){
    if (isdigit(s[i])) k*=2;
    if (isupper(s[i])) k*=3;
    if (s[i]=='$') k*=5;
    }

    k%=30;
    if (k) printf("Your password sucksn");
    else printf("Your password is Okn");
    return 0;
    }

  34. Tayyab Mazhar Avatar

    Codes with functions taught by bucky uptil now.

    Checks if a password has an UPPER CASE letter,NUMBER and DOLLAR symbol
    .

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>
    // Code to check if the password contains an UPPER CASE LETTER, a NUMBER and a DOLLAR($) symbol.
    int main()
    {

    char password[20] ;
    int i= -1;
    printf("ENTER YOUR PASSWORD(limit 20 characters) ");
    scanf("%s",password);

    int uppercase=2;
    int letter;

    do{ i=i+1;
    if( (isupper(password[i])) ){ letter =uppercase – 1; break; }

    if( (i<20) ){continue;}

    if( (i=20) ){ letter= uppercase -2 ; }
    }
    while(i<20);

    int number;
    int j=-1;
    do{ j=j+1;
    if(isdigit(password[j]) ){number=1;break;}

    if( (j<20) ){continue;}

    if( (j=20) ){ number=0; }
    }
    while(j<20);

    int symbol;
    int k=-1;
    do{ k+=1;
    if( (password[k] == '$') ) {symbol = 1;break;}

    if( (k<20) ){continue;}

    if( (k=20) ){ symbol = 0 ; }
    }
    while(k<20);

    if( ( letter == 1 ) && ( number == 1 ) && ( symbol == 1 ) ) {
    printf("nYOU HAVE A STRONG PASSWORD");
    }
    else if( ( letter == 0 ) || ( number == 0 ) || (symbol == 0) ) { printf("nYOUR PASSWORD IS PATHETICn"); }

    return 0;
    }

  35. prime conqueror Avatar

    Hi everyone! This is my 2nd day of watching Bucky's C programming tutorial. So far I'm having so much fun learning C. This is my solution to the challenge.

    #include <stdio.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    int main() {

    char password[20];
    printf("This Program will record your passwordn");
    printf("Make sure the first 3 characters is eithern");
    printf("An Uppercase letter, a number and a lettern");
    printf("nnEnter your password: ");
    scanf(" %s", password);

    if((isdigit(password[0])||isdigit(password[1])||isdigit(password[2])) &&
    (isupper(password[0])||isupper(password[1])||isupper(password[2])) &&
    ((password[0] == '$')||(password[1] == '$')||(password[2] == '$'))
    )
    {
    printf("Verified!n");

    }else{
    printf("Not Verified!");
    }

    return 0;
    }

    P.S.
    As i was writing this code. I was thinking if its possible to answer this challenge by checking every characters in the password.
    ex.
    th3pas$worD = verified
    if so, how? or maybe i should carry on and watch more of Bucky's tutorial then i might have the answer.
    Anyway, if there is an area to improve in my code. please let me know. it would be much appreciated. thanks. have a nice day!

  36. M Purefoy Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>
    int upperCounter =0;
    int symbolCounter =0;
    int digitCounter =0;
    void Check_Password(char characters[]);
    int main()
    {
    char password [6];
    printf("Your password must have 6 characters, a $, an upperCase letter, and a number");
    printf("Please enter your Password: ");
    scanf("%s", password);
    Check_Password(password);

    return 0;
    }

    void Check_Password(char characters[])
    {
    for(int i = 0; i< sizeof(characters); i++)
    {
    if(isupper(characters[i]))
    {
    upperCounter++;
    }
    else if(isdigit(characters[i]))
    {
    digitCounter++;
    }
    else if(characters[i] == '$')
    {
    symbolCounter++;
    }
    }
    if(upperCounter >=1 && digitCounter >= 1 && symbolCounter >=1)
    {
    printf("n Nice Password n");
    }
    else
    printf("nTry another password n");
    printf("%d n",upperCounter);
    printf("%d n",digitCounter);
    printf("%d n",symbolCounter);
    }

  37. Coal Avatar

    Shouldn't the "for" loop continue?I did all if's so the loop will check them all out to give an output.
    Any help would be appreciated.
    ___________________________________________________________
    #include <stdlib.h>
    #include<ctype.h>
    #include<string.h>

    int main()
    {
    char password[50];
    int i;
    printf("Please create a password for your account.n");
    scanf(" %c",&password);

    for(i=0;i<=strlen(password);i++){
    if(isupper(password[i])){
    printf(".n"); //loop stopped here.
    }if(islower(password[i])){
    printf(".n");
    }if(isdigit(password[i])){
    printf(".n");
    }if(islower(password[i]='$')){
    printf("%c is okay.n",password);
    break;
    }else{
    printf("%c does not satisfy the current policy requirements.n",password);
    break;
    }
    }

    return 0;

    }

  38. Loquazart Avatar

    Apparently the website has changed… so does anyone know about the new one?

  39. Loquazart Avatar

    #include<stdio.h>
    #include<stdlib.h>
    #include<conio.h>
    #include<ctype.h>
    #include<string.h>

    int main()
    {

    char pass[20];
    int a,n,i,temp,sp;
    int digi,ch,up,low;
    digi=0;
    low=0;
    up=0;
    sp=0;

    printf("Emter the len n");
    scanf("%d",&n);
    printf("Enter pass such that it should have Upper case letter, a number, and '$' character n");
    scanf("%s",pass);
    printf(" Pass is %s n",pass);

    for(i=0;i<=n;i++)
    {

    // a = pass%10;

    /* if(isalpha(pass[i]))
    {ch++;}
    */

    if(isdigit(pass[i]))
    {digi++;}
    else if(isupper(pass[i]))
    {up++;}
    else if(pass[i]=='$')
    {sp++;}
    else if(islower(pass[i]))
    {low++;}
    else {printf("n Hi n");}

    }

    printf("digi is %d n low is %d n up is %d n sp is %d n",digi,low,up,sp);

    if(digi>0 && up>0 && sp>0)
    {printf(" Good pass n");}
    else
    {printf(" Weak pass n");}

    return 0;
    }

  40. Anthony Barnes Avatar

    This challenge was easy, but for a beginner it could be a challenge because he hasn't shown us how to iterate through an array at this point. Don't feel bad if you couldn't figure this out! Here is my solution:

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>

    int main() {
    int pass, upper, digi, dollar, i, len = 0;
    char password[20];

    printf("Enter your password (Must contain uppercase letter, number, and dollar sign)n");
    scanf("%s", &password);
    len = sizeof(password);

    for(i = 0; i < len; i++) {
    if (isupper(password[i])){
    upper = 1;
    }
    if (isdigit(password[i])){
    digi = 1;
    }
    if (password[i] == '$'){
    dollar = 1;
    }
    }
    if(upper>0 && digi>0 && dollar>0 ){
    printf("Well done, you entered a correct password");
    }else{
    printf("You Messed up");
    }

    return 0;
    }

  41. Sidhant Jain Avatar

    #include<stdio.h>

    int main()
    { char passwd[20];
    int a=0, b=0 ,c=0, i;
    do{ printf("Enter a password:");
    scanf("%s", passwd);

    for(i=0;i<=20;i++){

    if(isupper(passwd[i])){a=1;}
    if(isdigit(passwd[i])){b=1;}
    if(passwd[i] == '$') {c=1;}
    }
    if(a==1 && b==1 && c==1){
    printf("Password is strong, you are good to go…n");
    break; }
    else{
    printf("Your password is weak, try again idiot…n");
    }
    }
    while (a==0 || b==0 || c==0);
    return 0;
    }

  42. Khoi Nguyen Avatar

    #include <stdio.h>
    #include <ctype.h>

    void checkPass(char pass[]);

    int main() {

    // Write a program to check a password which consists of an upper case letter, a number and a $ sign
    char pass[9]; // Declare an array of input

    printf("Enter your password (requires an upper case, a number, and a $): "); // prompt user to input
    scanf("%s", pass); // save the input

    checkPass(pass); // call a function

    return 0;
    }

    void checkPass(char pass[]) {

    int i, flag1 = 0, flag2 = 0, flag3 = 0; // declare some necessary variables

    for(i = 0; i < 9; i++) { // loop thru the array
    if(isupper(pass[i])) { // check if the input has an upper case letter
    flag1 = 1; // 1 means yes
    }
    if(isdigit(pass[i])) { // check if the input has a digit
    flag2 = 1;
    }
    if(pass[i] == '$') { // check if the input contains a '$'
    flag3 = 1;
    }
    }

    if(flag1 == 1 && flag2 == 1 && flag3 == 1) { // conditions to sastify the required password
    printf("Your password is good to use!");
    } else {
    printf("Your password sucks");
    }

    }

  43. Constantine Heo Avatar

    Can anyone please tell me why my code doesn't work in the way that i want? And how can i improve it?

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    #include <math.h>

    int main()
    {

    char password[20];
    printf("Enter password with lowercase and uppercase letters and numbern");
    scanf("%s", password);
    printf("%sn", password);
    int i=0;
    int a=0;
    int b=0;
    int c=0;
    int d=0;

    for(i=0;i<20; i++){
    if(isalpha(password[i])){
    a++;
    }
    if(isdigit(password[i])){
    b++;
    }
    if(isupper(password[i])){
    c++;
    }
    if(islower(password[i])){
    d++;
    }
    }
    printf("a=%dn", a);
    printf("b=%dn", b);
    printf("c=%dn", c);
    printf("d=%dn", d);

    if(a=0){
    printf("Missing alphabet");
    }
    if(b=0){
    printf("Missing number");
    }
    if(c=0){
    printf("Missing uppercase letter");
    }
    if(d=0){
    printf("Missing lowercase letter");
    }
    if(a>0, b>0, c>0, d>0){
    printf("Well done");
    }

    return 0;
    }

  44. Caio Costa Avatar

    Had to get help from a friend. Used ASCII label for the if statements.
    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>
    #include<string.h>

    int main()
    {

    int i, uc, lc, sy, nu;
    char pw[40];

    printf("Let's create a password for you!nIt needs to contain:n1.One uppercase character.n2.One lowercase character.n3.One number.n4.One '$'.n");
    printf("Password may not be longer than 40 characters nor have less than 8 characters.n");
    printf("Insert your password: ");
    scanf(" %s", pw);

    i = 0;
    while( pw[i]!='' && i!=40 ){
    if (pw[i]>=65 && pw[i]<=90){
    uc = 1;
    }else if (pw[i]>=97 && pw[i]<=122){
    lc = 1;
    }else if (pw[i]>=48 && pw[i]<=57){
    nu = 1;
    }else if (pw[i] == '$'){
    sy = 1;
    }
    i++;
    }
    if (uc == 1 && lc == 1 && nu == 1 && sy == 1 && i >=8){
    printf("Nice choice! You're good to go.'n");
    }else{
    printf("WTH bro, ik u can do better than that!n");
    }

    return 0;
    }

  45. Sachiyo Daley Avatar

    Managed to make one that keeps asking until the password is acceptable, not too sure if its written as efficiently as it could be but hope it helps anyone stuck :),

    /*This code is intended to test an input password and prompt the user to create
    an acceptable password*/

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <math.h>

    int main()
    {
    // initialise the password slot
    //and the variables to determine content
    char password[11];
    int i, verified; // 'i' will be used while checking each element of the password, 'verified' will end the code
    int Ucase, Lcase, Dollar; //initialise the three requirements
    printf("Please input a password between 3 and 10 characters, do not include 'spaces' in your password n");

    //set all variables to zero to start the loop
    verified =0;
    Ucase = Lcase = Dollar = 0;

    while (verified == 0){

    //keep asking to input password until all requirements are met
    if((Ucase<1) || (Lcase<1) || (Dollar <1)){
    Ucase = Lcase = Dollar = 0; //ensure all variables are zero before re-requesting a password
    printf("It must have at least one upper and lower case letter and at least one 'dollar sign': n");
    scanf(" %s", password);

    // check each character in the password
    for (i=0; i <=strlen(password); i++){
    if (isalpha(password[i])){
    if (isupper(password[i])){
    Ucase+=1;// add one to Ucase for every time it occurs
    }else
    Lcase+=1;// add one to Lcase every time it occurs

    }
    if (password[i]== '$' ){
    Dollar+=1;// add one to Dollar every time it occurs

    }else{}

    };

    //if all requirements are met add one to verified and exit the while loop
    }else{
    verified++;
    }
    }
    printf("Password accepted");

    return 0;
    }

  46. Christos Gkanidis Avatar

    #include<stdio.h>
    #include<ctype.h>
    #define N 30
    int main()
    {
    int length,up=0,letter=0,dollar=0,i;
    char password[N];
    printf("Write your password n");
    gets(password);
    length=strlen(password);
    for(i=0; i<length; i++){
    if (isalpha(password[i])){
    if(isupper(password[i]))
    up=1;
    }else
    if(isdigit(password[i]))
    letter=1;
    if(password[i]=='$')
    dollar=1;
    }
    if(up==1 && letter==1 && dollar==1)
    printf("password correctn");
    else
    printf("wrong passwordn");
    return 0;
    }

  47. yaggenlol Avatar

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>

    int main(void)

    {
    char password[20];
    int flag1, flag2, flag3;
    int i;
    printf("Please enter your password n");

    scanf(" %s",&password);

    for (i = 0; i <=20; i++) {
    if (isupper(password[i])){
    flag1 = 1;
    } if (password[i] == '$'){
    flag2 = 1;
    } if (isdigit(password[i])){
    flag3 = 1;
    }
    }

    if ( flag1 == 1 && flag2 == 1 && flag3 == 1) {
    printf("Strong password! n");
    } else {

    printf("Weak password! n");

    }

    }

Leave a Reply

Your email address will not be published. Required fields are marked *