Write program that reads an integer N from keyboard computes and display the sum of number from N to (2*N) if N is non-negative.If N is negative number, the it's sum of the number (2*N) to N. The starting and ending point are included in the sum.
Answers
Answered by
2
Answer:
mark as branlist
this works completely in c language
*********************
#include <conio.h>;
#include <stdio.h>;
void main ()
{
int n,x;
clrscr ();
printf ("enter number to multiply /n");
scanf ("%d",&n);
x=n*2;
printf (answer= );
printf ("%d",x);
}
Answered by
0
Answer:
N=int(input("Enter the value of N:"))
summ=0
if N<0:
for i in range(N*2,N+1):
summ+=i
print("Sum of the numbers from (N*2) to N is:",summ)
else:
for i in range(N,(N*2)+1):
summ+=i
print("Sum of the numbers from N to (N*2) is:",summ)
Explanation:
Similar questions