Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

Loops Practise

Wednesday, May 18, 2011

#include <iostream.h>
#include <conio.h>
int main ()
{
    clrscr ();
    long int last=0;
    cout <<"Enter The Number Till That You Want Sum Of Odd Numbers: ";
    cin >> last;
    long int a=0;
    long int start=1;
    for (int n=start;n<last;n++)
    {
        if (start<=1)
            a++;
        start=start+2;
        a=a+start;
        n=start;
    }
    cout <<"\n Sum Of All Odd Numbers = "<<a;
    getch();
    return 0;
}