The document contains 4 programs labeled P1 through P4. Each program prompts the user to input a number n, initializes variables s and p, uses a while loop from 1 to n, performs conditional logic on i based on its modulus, updates s and p, prints the results, and ends. P1 sums odd numbers and multiplies all. P2 sums even numbers and multiplies all. P3 sums numbers divisible by 3 and multiplies all. P4 sums numbers divisible by 4 and multiplies all.
The document contains 4 programs labeled P1 through P4. Each program prompts the user to input a number n, initializes variables s and p, uses a while loop from 1 to n, performs conditional logic on i based on its modulus, updates s and p, prints the results, and ends. P1 sums odd numbers and multiplies all. P2 sums even numbers and multiplies all. P3 sums numbers divisible by 3 and multiplies all. P4 sums numbers divisible by 4 and multiplies all.
The document contains 4 programs labeled P1 through P4. Each program prompts the user to input a number n, initializes variables s and p, uses a while loop from 1 to n, performs conditional logic on i based on its modulus, updates s and p, prints the results, and ends. P1 sums odd numbers and multiplies all. P2 sums even numbers and multiplies all. P3 sums numbers divisible by 3 and multiplies all. P4 sums numbers divisible by 4 and multiplies all.
var i, n, s, p: integer; var i, s,n, p: integer; begin begin writeln (‘n=’); readln (n); writeln (‘n=’); readln(n); s:=0; s:=0; p:=1; p:=1; while i<=n do while i<=n do begin begin if (i mod 2 <>0) then s:=s+i; if (i mod 2=0) then s:=s+i; p:=p*i; p:=p*i; writeln (‘s=’,s); writeln (‘p=’,p); writeln (‘s=’,s); writeln (‘p=’,p); end; end; readln; readln; end. end.
c) Program P3; d) Program P4;
var i, n, s, p: integer; var i, n, s, p: integer; begin begin writeln (‘n=’); readln (n); writeln (‘n=’); readln (n); s:=0; s:=0; p:=1; p:=1; while i<=n do while i<=n do begin begin if (i mod 3=0) then s:=s+i; if (i mod 4=0) then s:=s+i; p:=p*i; p:=p*i; writeln (‘s=’,s); writeln (‘p=’,p); writeln (‘s=,s); writeln (‘p=’,p); end; end; readln; readln; end. end.