Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Write a prog. that accept a number passwrd and checks if the length of that passwrd is greater than 8chars.

2 Answers

+1 vote
answered Dec 8, 2019 by Donzy Botwe (440 points)
#include <iostream>

int main() {

    long long n;

    int password = 0;

    printf("Enter your password: ");

    scanf("%lld", &n);

    while (n != 0) {

        n /= 10;     // n = n/10

        ++password;

    }

   

    if(password>8)

    {printf("Correct password");

}

    else if(password<=8)

    {printf("In correct !!!");

}

}

with this code when a user enters his/her password it will count the number of integers in the password internally and if the number is greater than 8 characters it outputs correct and if below or equal to 8 output incorrect.

With this I hope it worked
0 votes
answered Dec 8, 2019 by anonymous

#include <iostream>

int main() {

    long long n;

    int password = 0;

    printf("Enter your password: ");

    scanf("%lld", &n);

    while (n != 0) {

        n /= 10;     // n = n/10

        ++password;

    }

   

    if(password>8)

    {printf("Correct password");

}

    else if(password<=8)

    {printf("In correct !!!");

}

 

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...