write a program to printodd numbers between 1 to 10 using for endloop
Answers
Answered by
0
Answer:
#include <stdio.h>
int main()
{
int i, n=10;
/* 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;
}
Explanation:
you can try this one
Answered by
1
Question ?
Write a program to print odd numbers between 1-10 using for loop
Program:-
This is written in Python.
for I in range(1,10,2):
print(I, end=" ")
This is written in Java.
class x
{
public static void main()
{
for(int i=1;i<=9;i+=2)
System.out.print(i+" ");
}
}
Similar questions