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



create a login program that ask username and password. if you input username or password 3 times w..

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

create a login program that ask username and password. if you input username or password 3 times w..

Answer / atit

I was using by educational purpose

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

Give a one-line C expression to test whether a number is a power of 2.

10 Answers   Microsoft,


abcdedcba abc cba ab ba a a

2 Answers  


#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }

0 Answers  


write a c program to Create a mail account by taking the username, password, confirm password, secret_question, secret_answer and phone number. Allow users to register, login and reset password(based on secret question). Display the user accounts and their details .

2 Answers  


Write a c program to search an element in an array using recursion

1 Answers   Wipro,






#include <stdio.h> int main(void) { int a=4, b=2; a=b<<a+b>>2 ; printf("%d",a); return 0; }

0 Answers   Student,


int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

2 Answers   CSC,


why array index always strats wuth zero?

2 Answers  


main() { int (*functable[2])(char *format, ...) ={printf, scanf}; int i = 100; (*functable[0])("%d", i); (*functable[1])("%d", i); (*functable[1])("%d", i); (*functable[0])("%d", &i); } a. 100, Runtime error. b. 100, Random number, Random number, Random number. c. Compile error d. 100, Random number

1 Answers   HCL, rsystems,


Question: We would like to design and implement a programming solution to the reader-writer problem using semaphores in C language under UNIX. We assume that we have three readers and two writers processes that would run concurrently. A writer is to update (write) into one memory location (let’s say a variable of type integer named temp initialized to 0). In the other hand, a reader is to read the content of temp and display its content on the screen in a formatted output. One writer can access the shared data exclusively without the presence of other writer or any reader, whereas, a reader may access the shared memory for reading with the presence of other readers (but not writers).

1 Answers  


char *someFun1() { char temp[ ] = “string"; return temp; } char *someFun2() { char temp[ ] = {‘s’, ‘t’,’r’,’i’,’n’,’g’}; return temp; } int main() { puts(someFun1()); puts(someFun2()); }

2 Answers  


write a program to Insert in a sorted list

4 Answers   Microsoft,


Categories