C programming language

Talk about anything.
17 posts Page 1 of 2

IDoNotKeyBind

IDoNotKeyBind
Posts: 84
Joined: March 24, 2016, 9:37 am

Post by IDoNotKeyBind » June 11, 2016, 1:55 pm
Hello, if anyone of you is into C programming language and knows how to code and stuff. Please give me coding of this question, any help would be appreciated.
Just for you to know, I use code blocks, to code and compile.

Q. You have to enter a password, and tell that if it is a weak password or strong on the basis of the following:
1. It should contain an uppercase letter.
2. It should contain a lowercase letter.
3. It should contain a digit.
4. It should not be more than 20 characters.
5. It should contain the '$'(dollar) sign.
That's it.
Thank you for your help (even if you don't because reading is pain in the ass when you know nothing about it).

Jaker

User avatar
Jaker
Donator
Posts: 2203
Joined: January 12, 2013, 12:35 pm

Post by Jaker » June 11, 2016, 2:06 pm
IDoNotKeyBind wrote:
Hello, if anyone of you is into C programming language and knows how to code and stuff. Please give me coding of this question, any help would be appreciated.
Just for you to know, I use code blocks, to code and compile.

Q. You have to enter a password, and tell that if it is a weak password or strong on the basis of the following:
1. It should contain an uppercase letter.
2. It should contain a lowercase letter.
3. It should contain a digit.
4. It should not be more than 20 characters.
5. It should contain the '$'(dollar) sign.
That's it.
Thank you for your help (even if you don't because reading is pain in the ass when you know nothing about it).
I have an older brother which is an absolute pro in programming (currently he's doing C++, but he knows C as well. He's won 2 silver and 2 gold medals on World and European Olympiads in Informatics (programming). I'll tell him about your problem and then forward it here or to your PM.

Kaosx234

User avatar
kaosx234
Posts: 8614
Joined: October 7, 2012, 7:34 am
Location: Hrvatska, Split

Post by Kaosx234 » June 11, 2016, 2:10 pm
Jaker wrote:
IDoNotKeyBind wrote:
Hello, if anyone of you is into C programming language and knows how to code and stuff. Please give me coding of this question, any help would be appreciated.
Just for you to know, I use code blocks, to code and compile.

Q. You have to enter a password, and tell that if it is a weak password or strong on the basis of the following:
1. It should contain an uppercase letter.
2. It should contain a lowercase letter.
3. It should contain a digit.
4. It should not be more than 20 characters.
5. It should contain the '$'(dollar) sign.
That's it.
Thank you for your help (even if you don't because reading is pain in the ass when you know nothing about it).
I have an older brother which is an absolute pro in programming (currently he's doing C++, but he knows C as well. He's won 2 silver and 2 gold medals on World and European Olympiads in Informatics (programming). I'll tell him about your problem and then forward it here or to your PM.
Year and for which school?
Image
Zoroark wrote:
I've given people in game money
His life is fulfilled now

[Lsrcr]Oggy

User avatar
Oggy
Posts: 2507
Joined: August 26, 2014, 6:29 am
Location: Los Santos

Post by [Lsrcr]Oggy » June 11, 2016, 2:20 pm
I would have sent you the code but...
This rule in ls-rcr.com/rules: Do not send any executable files or scripts to other players.
I'm not sure if that rule applies to this but I don't want to take risk.
Image

Auto

Auto
Retired Administrator
Posts: 5006
Joined: July 14, 2011, 8:39 pm
Location: US

Post by Auto » June 11, 2016, 2:25 pm
That's a pretty simple program, but it seems like this is a homework problem. I'm not going to do your homework for you but I will guide you in the right direction. Here are the steps I would take to solve the program.
  1. Print instructions and password requirements to user
  2. Request user input (password), store this in a local variable (I assume you aren't encrypting it or tying it to a user account)
  3. Create a function isPassStrong, passing the password variable by value
    • Create an else-if ladder that checks for each password requirement
      • If every check passes successfully, return true
      • If at least one check does not pass, return false and tell user to strengthen their password by fixing the problem
When you perform your checks, I would start with making sure the password length is good first, then look for the upper/lowercase letters, then the digit, then the dollar sign. Best of luck.

[Lsrcr]Oggy

User avatar
Oggy
Posts: 2507
Joined: August 26, 2014, 6:29 am
Location: Los Santos

Post by [Lsrcr]Oggy » June 11, 2016, 2:31 pm
Go through all the characters of the password and for a character ch,

1) if (ch >= 'A' && ch <= 'Z') then it's a upper case letter
2) if (ch < 'A' || ch > 'Z') then it's a lower case letter
3) if(isdigit(ch)), then it's a digit
4) if(strlen(password)>=20), this checks if the password has atleast 20 characters
5) if(ch=='$')


EDIT: For going through each characters,

char ch;
for(i=0; i<strlen(password); i++)
{
ch=password;
blah blah blah
}
Last edited by [Lsrcr]Oggy on June 11, 2016, 3:01 pm, edited 7 times in total.
Image

Naruk

User avatar
Naruk
Posts: 1042
Joined: July 8, 2013, 1:51 pm
Location: Visayas, Cebu, Cebu City

Post by Naruk » June 11, 2016, 2:53 pm
I only know Visual Basic 6 language
"LIfe is fair because it is unfair to everyone."

An ordinary player.

Jaker

User avatar
Jaker
Donator
Posts: 2203
Joined: January 12, 2013, 12:35 pm

Post by Jaker » June 11, 2016, 3:06 pm
Spoiler: show
Finished Computer Science (preddiplomski, FER)

Shirt

Shirt
Posts: 45
Joined: April 12, 2014, 9:39 am
Location: India - Uttar Pradesh - Bareilly - Somewhere There

Post by Shirt » June 11, 2016, 3:09 pm
ATGOggy wrote:
Go through all the characters of the password and for a character ch,

1) if (ch >= 'A' && ch <= 'Z') then it's a upper case letter
2) if (ch < 'A' || ch > 'Z') then it's a lower case letter
3) if(isdigit(ch)), then it's a digit
4) if(strlen(password)>=20), this checks if the password has atleast 20 characters
5) if(ch=='$')


EDIT: For going through each characters,

char ch;
for(i=0; i<strlen(password); i++)
{
ch=password;
blah blah blah
}

thank you so much for your guidelines, would definitely try out this.
but what I didn't get here is, this part
char ch; \\got it
for(i=0; i<strlen(password); i++) \\the part which I didn't get
{
ch=password
please explain me that 'for' part.

@Auto;
No, it is not any homework, I was just learning C programming through youtube because it cost too much to learn from any IRL teacher. And I saw this question in some forums I suppose and then was not able to do it. So, I thought let's ask you guys.
@Jaker;
Would appreciate your help, mate.
Image
Pro Rapist ||Pro Robber ||Pro Arrester ||Pro Tazer ||Pro Modder ||Determined To Be A Swat/Army/Pagati ||Banned ||Name Loved By [Lsrcr]Dani6

Jaker

User avatar
Jaker
Donator
Posts: 2203
Joined: January 12, 2013, 12:35 pm

Post by Jaker » June 11, 2016, 3:36 pm
Here, this is what my bro has written(source: https://gist.github.com/anonymous/25693 ... 4a781c260e)
Code: Select all
#include <stdio.h>
#include <ctype.h>

char s[100];

int main() {
  scanf("%s", s);

  int has_upper = 0;
  int has_lower = 0;
  int has_digit = 0;
  int has_dollar = 0;

  for (char *c = s; *c; ++c) {
    if (isupper(*c)) has_upper = 1;
    if (islower(*c)) has_lower = 1;
    if (isdigit(*c)) has_digit = 1;
    if (*c == '$') has_dollar = 1;
  }

  if (strlen(s) <= 20 && has_upper && has_lower && has_digit && has_dollar)
    puts("Strong");
  else
    puts("Weak");

  return 0;
}
17 posts Page 1 of 2
Return to “The Bar”

Who is online

Users browsing this forum: No registered users and 4 guests