Â
The Code given below can be used in TURBO C++ Compilers: -
#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include<conio.h>
void main()
{
char line1[10];
int arr[5];
fstream file;
file.open("xyz.txt", ios::in | ios::out);
cout << "Enter 5 numbers separated with space: ";
getline(cin, line1);
file << line1;
file.seekg(0, ios::beg);
for (int i = 0; i < 5; i++)
{
file >> arr[i];
cout << pow(arr[i], 2) << endl;
}
file.close();
getch();
}
//.......Coded by SAHIL SHAIKH
The Code given below can be used in gcc/g++ Compilers: -
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int main()
{
string line1;
int arr[5];
fstream file;
file.open("xyz.txt", ios::in | ios::out);
cout << "Enter 5 numbers separated with space: ";
getline(cin, line1);
file << line1;
file.seekg(0, ios::beg);
for (int i = 0; i < 5; i++)
{
file >> arr[i];
cout << pow(arr[i], 2) << endl;
}
file.close();
}
//.......Coded by SAHIL SHAIKH
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP