🔒 Closed Pahelp naman po sa c++ coding mga lodi

Status
Not open for further replies.
Kung di ka marunong mag simula ka dito:
C++ Syntax: You do not have permission to view the full content of this post. Log in or register now.
C++ Output: You do not have permission to view the full content of this post. Log in or register now.
C++ Variables: You do not have permission to view the full content of this post. Log in or register now.
C++ User Input: You do not have permission to view the full content of this post. Log in or register now.
C++ If/Else: You do not have permission to view the full content of this post. Log in or register now.

May mga example naman yan saka basic lang yan at madaling maintindihan kahit 0 knowledge ka sa C++
Pag alam mo na ang 5 na yan madali nalang yan, isang string variable and if else lang kailangan mo diyan.
 
#include <iostream>
#include <string>

using namespace std;

int main () {

string password;

cout<<"Enter a password: ";
getline (cin,password);


if(password==password){
cout<<"Valid password.";
}
else {
cout<<"Invalid password!";
}
return 0;
}



eto po kase code ko eh puro valid po lumalabas. dapat pg nag input ng integer invalid po sana. kaso nagiging valid padin
 
#include <iostream>
#include <string>

using namespace std;

int main () {

string password;

cout<<"Enter a password: ";
getline (cin,password);


if(password==password){
cout<<"Valid password.";
}
else {
cout<<"Invalid password!";
}
return 0;
}



eto po kase code ko eh puro valid po lumalabas. dapat pg nag input ng integer invalid po sana. kaso nagiging valid padin
Good at gumawa ka ng sarili mong code.
Yung ilagay mo sa if condition mo ay ganito
C++:
if (password == "yung ilalagay mo dito ay yung gusto mong maging password")

// example
    
if (password == "1234")

So sa ibinigay kong example 1234 yung password, so pag hindi 1234 yung ininput ng user mag iinvalid yung output. And if 1234 ininput ng user edi yung if statement yung mag eexecute at valid password lalabas
 
galeng! Pano yan lods?
C++:
#include<iostream>
using namespace std;

int main ()
{
    
    string password;
    char ch;

    here:
    cout << "Enter your password: ";

    while (getline(cin, password))
    {
        for (int i = 0; i < password.length(); i++) {
    
            ch = password.at(i);
    
            
            if (!(( ch >= 'a' && ch <= 'z' )||( ch >= 'A' && ch <= 'Z' ))) {
                cout << "Error!" << endl << endl;
                goto here;
                
                
            } else {
                cout << "The password you entered is valid." << endl << endl;
                goto here;
                
            }
         }
     }
    
    
}

Gawin mo na yan na reference.
 
Status
Not open for further replies.

About this Thread

  • 14
    Replies
  • 341
    Views
  • 3
    Participants
Last reply from:
itsmeaze

Trending Topics

Online now

Members online
1,168
Guests online
1,970
Total visitors
3,138

Forum statistics

Threads
2,293,791
Posts
29,086,723
Members
1,207,964
Latest member
Adhitya17
Back
Top