int main()
{
printf("Enter 0 or 1 :");
scanf("%d",&i_choice);

  if ( i_choice ==0 )
  for(	;i_count_1 < i_number;)
  {-------
   ------
  }
  
  if (choice == 1)
  for(	;i <= i_number;)
  {-------
  ------
  }

Here I raed a user input ( 0 or 1)
So as per i/p I've to change the condition in my for loop.
if choice ==1 the condition must be (i <= i_number)
if choice == 0 the condition must be (i_count_1 < i_number)

I don't know how to use #define with this program.

anybody can help me....
Krish

Edited 6 Years Ago by Nick Evan: Added code-tags

Comments
I gotta find a compiler which can compile emoticons!
20+ posts, and code still looks like crap WITHOUT THE F***ING CODE TAGS!

I don't know how to use #define with this program.

Question is, why do you want to use #define in your program?

Okkk... I realize I can't use a #define here....
becoz I am getting choice inside a function...

But my code is repeating twice ...I wanna avoid that....
Except condition the other statements are same for both...

Here is my code

printf("\n U wanna find prime nos up to N(press 1)
or N prime nos (press 0 ");
scanf("%d",&i_choice);

switch(i_choice) {

case 0 :
for (i = 1, i_count = 0; i_count_1 < i_number; i++ ) {
for (j = 1,i_count = 0; j <= i ; j++) {
if ((i % j) == 0)
++i_count;
}
if (i_count <= 2) {
printf("\t %d \n",i);
i_count_1++;
}
}
break;

case 1 :
for (i = 1, i_count = 0 ; i <= i_number; i++ ) {
for (j = 1, i_count = 0; j <= i ; j++) {
if( (i % j)==0 )
++i_count;
}
if (i_count <= 2) {
printf("\t %d \n",i);
i_count_1++;
}
}
}
}

Edited 6 Years Ago by Nick Evan: For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.

This article has been dead for over six months. Start a new discussion instead.