Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > how can i do ?

Reply
Thread Tools

how can i do ?

 
 
wahid
Guest
Posts: n/a
 
      01-10-2010
• Write a program that will take an integer
number n input from the user, and then
output the value of the sum of the series
• S = 12 + 22 + 32+….. + n2
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      01-10-2010
wahid wrote:
> • Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> • S = 12 + 22 + 32+….. + n2


Solve the problem on paper, then convert it to code, then post your
attempt if you have problems.

Asking people to do your homework is a great way to learn absolutely
nothing and fail your exams.

--
Ian Collins
 
Reply With Quote
 
 
 
 
wahid
Guest
Posts: n/a
 
      01-10-2010
On Jan 10, 1:05*pm, wahid <wahid.1...@gmail.com> wrote:
> • Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> • S = 1^2 + 2^2 + 3^2+….. + n^2


 
Reply With Quote
 
Seebs
Guest
Posts: n/a
 
      01-10-2010
On 2010-01-10, wahid <> wrote:
> ? Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> ? S = 12 + 22 + 32+?.. + n2


You never post thank-you notes to the people who do your homework, why is
that?

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      01-10-2010
wahid <> writes:
> • Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> • S = 12 + 22 + 32+….. + n2


Go away and do your own damned homework.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Nick
Guest
Posts: n/a
 
      01-10-2010
Seebs <usenet-> writes:

> On 2010-01-10, wahid <> wrote:
>> ? Write a program that will take an integer
>> number n input from the user, and then
>> output the value of the sum of the series
>> ? S = 12 + 22 + 32+?.. + n2

>
> You never post thank-you notes to the people who do your homework, why is
> that?


He did to the last one (the print the three digits). There were some
beautiful answers there, I wonder which one he used.
--
Online waterways route planner | http://canalplan.eu
Plan trips, see photos, check facilities | http://canalplan.org.uk
 
Reply With Quote
 
Ike Naar
Guest
Posts: n/a
 
      01-10-2010
In article <5b81f591-811c-43fb-9b78->,
wahid <> wrote:
>On Jan 10, 1:05*pm, wahid <wahid.1...@gmail.com> wrote:
>> • Write a program that will take an integer
>> number n input from the user, and then
>> output the value of the sum of the series
>> • S = 1^2 + 2^2 + 3^2+….. + n^2

>


#include<stdio.h>/**/
int main(void){int n;
scanf("%d",&n);printf
("%d\n",(((n<<1)+(1<<
1)+1)*n+1)*n/(((1<<1)
+1)<<1));return 1-1;}
 
Reply With Quote
 
Antoninus Twink
Guest
Posts: n/a
 
      01-10-2010
On 10 Jan 2010 at 7:05, wahid wrote:
> • Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> • S = 12 + 22 + 32+….. + n2


#include <stdio.h>
#include <limits.h>

int main(void)
{
int d, rv = 0;
fputs("Enter a Number: ", stdout);
fflush(stdout);
if(scanf("%d", &d) == 1 && d > 0) {
if((7. + 5 * d) * d > ULLONG_MAX) {
fputs("Integer overflow\n", stderr);
rv = 1;
} else
printf("12 + 22 + ... + %d2 = %llu\n", d, (7ULL + 5 * d) * d);
}
else {
fputs("Invalid input: needed a positive integer\n", stderr);
rv = 1;
}
return rv;
}

 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      01-10-2010
On 1/10/2010 2:05 AM, wahid wrote:
> • Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> • S = 12 + 22 + 32+….. + n2


Sounds like a bad idea. If the program takes an integer
from the user each time it is run, how can the user get the
integer back again? Think of how inconvenient it would be if
you gave away 3, say, and could never use it again: You could
never again sing "Three Blind Mice" or listen to the Threepenny
Opera or celebrate Epiphany, or ride in a train powered by an
electrified third rail. The Holy Trinity would reject you, and
the entire month of March would be lost to you forever!

You could, I guess, select an "unlikely" integer as the
one to give away, but it seems awfully hard to choose one that
you're certain you'll never need again. The very fact that
you chose it once indicates that it is far more likely to crop
up than almost all other integers. Also, if you give the
integer to an early version of the program, discover that the
program has a bug, and fix it, how will you test the fix? You
no longer have the integer that caused the misbehavior, and
can thus not be sure you've actually fixed the problem.

Wahid, I think you should go to your teacher and point out
these serious drawbacks. Tell him or her that the assignment
threatens those who complete it with a sort of progressive
innumeracy by depriving them of another integer each time they
run the code. Tell him or her, in short, that he or she is
either a sadist or a fool, and ask for a substitute assignment.
No, not "ask," but "demand:" it's your right as a diligent
student.

--
Eric Sosman
lid
 
Reply With Quote
 
Kenny McCormack
Guest
Posts: n/a
 
      01-10-2010
In article <>,
Keith Thompson <kst-> wrote:
>wahid <> writes:
>> • Write a program that will take an integer
>> number n input from the user, and then
>> output the value of the sum of the series
>> • S = 12 + 22 + 32+….. + n2

>
>Go away and do your own damned homework.


Temper, temper, my good man!

Where the Kiki we all know and love, who is so eager to "help" people?

That is your reason for being here, isn't it?
(As you've said in the past, when I've asked you directly why you are here)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Can Groovy be used in an applet and/or can it generate the Java bytecodes that then can be used in an applet? Casey Hawthorne Java 1 03-18-2009 12:56 AM
Word Docs Won't Open, Can't Be E-Mailed, Can't Be Deleted, Can't Be Copied, Etc. Martin Computer Support 16 02-24-2009 07:35 PM
Wireless can get internet but can't see network -- can when wired 02befree Computer Support 0 12-24-2007 09:10 PM
SOLVED - can't open file in windows media player / WMP. But can in VLC - video LAN .. Now can in WMP jameshanley39@yahoo.co.uk Computer Information 2 09-19-2007 02:53 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57