Monday 6 August 2012

Loop control structure003


Write a program to print all the odd number between one to ten (intrger) along with the sum.

#include <stdio.h>
#include <conio.h>


void main ( )
{
        int          a = 1, s = 0;
        clrscr ( );

        while ( a <= 10 )
        {                
                     printf ("\n\n %d ",a);
                     s = s + a;
                     a = a + 2;
        }
        printf ("\n\n SUM OF ODD NUMBERS = %d",s);
        getch ( );



Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...