Write a program to print only odd numbers from 1-50 using the user defined function

//this is a program to print only odd numbers from 1-50 using the user defined function
#include<stdio.h>
#include<conio.h>
void onlyodd();
void main()
{
onlyodd();
getch();
}
void onlyodd()
{
int i;

printf("\n\nDisplaying the odd numbers from 1-50\n\n");

for(i=1;i<=50;i++)
{
if(i%2!=0)
printf(" %d ",i);
}
}

Previous
Next Post »