program SumLessN;
const
MAX_N = 100;
var
A: array[1..MAX_N] of integer;
N, i, sum: integer;
begin
writeln('Enter the value of N:');
readln(N);
writeln('Enter the array A:');
for i := 1 to N do
readln(A[i]);
sum := 0;
if A[i] <= N then
sum := sum + A[i];
writeln('Sum of elements less than or equal to N:', sum);
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
program SumLessN;
const
MAX_N = 100;
var
A: array[1..MAX_N] of integer;
N, i, sum: integer;
begin
writeln('Enter the value of N:');
readln(N);
writeln('Enter the array A:');
for i := 1 to N do
readln(A[i]);
sum := 0;
for i := 1 to N do
if A[i] <= N then
sum := sum + A[i];
writeln('Sum of elements less than or equal to N:', sum);
end.