How to write program to print descending order

Questions by RoshanAshsih

Showing Answers 1 - 3 of 3 Answers

Here is a program to print first n odd numbers in descending order

#include
main()
{
int i=0,j=0,n;
printf("Enter a number:");
scanf("%d",&n);
printf("The first %d odd numbers are:-
");
for(i=0;i<=n;i++)
{
if(j%2!=0)
printf("%d
"j);
j=j+1;
}
}

Bhushan

  • Apr 6th, 2015
 

Code
  1. #include

  2. main()

  3. {

  4. int i=0,j=0,n;

  5. printf("Enter a number:");

  6. scanf("%d",&n);

  7. printf("The first %d odd numbers are:-

  8. ");

  9. for(i=1;i<=n;i=i+2)

  10. {

  11. printf("%d"j);

  12. }

  13. }
Code
  1. #include

  2. main()

  3. {

  4. int i,n;

  5. printf("Enter a number:");

  6. scanf("%d",&n);

  7. printf("The first %d odd numbers are:-

  8. ");

  9. for(i=1;i<=n;i=i+2)

  10. {

  11. printf("%d"i);

  12. }

  13. }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions