in this program the user is asked to proceed or not ,if proceed it should go back to the loop and implement it if not it should exit.
C code for the sum of squares of n numbers?
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
int main()
{
int total, num;
char ans;
total=0;
ans='y';
clrscr();
while((ans=='y')||(ans=='Y'))
{
printf("Enter a number ");
scanf("%d",%26amp;num);
total+=(num*num);
printf("Do you want to continue? \n");
ans=getch();
printf("%c\n",ans);
}
printf("Total is %d",total);
getch();
return 0;
}
sundew
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment