I'm having a lot of troubles trying to read the input data into the program. I'm a beginner of C++ and this is my first time to learn to use functions. I wrote out the code but I only got zero. Can someone please help me out?
I have use the following input data:
104
3773
13
121
77
30751
to determine the integers if they are:
1)a multiple of 7, 11 or 13
2)sum of the digits odd or even
3)the square root value(if positive)
4)is it a prime number
and here is my code:
#include<iostream>
#include<fstream>
#include<conio.h>
#include<cmath>
using namespace std;
#define in_file "data.txt"
#define out_file "result.txt"
void multiple();
void sum();
double square(double);
void prime();
int num;
float value;
void main()
{
ifstream ins;
ofstream outs;
ins.open(in_file);
outs.open(out_file);
int num;
ins>>num;
multiple();
sum();
double square();
prime();
ins.close();
outs.close();
getch();
}
void multiple()
{
if (num%7==0 || num%11==0 || num%13==0)
cout<<num<<" is a multiple of 7, 11 or 13."<<endl;
}
void sum()
{
if (num%2==0)
cout<<num<<" is a even number."<<endl;
else
cout<<num<<" is a odd number."<<endl;
}
double square(double value)
{
double num=sqrt(value);
cout<<"The square root value is: "<<value<<endl;
return value;
}
void prime()
{
for (int i=2; i<=num; i++)
{
for (int j=2; j<i; j++)
{
if (i%j==0)
cout<<num<<" is a prime number."<<endl;
else
cout<<num<<" is not a prime number."<<endl;
}
}
}