Write a C++ program that reads N positive integer numbers from the keyboard, calculates and displays the
following information.
a. Count of all numbers which are greater than 1 and less than 11. If no such numbers are entered, 0 for the
count value should be displayed.
b. Count of all prime numbers. The prime numbers are numbers which are divisible by 1 and itself. If no
prime numbers are entered, 0 for the count value should be displayed.
c. Average of all prime numbers which are greater than 5. If no prime numbers greater than 5 are entered, 0
for the average value should be displayed.
d. Largest number of all numbers entered from the keyboard.
e. Ascending order of two smallest numbers entered from the keyboard.
f. Value of A [where A =3.14*Rad*Rad; Rad – average of all numbers entered from the keyboard].
N is a constant and its value is 8.
number. Assume N=3, if the largest digit of your student id number is less than 3.
The program should contain only a main function. User defined functions and arrays should not be used. classes and linked lists should not be used.
vbkumar
0
Newbie Poster
Recommended Answers
Jump to Post>>how to write this program
Take a pen, write it. Sorry to be rude. But please show some effort from your side. Its not fair on your part to just post a question like that and expect answers to show up.
Paste whatever code you have written, or …
Jump to PostOkay, I did it. Now it's your turn.
You need to make an attempt before someone can help you with your code.
EDIT: beaten by myk, but you get the idea.
Jump to PostThat's much better :)
Well, a few things:
1) To test for prime, i feel this would be a better method:
for (i = 2 to n / 2) { if (num % i == 0) then not prime }
2) The return type of …
All 12 Replies
myk45
48
Posting Whiz
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
vbkumar
0
Newbie Poster
vbkumar
0
Newbie Poster
vbkumar
0
Newbie Poster
myk45
48
Posting Whiz
vbkumar
0
Newbie Poster
vbkumar
0
Newbie Poster
vbkumar
0
Newbie Poster
myk45
48
Posting Whiz
myk45
48
Posting Whiz
vbkumar
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.