6. Based on question 5, modify the program to keep track of the number of attempted password guesses. It then prints: “The password was cracked after ‘n’ amount of tries”, n being the tracking variable.
Sat Jul 22 2023 15:25:07 GMT+0000 (Coordinated Universal Time)
Saved by
@Codes
// Online C compiler to run C program online
#include <stdio.h>
int main() {
int code = 1324;
int n;
int count;
printf("Enter the number: ");
scanf("%d", &n);
for(int i = 0; i == count; i++){
count ++;
if(code==n){
printf("Password cracked");
break;
}
else{
printf("Enter again: ");
scanf("%d", &n);
}
}
printf("\nThe password was cracked after %d amount of tries", count);
return 0;
}
content_copyCOPY
Comments