Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt b . 4 9 .

Answered: 1 week ago