Hello friends!!!!!
Pgr to print odd numbers
C LANGUAGE
Rishendra
9/5/20241 min read
#include <stdio.h>
int main () {
int a,i,odd=0;
printf("Enter a number : ");
scanf("%d", &a);
if(a % 2 ==0) {
for(i=0 ; i<a / 2 ; i++) {
odd = 2*i+1;
printf("%5d", odd);
}
}
else {
for(i=0 ; i<=a / 2 ; i++) {
odd = 2*i+1;
printf("%5d", odd);
}
}
return 0;
}
Output :
Enter a number : 20
1 3 5 7 9 11 13 15 17 19
=== Code Execution Successful ===