DO NOT MISS

Ads

Sunday 31 July 2016

Program 15 Using While loop


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

void main()

       {

             int a,i,sum=0;
             clrscr();

             printf("enter a range:");
             scanf("%d",&a);

             i=1;
           
 while(i<=a)
                         {
                                sum=sum+i*i;
                                i++;
                         }

             printf("the sum of the Squre natural no is:=%d\n",sum);

             getch();

        }

Output:-


Explanation:-
The Number is :4 (1 + 2 + 3 + 4)
 Square of (1*1+2*2+3*3+4*4) = 1 +++ 16 =30.
______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________



Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims