Sum Input Values and Determine Difficulty
This C program reads a number 'n' from the user, then reads 'n' integers, summing them up. If the total sum is not zero, it outputs 'HARD'; otherwise, it outputs 'EASY'. This snippet is useful for understanding basic input/output operations and conditionals in C.unknown
c_cpp
13 days ago
298 B
9
Indexable
Never
#include<stdio.h> int main() { int n, i, a; int total = 0; scanf("%d", &n); for(i = 0; i < n; i++) { scanf("%d", &a); total += a; } if(total != 0) { printf("HARD\n"); } else { printf("EASY\n"); } return 0; }
Leave a Comment