Generate the first 10 odd numbers in reverse order.
Answers
Answer:
/* C Program to Print Odd Numbers from 1 to N using For Loop and If */
#include<stdio.h>
int main()
{
int i, number;
printf("\n Please Enter the Maximum Limit Value : ");
scanf("%d", &number);
printf("\n Odd Numbers between 1 and %d are : \n", number);
for(i = 1; i <= number; i++)
{
if ( i % 2 != 0 )
{
printf(" %d\t", i);
}
}
return 0;
}
Explanation:
Answer:
Hey!
#include<stdio.h>
int main() {
int n, i, a;
printf("Enter a number:");
scanf("%d", &n);
printf("List in descending order:");
for (i = n - 1; i >= 0; i--) {
a = 1 + i * 2;
printf("%d ", a);
}
return 0;
}
Output:
Enter a number:10
List in descending order:19 17 15 13 11 9 7 5 3 1
Hope this helps
Have agood day!