By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,730 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,730 IT Pros & Developers. It's quick & easy.

Write an algorithm to display first 10 odd numbers using for loop

P: 1
Write an algorithm to display first 10 odd numbers using for loop
Oct 30 '19 #1
Share this Question
Share on Google+
4 Replies


dev7060
Expert 100+
P: 162
Follow the posting guidelines and mention what you've done so far for this.
Oct 31 '19 #2

P: 28
hello try this using for loop

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. void main()
  5. {
  6.       int max,i;
  7.       printf("Enter value of max");
  8.       scanf("%d",&max);
  9.       printf("Odd Numbers : \n");
  10.       for(i=0;i<=max;i++)
  11.        {
  12.            if(i%2==1)
  13.              printf("%d",i);
  14.        }
  15.  
  16. }
4 Weeks Ago #3

P: 51
Set to initial value 1 and increment 2
Expand|Select|Wrap|Line Numbers
  1. for(i=1;i<=19;i+=2)
  2.  
4 Weeks Ago #4

dev7060
Expert 100+
P: 162
Reason for asking the progress is to see what they have tried so far. And that's how things work in the profesional IT environment. Nonetheless, one can easily find tons of working code snippets on the web for these basic questions.
4 Weeks Ago #5

Post your reply

Sign in to post your reply or Sign up for a free account.