Sum of odd number between the two range number are given below….
Let’s understand some concept.
ODD Number..
Number which are not divided by 2 with 1 or 2 remainder is known as odd number.
Sum of odd Number. if you enter number then the sum done by this formula…If a=last term 100. Then n=a/2. So, x=n*n. OR if last term is odd then a={(n+1)/2}2.
Some important symbols used in code.
- () small bracket
- && use for ‘and’ use for address
- {} curly bracket
- “” double code
Sum of odd number by using formula…

- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int a, b, c, d=0, e;
- clrscr();
- printf(“Enter the number find the Sum of odd number”);
- scanf(“%d”, &a);
- if(a%2==0)
- {
- b=a/2;
- c=b*b;
- printf(“%d”, c);
- }
- else if(a%2!=0)
- {
- b=a+1;
- c=b*b;
- d=c/4;
- printf(“%d”, d);
- }
- getch();
- }

Inputs..
If a=100 then
Results..
Sum= 2500.
Sum of odd number by using ‘for’ loop..
- #include<studio.h>
- #include<conio.h>
- void main()
- {
- int a,b=0,c,d,i;
- clrscr();
- printf(“Enter the number to find out sum of odd number”);
- scanf(“%d”, &a);
- for(i=1;i<=a;i++)
- {
- if(i%2!=0)
- b+=i;
- }
- printf(“%d”, b);
- getch();
- }
Inputs..
If a=100 then
Results..
Sum= 2500
Sum of odd number by using ‘while’ loop..
- #include<studio.h>
- #include<conio.h>
- void main()
- {
- int a,b=0,c,i;
- clrscr();
- printf(“Enter the number to find out sum of odd number”);
- scanf(“%d”, &a);
- while(i<=a)
- {
- if(i%2!=0)
- b+=i;
- i++;
- }
- printf(“%d”, b);
- getch();
- }
Inputs..
If a=100 then
Results..
Sum= 2500
Sum of odd number by using ‘ do while’ loop..
- #include<studio.h>
- #include<conio.h>
- void main()
- {
- int a,b=0,c,i;
- clrscr();
- printf(“Enter the number to find out sum of odd number”);
- scanf(“%d”, &a);
- {
- do
- {
- if(i%2!=0)
- b+=i;
- i++;
- }
- while(i<=a);
- printf(“%d”, b);
- getch();
- }
Inputs..
If a=100 then
Results..
Sum= 2500
Sum of odd number between two range number by using ‘for’ loop..
- #include<studio.h>
- #include<conio.h>
- void main()
- {
- int a,b,c=0,d,i;
- clrscr();
- printf(“Enter the number to find out sum of odd number”);
- scanf(“%d%d”, &a, &b);
- for(i=a;i<=b;i++)
- {
- if(i%2!=0)
- c+=i;
- }
- printf(“%d”, c);
- getch();
- }
Inputs..
If a=10, b=100 then
Results..
Sum= 2475..
Sum of odd number between two range number by using ‘while’ loop..
- #include<studio.h>
- #include<conio.h>
- void main()
- {
- int a,b,c=0,i;
- clrscr();
- printf(“Enter the number to find out sum of odd number”);
- scanf(“%d&d”,&a, &b);
- i=a;
- while(i<=b)
- {
- if(i%2!=0)
- c+=i;
- i++;
- }
- printf(“%d”, c);
- getch();
- }
Inputs..
If a=10, b=100 then
Results..
Sum= 2475..
Sum of odd number between two range number by using ‘do while’ loop..
- #include<studio.h>
- #include<conio.h>
- void main()
- {
- int a,b,c=0,i;
- clrscr();
- printf(“Enter the number to find out sum of odd number”);
- scanf(“%d&d”,&a, &b);
- i=a;
- do
- {
- if(i%2!=0)
- c+=i;
- i++;
- }
- while(i<=b);
- printf(“%d”, c);
- getch();
- }
Inputs..
If a=10, b=100 then
Results..
Sum= 2475..

