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 |
Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
Under linux environment can u please provide a c code for computing sum of series 1-2+3-4+5......n terms and -1+2-3+4-5...n terms..
How do you write a program which produces its own source code as its output?
#include <stdio.h> int main(void) { int a=4, b=2; a=b<<a+b>>2 ; printf("%d",a); return 0; }
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
Is the following code legal? typedef struct a { int x; aType *b; }aType
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
Write a program to print a square of size 5 by using the character S.
main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }
write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"
int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().
could you please send the program code for multiplying sparse matrix in c????