Data Entry System
C
Hard
4 views
Problem Description
Input multiple records (name and age) in a loop. After each entry ask "Add more? (y/n)". Validate input - name must not be blank, age must be between 1-120.
Official Solution
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
char name[50];
int age;
char choice;
while (1) {
/* ---- Name Input ---- */
while (1) {
printf("nEnter name: ");
fgets(name, sizeof(name), stdin);
// Remove newline
name[strcspn(name, "n")] = '