create a login program that ask username and password. if you
input username or password 3 times wrong, the program will
terminate else the program will prompt a message
"congratulations"
Answers were Sorted based on User's Feedback
Answer / lokesh ketha
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char u[10],p[10],user[]="lokesh",pas[]="spiderman";
int n=0;
clrscr();
printf("\n press enter and enter username and password(only
3 attempts)");
while(n<=2)
{
printf("\n Username: ");
scanf("%s",&u);
printf("\n Password: ");
scanf("%s",&p);
if(strcmp(user,u)==0 && strcmp(pas,p)==0)
{
printf("\n Congratulations!");
break;
}
else
{
n++;
printf("\n the username or password is incorrect. only %d
trials left. press enter", 3-n);
}
}
if(n==3)
{
printf("\n you have used maximum attempts(3). please try
later.");
}
getch();
}
| Is This Answer Correct ? | 31 Yes | 19 No |
Is this code legal? int *ptr; ptr = (int *) 0x400;
what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }
#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }
There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.
main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }
how can i cast a char type array to an int type array
String reverse with time complexity of n/2 with out using temporary variable.
{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
What is "far" and "near" pointers in "c"...?
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
how to return a multiple value from a function?
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }