Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include using namespace std; int main() { int n;//to store input value //taking user input cout < >n;//reading number int sum=0;//to store sum from 1
#include
using namespace std;
int main()
{
int n;//to store input value
//taking user input
cout<<"Enter a number:";
cin>>n;//reading number
int sum=0;//to store sum from 1 to n
for(int i=1;i<=n;i++)
sum+=i;//finding sum
//printing total sum
cout<<"Total from 1 to "<
//printing total is even or odd
if(sum%2==0)
cout<<"Total is even ";
else
cout<<"Total is odd ";
//checking total is prime or not
for(int i=2;i
if(sum%i==0)//means total is not prime
{
cout<<"Total is not a prime number ";
return 0;
}
//if total is prime
cout<<"Total is a prime number ";
return 0;
}
i would i explain this in word to my professor he is asking how many fuction this code as and how did i find out if the number is even or odd
this is a C++ class language C++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started