Friday 18 March 2016

Solution of URI 1114 :: Fixed Password


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int x;
    while(1)
    {
        scanf("%d", &x);
        if(x==2002)
        {
            printf("Acesso Permitido\n");
            break;
        }
        else
            printf("Senha Invalida\n");
    }
    return 0;
}

2 comments:

  1. #include
    int main ()
    {
    int i,a,b=2002;
    for(i=0;i<100;i++){
    scanf("%d",&a);
    if(a==b) printf("Acesso Permitido\n");
    if(a>b || a<b)printf("Senha Invalida\n");

    }
    return 0;
    }
    why this in not accepting??

    ReplyDelete
    Replies
    1. Because the question says when the password is typed correctly then the program is finished, But your code says the loop run 100 times and doesnt matter the password is typed correctly or not

      Delete

Note: only a member of this blog may post a comment.