Print all odd nos till 50


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n=1;
do
{
cout<<n<<endl;
n=n+2;
}
while(n<=50);
getch();
}
**********output***********
1
3                                                                            
5                                                                            
7                                                                            
9                                                                            
11                                                                            
13                                                                            
15                                                                            
17                                                                            
19                                                                            
21                                                                            
23                                                                            
25                                                                            
27                                                                            
29                                                                            
31
33                                                                            
35                                                                            
37                                                                            
39                                                                            
41                                                                            
43                                                                            
45                                                                            
47  

Algorithm:
1. Start
2. Set n=1
3. Write n
4. Increment n
5. Check if no<50
     if true then:
     a)Go to step 2
    if false then:
     b)go to step 5
6. Stop

                                                                        
49

0 comments:

Post a Comment