THE PROGRAMMING LANGUAGE IS C++
Part 1.Create a program that decides whether a given integer is prime or not. The program should at the end of its analysis print the number followed by prime or composite.
Part 2.Make the program from part 1 print the prime factors of any composite number entered (an additional feature to Part 1).
THE PROGRAMMING LANGUAGE IS C++
PART 1:
#include<iostream>
using namespace std;
int main()
{
int n,i,count=0;
printf("Enter a number: ");
scanf("%d",&n);
if(n==1)
{
printf("%d is neither prime or composite number.",n);
}
else
{
for(i=1;i<=n;i++)
{
if(n%i==0)
count++;
}
if(count==2)
printf("%d is prime number.",n);
else
printf("%d is composite number.",n);
}
return 0;
}
PART 2:
#include<iostream>
using namespace std;
int main()
{
int n,i,count=0;
printf("Enter a number: ");
scanf("%d",&n);
if(n==1)
{
printf("%d is neither prime or composite number.",n);
}
else
{
for(i=1;i<=n;i++)
{
if(n%i==0)
count++;
}
if(count==2)
printf("%d is prime number.",n);
else
{
printf("%d is composite number.",n); //part 2
printf("\nPrime factors are: ");
int j=2;
while(n>1)
{
while(n%j==0)
{
printf("%d ",j);
n=n/j;
}
j++;
}
}
}
return 0;
}
THE PROGRAMMING LANGUAGE IS C++ Part 1.Create a program that decides whether a given integer is...
Answer should be in C programming language Write a program that will create an array of 10 floating point numbers and take input 10 floats from keyboard. The program will print the position (index) of the maximum and minimum number among them
Using the C Programming Language: An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a function perfect that determines if parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the factors of each...
Using the programming language C, read user input of an integer, check and output whether the integer is an odd number or even number.
You are to create a program that queries the user for a range of integer values (min and max). For this range, you are to find all of the prime numbers and print them to the screen. The user is then given the option to request that all of the non-prime numbers be printed to the screen with at least one factor pair that proves that they are not prime. (Using language C)
Q2. To check and print if entered integer is prime or not. Prompt the user to enter a positive integer or 0 to exit. while negative integer entered - prompt for valid values again. If positive integer entered - check if it is prime. Write a separate function that accepts a positive integer as argument and checks and returns 1 if the integer is prime or 0 if it is not prime. Call the function from main. Accept the return...
use C++ programming language and follow the instruction carefully. thanks! Inputs: . [integer] values (10 times) Outputs: • [integer) highest value . [integer] lowest value Description: Write a program that lets the user enter 10 values. These values should be stored in an array. Your program will then find the highest and lowest values in the array. Your program will display the list of number as a comma separated list, and print which values is the highest and lowest Do...
Q1 SUMMER2020- nts python language Example Write a program to read an integer r then print a triangle with r number of rows using .asterisks Result Input 5 Hint: Use end= parameter of the print function to not add a newline to the end of the string * * * * * * * * * * * * 9 - عام python language Course Information o Course Material Assignments o example input Lab Exercises Quizzes Result 7.0 ACUTE 7.0...
Language is C programming Student ID should be 8 numbers long. create a program to read your student ID number and store it in an array. Input can not be hard wired, I have to be able to input my number Then change the first number to a letter. If the same number repeats in other parts of your student ID, you must change that number to a letter as well. print original array and modified array as your output....
Question 4: C Programming (15 points) Create a program that asks the user for an integer number representing the number of students in a classroom. Your program will then malloc an array of struct students having the same number of cells as input by the user's integer number. The student struct will have only two fields: student name and gpa. Your program then opens a CSV file
C++ Programming Use the following function to create a program that determines whether (n ^ 2 + 1) is prime for each of the primes not exceeding 1000. bool check_prime(int input) { for(int i = 2; i <= sqrt(input); ++i) { if(input % i == 0) { return false; } } return true; }