Answer:
total=0
def calcsumnumsquare(k,total):
while k>=1:
total+=int(k)*int(k)
k-=1
return total
print(calcsumnumsquare(4,0))
Explanation:
The program required is written above. It uses only two variables k and total as mentioned in the question. And the total is initially set to 9, and then its value is incremented by the square of each k during each loop established by while loop. And finally, when k=1, the output is returned. And we have printed the return value using print.
In my opinion I think that the iPhone XR is better for gaming.
Answer:
# include<iostream>
# include<stdio.h>
# include<stdlib.h>
using namespace::std;
int main()
{
int *a=NULL;
int n; int score=0;
cout<<"Enter the value of N";
cin>>n;
a=new int[n];
cout<<"Enter the elements of a";
for(int i=0;i<=n;i++)
{
cin>>a[i];
}
int num=n;int k=n;int j=num;
while(j>=num)
{
if(n%2==0)
{
for(int i=0;i<=k;i++)
{
score+=a[i];cout<<score; }
if(a[0]>a[n])
{
a[n]=0;
n--;
}
else if(a[0]<a[n])
{
a[0]=0;
n--;
}
else if(n==1)
{
exit(0);
}
}
else
{
for(int i=0;i<=n;i++)
{
score-=a[i];
}
if(a[0]>a[n])
{
a[n]=0;
n--;
}
else if(a[0]<a[n])
{
a[0]==0;
n--;
}
else
{
exit(0);
}
}
j--;
}
cout<<"score"<<score;
return 0;
}
Explanation:
The array above is created dynamically, and rest is as mentioned in question.