Hi

I'm biggener in c language and I hope from every one in this forum help me.

now I will start first Q

How I can write a c program to comput the sum of sequres of numbers from m to n .

for exsample : from3 ot 6 : 3^2+4^2+5^2+6^2=

CDROOM 0 Newbie Poster

Hi

I'm biggener in c language and I hope from every one in this forum help me.

now I will start first Q

How I can write a c program to comput the sum of sequres of numbers from m to n .

for exsample : from3 ot 6 : 3^2+4^2+5^2+6^2=

rowly 0 Junior Poster in Training

Hi

I'm biggener in c language and I hope from every one in this forum help me.

now I will start first QHow I can write a c program to comput the sum of sequres of numbers from m to n .

for exsample:(from3 ot 6) : 3^2+4^2+5^2+6^2=

think about it like this !

ask the user to enter two numbers the first(m) and the last (n)

second ya gonna count from m to n so from 3 to 6 ! (for loop)

with condition that 3 is included and 6 is included.

zn multiply each number by it self and add it to the total (you create a total to carry all the sum)

after that output the total.

cime63 0 Newbie Poster

you can use for(int i = m;i <= n; i ++) to get the sum value

CDROOM 0 Newbie Poster

I wrote this program put I don not know whare is th mestake

#incluode<stdio.h>

main()

{

int m,n,sum=0,i=m;

printf("enter two numbers one greater than other");

scanf("%d%d",&m,&n);

for(i=m;i<=n;i++)

{

sum=sum+(i*i);

printf(" sum sequare from %d to sequare%d is %d",m,n,sum);

}

}

Salem 5,138 Posting Sage

> printf(" sum sequare from %d to sequare%d is %d",m,n,sum);

Maybe put this line outside the for loop?

Does it print the right answer on the last iteration of the loop?

cime63 0 Newbie Poster

can you give the errror message?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.