Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   plz send logic to write given program. (http://www.velocityreviews.com/forums/t595565-plz-send-logic-to-write-given-program.html)

 pitamber kumar 03-02-2008 08:25 PM

plz send logic to write given program.

Write a program to find the number of and sum of all intergers greater
than 100 & less than 200 that are divisible by 7.

 Sjouke Burry 03-02-2008 08:30 PM

Re: plz send logic to write given program.

pitamber kumar wrote:
> Write a program to find the number of and sum of all intergers greater
> than 100 & less than 200 that are divisible by 7.

We are not supposed to do your homework.
And dont think you will ever learn anything by cheating.

 Johannes Bauer 03-02-2008 08:34 PM

Re: plz send logic to write given program.

pitamber kumar schrieb:
> Write a program to find the number of and sum of all intergers greater
> than 100 & less than 200 that are divisible by 7.

i=101; while [ \$i -lt 200 ]; do if [ \$((\$i%7)) -eq 0 ]; then echo
\$((\$i/7-14)): \$i; fi; i=\$((\$i+1)); done

You're welcome.

Kind regards,
Johannes

--
"PS: Ein Realname wäre nett. Ich selbst nutze nur keinen, weil mich die
meisten hier bereits mit Namen kennen." -- Markus Gronotte aka Makus /
Kosst Amojan / maqqusz / Mr. G / Ferdinand Simpson / Quartillia
Rosenberg in dse <45608268\$0\$5719\$9b4e6d93@newsspool3.arcor-online.net>

 Amandil 03-02-2008 08:36 PM

Re: plz send logic to write given program.

On Mar 2, 3:25 pm, pitamber kumar <pitambern...@gmail.com> wrote:
> Write a program to find the number of and sum of all intergers greater
> than 100 & less than 200 that are divisible by 7.

Ok, I wrote it. Now you write one yourself, post it, and I'll see how
they compare.

In general, do not post homework questions. If you want to hide the
fact that it's a homework problem, show us what you have done, and

Hint: Use a loop to run through the numbers from 100 to 200. Check
each number if it's divisible by 7: If it is, add it to a running
total.

-- Marty

 Keith Thompson 03-02-2008 08:38 PM

Re: plz send logic to write given program.

pitamber kumar <pitambernitk@gmail.com> writes:
> Write a program to find the number of and sum of all intergers greater
> than 100 & less than 200 that are divisible by 7.

Done.

(No, we will not do your homework for you.)

--
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

 Kenny McCormack 03-02-2008 08:42 PM

Re: plz send logic to write given program.

In article <87ve44zwse.fsf@kvetch.smov.org>,
Keith Thompson <kst-u@mib.org> wrote:
>pitamber kumar <pitambernitk@gmail.com> writes:
>> Write a program to find the number of and sum of all intergers greater
>> than 100 & less than 200 that are divisible by 7.

>
>Done.
>
>
>(No, we will not do your homework for you.)

Actually, you just did. You just haven't published your results.

 osmium 03-02-2008 08:48 PM

Re: plz send logic to write given program.

"pitamber kumar" writes:

> Write a program to find the number of and sum of all intergers greater
> than 100 & less than 200 that are divisible by 7.

Look at the modulo operator. Perversely, this is represented by '%'.

 Ioannis Vranos 03-02-2008 08:50 PM

Re: plz send logic to write given program.

pitamber kumar wrote:
> Write a program to find the number of and sum of all intergers greater
> than 100 & less than 200 that are divisible by 7.

Why?

 santosh 03-02-2008 09:06 PM

Re: plz send logic to write given program.

pitamber kumar wrote:

> Write a program to find the number of and sum of all intergers greater
> than 100 & less than 200 that are divisible by 7.

This is trivially easy. Show us your effort and you'll likely get good
help. But we don't do homework on demand.

 Eric Sosman 03-02-2008 09:18 PM

Re: plz send logic to write given program.

pitamber kumar wrote:
> Write a program to find the number of and sum of all intergers greater
> than 100 & less than 200 that are divisible by 7.

Here you go. Invoke it exactly as described in the
"Usage" message, or it may misbehave.

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main(int l,char**s){static const short o[]={23,4,5,-2,-5,-11,14,
9,-5,1,-6,};int n,m;if(l!=2){fprintf(stderr,"Usage:\n\t%s \"Do your"
" own homework next time, vile cheater!\"\n",*s);return EXIT_FAILURE;
}for(m=n=puts(*++s)<0;m<(int)sizeof o;m+=sizeof(short)){n+=o[m/sizeof
(short)];putchar(toupper((unsigned char)(n[*s])));}puts("");return 0;}
--
Eric Sosman
esosman@ieee-dot-org.invalid

All times are GMT. The time now is 02:19 PM.