0% found this document useful (0 votes)
8 views

c++ program 1

The document provides examples of C++ programs that calculate the squares of user-input numbers. The first program handles integer inputs, while the second program is designed for decimal (double) inputs. Both programs prompt the user for the number of inputs and display the squared results.

Uploaded by

Mircea
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

c++ program 1

The document provides examples of C++ programs that calculate the squares of user-input numbers. The first program handles integer inputs, while the second program is designed for decimal (double) inputs. Both programs prompt the user for the number of inputs and display the squared results.

Uploaded by

Mircea
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

https://www.programiz.

com/cpp-programming/online-compiler/
// Online C++ compiler to run C++ program online /aflu patratele a n numere
pe care le introduc eu
#include <iostream>

using namespace std;

int main() {

int a[250], n, i;

cout << " numar: ";

cin>>n;

for ( i=0; i <= n-1; ++i)

cin>>a[i];

for (i=0; i<=n-1; i++)

cout<<a[i]*a[i]<<' ';

Output
numar: 4 1 2 3 4 # asta introduc
1 4 9 16 # asta obtin

2) // Online C++ compiler to run C++ program online


#include <iostream>
using namespace std;
int main() {
double a[5]; # pentru numere zecimale
int n, i;
cout << " numar: ";
cin>>n;
for ( i=0; i <= n-1; ++i)
cin>>a[i];
for (i=0; i<=n-1; i++)
cout<<a[i]*a[i]<<' ';
}
Output
numar: 3 4.4 5.5 9.9 # asta introduc
19.36 30.25 98.01 # asta obtin

You might also like