HI
i got stuck in this program
please help me and provide me the source code,..
I normally don't do it, but here's a solution:
#include <stdio.h>
int main() {
printf("1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49 53 55 59 61 65 67 71 73 77 79 83 85 89 91 95 97 ");
return 0;
}
#include <stdio.h>
int main( void ) {
printf("1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49 53 55 59 61 65 67 71 73 77 79 83 85 89 91 95 97 ");
fflush( stdout );
return 0;
}
... Fair enough.
printf("integers not divisible by 2 and 3 between 1 and 100");
Output buffers are flushed on program exit anyway...
...and main( void )
is a C99 monstrosity.
Umm, considering that this is a C forum, what would you recommend in its place?
Umm, when did I mention other languages?
Perhaps I just agree with Ritchie and Stroustrup that main(void) is awful. That's my opinion, however.
My post was motivated on this: since int main()
int main(void)
are considered more-or-less equivalent (from our perspective, because they are most definitely not equivalent in actuality), and not all C compilers can trip through the second easily, why bother correcting correct code?
hey_shishir, sorry you've had to put-up with this. However, the forum announcements make it quite clear that we won't do your homework for you. You are plenty bright enough to think about how to test a number to see whether or not it is divisible by 3. Give it your best shot, and if it still doesn't work right, post back here with what you have got and we'll help you fix it.
why bother correcting correct code?
How can something correct be corrected? ( Rhetoric question )
Regardless, there was not correction to twomers posted code, but rather an add-on or extension to the sarcasm intended. Thus the green highlights.
e.g.
You are plenty bright enough
How bright where you thinking? Bright as a 20 watts bulb or as a 60 watts one. ( No an actual question, but rather a sarcasm )
Ahhh.... :D
>> How can something correct be corrected? ( Rhetoric question )
"Try again. Fail again. Fail better"
>> How can something correct be corrected? ( Rhetoric question )
"Try again. Fail again. Fail better"
There was a reason why rhetoric question was specifically written within parenthesis.
>> There was a reason why rhetoric question was specifically written within parenthesis.
Same reason as void :D I got the joke, by the way.
I merely thought the quote correlated to the situation. Anyways, I don't think the OP's coming back. Been fun posting in this thread!
nice discussion........
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
printf("the numbers not divisible by 2 and 3 is");
for(i=0;i<100;i++)
{
if((i%2)!=0&&(i%3)!=0)
{
printf("%d",i);
}
}
getch();
}
this coding will definately help u to get the needed answer
- void main
is bad, very bad. Find out why.
- getch()
is nonstandard and nonportable. Use getchar()
instead, and then you can get rid of the conio.h header file.
- Use CODE tags when posting code.
- Don't post complete solutions to homework.
If one number divisible by 2 and 3, it is also divisible by 6.
for(i = 1; i <= 100; i++) {
if (i % 6)
// this condition is true whenever i is not divisible by number 2 and 3.
}
Yes, but not all numbers divisible by two or three are divisible by six.
Yes, but the topic say divisible by 2 and 3.
Well, seeing as we've lost the OP anyway, I hope you are laughing and not suggesting you have a firmer grasp of English grammar than I...
Because if you are just laughing you know already that the word "and" is only used to conjoin similar clauses and does not have any effect upon the exact, technical relationship (if any) between those clauses...
But again, seeing as this thread has permanently disintegrated into silly answers, I accept your joke.
//this is it
int main
int main()
{int a,count;
a=1; count=0;
for (a=1;a<100;a=a+1)
{
if(a%2!=0&&a%3!=0)
{count=count+1; printf("\n%d",a);};
}
printf("\n\n the answer is here = %d",count);
return 0;
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.