C++

Simple “hello world” program:

#include <iostream>

using namespace std;

int main()

{

cout << " hello world /n codeandseek.com" ;

return 0;

}

 

Adding two values:

#include <iostream>

using namespace std;

int main()

{
int a , b   sum;

cout << " enter value of a = " ;

cin >> a ;

cout << " enter value of b = ";

cin b;

sum=a+b;

cout << " sum of both the number is = " << sum << endl;

return 0;

}

 

Cube root:

#include <cstdlib>
 #include <iostream>
 #include <iomanip>
 #include <cmath>
 using namespace std;
 const int size = 10;
 void square_array (double values [size]);
 void read_numbers (double values [size]);
 void print_cube_root (double values [size]);
 int main(int argc, char *argv[])
 {
 const int size = 10;
 double number;
 double values [size];
 read_numbers (values);
 square_array (values);
 print_cube_root (values);
 cout << "\n\n";
 system("PAUSE");
 return EXIT_SUCCESS;
 }
 void read_numbers (double values [size])
 {
 int index;
 cout << "Enter 10 numbers:\n";
 for (index = 0; index < size; index++)
 cin >> values [index];
 }
 void square_array (double values [size])
 {
 int index;
 cout << "\nThe square of the numbers are:\n";
 for (index = 0; index < size; index++)
 {
 values [index] = values [index] * values [index];
 cout << "\n\n";
 cout << values [index];
 }
 }
 void print_cube_root (double values [size])
 {
 int index;
 cout << "\n The cube root of the numbers are = \n";
 for (index = 0; index < size; index++)
 {
 values [index] = values [index] * values [index];
 cout << "\n\n";
 cout << values [index];

return 0;
 }
 }
Advertisements