Let’s understand some concept.
Natural Number..
All counting number which start from 1, 2, 3, 4, 5, 6, 7, 8, 9…………………. Infinite…
Sum of Natural Number a=n/2*(n+1) if you enter number then the sum done by this formula…
Some important symbols used in code.
- () small bracket
- && use for ‘and’ use for address
- {} curly bracket
- “” double code
The sum of Natural Number by using Formula..
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int a, b=0, c;
- clrscr();
- printf(“Sum of Natural number from 1 to 100”)
- a=100;
- b=a/2*(b+1);
- printf(“%d”, b);
- getch();
- }
Inputs..
If a=100 then
Results..

The sum of Natural Number by using ‘for’ loop…
If you enter range of Natural Number then using a loop. A after increment natural Number added by this method b+=a which like a++. In loop same rule follow by Increment and adding in on container like all alphabet.
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int a, b, c=0;
- clrscr();
- printf(“Sum of naturanumber”);
- for(a=1;a<=100;a++)
- {
- c+=a;
- }
- printf(“%d”, c);
- getch();
- }
Inputs..
If a=100 then
Results..

The sum of Natural Number by using ‘while’ loop..
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int a, b=0, c;
- clrscr();
- printf(“Sum of Natural Number”);
- a=100;
- while(a<=100)
- {
- b+=a;
- a++;
- }
- printf(“%d”, b);
- getch();
- }
Inputs..
If a=100 then
Results..

The sum of Natural Number by using ‘do while’ loop…
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int a=1, b=0, c;
- clrscr();
- printf(“Sum of Natural Number”);
- do
- {
- b+=a;
- a++;
- }
- while(a<=100);
- printf(“%d”, b);
- getch():
- }
Inputs..
If a=100 then
Results..


