Question

Write a C program that … reads one unsigned long int value  N  from standard input...

Write a C program that …

  • reads one unsigned long int value  N  from standard input
    • assume that the value of  N  that is entered by the user is greater than  1 
  • prints (to standard output) …
    • the greatest prime number that divides of  N 
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int main()
{
long int N,out,i,j,f;
scanf("%ld",&N);
for(i=1;i<=N;i++)
{
f=0;
for(j=1; j<=N; j++)
{
if(i%j==0)
f++;
}
if(f==2)
{
if(N%i==0)
out=i;
}
}
printf("%ld",out);

return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a C program that … reads one unsigned long int value  N  from standard input...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program that … reads (from standard input) five words, with each of the...

    Write a C program that … reads (from standard input) five words, with each of the words being entered on a separate line prints (to standard output) the words in reverse alphabetical order Hints http://www.cplusplus.com/reference/cstring/strcmp

  • Write a C program that … reads a sequence of one or more double values from...

    Write a C program that … reads a sequence of one or more double values from standard input, one-after-another stops reading double values as soon as a negative value is entered then prints (to standard output & with precision 2) … the average of the positive values that were entered

  • Use C programming Make sure everything works well only upload Write a program that takes an...

    Use C programming Make sure everything works well only upload Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2:\n". If the user's input is less...

  • python language Primes Write a program primes.py that reads a positive integer from standard input, and...

    python language Primes Write a program primes.py that reads a positive integer from standard input, and determines whether or not the number is prime A prime number is a positive integer that is greater than 1, an e can be divided exactly (without leaving a rerm or itself 1 $ python3 primes. py 2 one positive integer please: 21 3 21 is not prime! 5 S python3 primes. py 6 one positive integer please 7 23 is prime

  • Write a C program named space_to_line.c that features a while loop that continuously reads input from...

    Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...

  • Write a Python program that reads user input from the command-line. The program should define a...

    Write a Python program that reads user input from the command-line. The program should define a function read Position, which reads the values for t, v0, and h0. If there is an IndexError, print 'Please provide the values for t, vO, and hO on the command line.'. If t, v0, or h0 are less than 0. print 't = # is not possible.' for each variable respectively. Note that the # represents the number entered on the command-line by the...

  • Write a fragment of code that reads in a header value from the standard input and...

    Write a fragment of code that reads in a header value from the standard input and then reads in that many integers (also from standard input) and prints their sum to standard output (for loops, header values, accumulators, basic arithmetic). Declare any variables you use. part b Objects of the Calculator class require no additional information when created. Define an object named calc, of type Calculator.

  • Create a function, void allocate_mem(unsigned int** input_one, unsigned int** input_two, unsigned long int** output, int num_ints)...

    Create a function, void allocate_mem(unsigned int** input_one, unsigned int** input_two, unsigned long int** output, int num_ints) in C. This function allocates enough memory to the three arrays to store num_ints elements each. This function should exit with EXIT_FAILURE if the program fails to allocate the memory. input parameters: unsigned int* input_one unsigned int* input_two unsigned long int* output int num_ints return parameters: none Do NOT hard code the size of the unsigned (long) integer arrays

  • 1) Write a C program that reads a hexadecimal value from the keyboard and then stores...

    1) Write a C program that reads a hexadecimal value from the keyboard and then stores the value into an unsigned char variable. Read two int values p and n from the keyboard, where the values are less than 8. Implement the following commands: S – sets the n bits starting at position p to 11..1 R – resets the n bits starting at position p to 00…0 F – flips the n bits starting at position p to their...

  • c program that counts the number of characters, words and lines from standard input until EOF....

    c program that counts the number of characters, words and lines from standard input until EOF. attached is what i Have so far but its not working ?. about shell redirection Requirements 1. Write a C program that counts the number of characters, words and lines read from standard Input until EOF Is reached. 2. Assume the Input is ASCII text of any length. 3. Every byte read from stdin counts as a character except EOF 4. Words are defined...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT