Try This
drop table t1;
create table t1
(
"id" number(10),
"name" varchar2(100),
"age" number(10),
"gender" char(1),
"BALANCE" number(10)
);
insert into t1 values(1001,'john',10,'M',10);
insert into t1 values(1002,'Meena',5,'F',0);
insert into t1 values(1003,'Nikh',11,'M',0);
insert into t1 values(1004,'divs',7,'F',0);
insert into t1 values(1005,'neha',4,'F',0);
select * from t1;
And Create A Procedure like this
declare
initBal t1."BALANCE"%type;
begin
select "BALANCE" into initBal from t1 where rownum<=1 order by "id";
for c in (select rownum slno, "id","name","age","gender","BALANCE" from t1 order by "id")
loop
if c.slno >1 then
if c."gender" = 'M' then
initBal := initBal+c."age";
elsif c."gender" = 'F' then
initBal := initBal-c."age";
end if;
end if;
dbms_output.put_line(c."id"||' , '||c."name"||' , '||c."age"||' , '||c."gender"||' , '||initBal);
end loop;
end;
Here we can see output on dbms output window