Code C++ minh họa
#include
#include
#includeint chinhPhuong(int M);
void main(){
int N=10;
int i, so;
long tong=0;clrscr();
cout<<"Nhap N= "; cin>>N;
//cout< cout<<"nhap cac cac so nguyen duong:\n";for(i=0; i cout<<"So thu "<>so;
if(chinhPhuong(so)) tong+=so;
}
cout<<"Tong cac so chinh phuong: "< getch();
}int chinhPhuong(int M){
double can=sqrt(M);
int kt=1;
if((can - floor(can)) >0) kt=0;
if(M<2) kt=0;
return kt;}
Video tham khảo gghg
https://tritue.edu.vn/tuecode/tracnghiem30/index.php/baiviet/post/view/id/6?id=6