#include <iostream>
using namespace std;
int main()
{
int nombre, carre ;
cout << "Introduza un numero : " ;
cin >> nombre ;
carre = nombre * nombre ;
cout << "A raiz quadrada est ; " << carre ;
}
When compiling with GCC:
gcc -Wall -Wextra -Werror -o calc_carre calc_carre.cpp
I get:
calc_carre.cpp: (. text + 0xe): undefined reference to
std::cout' calc_carre.cpp:(.text+0x13): undefined reference to
std :: basic_ostream> & std :: operator < & quot; (std :: basic_ostream > & amp ;, char const *) 'calc_carre.cpp: (. text + 0x1f): undefined reference tostd::cin' calc_carre.cpp:(.text+0x24): undefined reference to
std :: istream :: operator > (int &) ' calc_carre.cpp: (. text + 0x3a): undefined reference tostd::cout' calc_carre.cpp:(.text+0x3f): undefined reference to
std :: basic_ostream> & std :: operator < > (std :: basic_ostream > & amp ;, char const *) 'calc_carre.cpp: (. text + 0x4f): undefined reference tostd::ostream::operator<<(int)' /tmp/cclJ9vPR.o: In function
__ static_initialization_and_destruction_0 (int, int) ': calc_carre.cpp: (. text + 0x7d): undefined reference tostd::ios_base::Init::Init()' calc_carre.cpp:(.text+0x8c): undefined reference to
std :: ios_base :: Init :: ~ Init () 'collect2: error: ld returned 1 exit status
No C:
#include <stdio.h>
int main()
{
int nombre, carre ;
printf ("Introduza un numero") ;
scanf ("%d", &nombre) ;
carre = nombre * nombre ;
printf (" A sua raiz quadrada é: %d, nombre) ;
}
When I compile, I do not get any error, but see through your eyes: