Write a C language program to create file “odd” to store all odd numbers between 1 and n.

      

Write a C language program to create file “odd” to store all odd numbers between 1 and n.

  

Answers


KIZITO

#include

int main()
{
int i, n;

/* Input upper limit from user */
printf("Print odd numbers till: ");
scanf("%d", &n);

printf("All odd numbers from 1 to %d are: \n", n);

/* Start loop from 1 and increment it by 1 */
for(i=1; i<=n; i++)
{
/* If 'i' is odd then print it */
if(i%2!=0)
{
printf("%d\n", i);
}
}

return 0;
}
Kizito123 answered the question on April 22, 2018 at 11:41


Next: Distinguish between character constant and string constant
Previous: What is the advantage of UNION in C?

View More Computer Science Questions and Answers | Return to Questions Index


Exams With Marking Schemes

Related Questions