How to write a Cprogram to print all the prime numbers between 1and n where n is the value supplied by the users.

Answers

Answer 1

Answer:

#include <stdio.h>

int main()

{

   int i, j, n, prime;

   printf("Enter till where we want to find prime number: ");

   scanf("%d", &n);

   for(i=2; i<=n; i++)

   {

       prime = 1;  

       for(j=2; j<=i/2; j++)

       {

         

           if(i%j==0)

           {

               prime = 0;

               break;

           }

       }

       if(prime==1)

       {

           printf("%d, ", i);

       }

   }

   return 0;

Explanation:

A number  which is divisible by 1 and itself is called prime number. Here in the program we start by taking number from 1 to n , where n is the last number till which we are required to find prime numbers. Then we start the loop by taking two for loops one for running the numbers from 1 to n and the inner for loop to check whether the number is divisible other than 1 and itself. We take the current number as prime =1. If the number is still not divisible by number other than 1 and itself we consider that number to be prime and print it.


Related Questions

Those firms must make some drastic changes quickly toavoid further demise and

possible liquidation that fall in__________ of grand strategymatrix

a. Qurdant-1

b. Qurdant-2

c. Qurdant-3

d. Qurdant-4

Answers

Answer:

c. Qurdant-3

Explanation:

Those firms must make some drastic changes quickly toavoid further demise and  possible liquidation that fall in Qurdant-3 of grand strategymatrix .

What are the applicationsof Assembly Language where any high level language becomesinsufficient".

Answers

Answer and Explanation:

Assembly language is a low- level code or language used for initialization and system testing. It makes use of an assembler to convert codes and instructions in assembly language to executable machine language code.

It can be used for video processingIt can ease the accessibility of specific processor instructionsCritical Issues with performance can be addressed with the use of assembly languageIt is generally used for direct manipulation of the hardware.it can help in optimization of task and helps to run our program faster if the program is stilted or constrained in memory as it is the most primitive language computer can use.If a program is  platform specific then itis better to use assembly language for better output.It can be used in real time systems, low level embedded systems, etc

______________ Gives the Mean time for which systemremained available for use.

a) MTTF

b) MTBF

c) MTTR

d) MTTD

Answers

Answer: d)MTTD

Explanation: MTTD(Mean Time To Detect) is the time for the discovery of the  problem in a system.  It is basically the average time until the problem is noticed by someone. For e.g.- if there is a problem in a computer system at 9:00 am and the problem is noticed at 9:10 am by then user then the MTTD is  10 minutes . So, MTTD gives the mean time for which the system remains available for use.

Cite at least three medical technologies that make our lives better?

Answers

Answer:

 Three medical technologies that makes our lives better are:

In today's world technology boots innovation, stethoscope is coming to our smart phones as we can download it in our smartphones and it provide the analog and digital sound and can transmit it to bluetooth to cloud and doctor can store the data into the patient’s health checkup record. It is cost effective.   Artificial organs used for replacement to relieve human being from pain as it makes life easier and improve one's health status. Robotic surgery is also used to helps to aid in flexibility and control various health issues.

what is the online shopping?explian abstract of online shoopimg?

Answers

Answer:

Online shopping is the process where costumers buy online goods and products over the internet from the sellers. The basic concept is that it is a e-commerce which runs partially over the internet.  It has grown in popularity over the years because people find it easy to bargain shop and convenient.

Abstract of online shopping :  

The main objective of the online shopping is that easy to use and make it  interactive. It is a web based application for online retailers and users can  view the each product and its complete specifications. It is a user friendly application which also provides drag and drop features so that user can easily add the product to the shopping cart and user can also go online and make changes in the order.

If a compiler detects a violation of language rules, it refuses to translate the class to ____.

a.
machine code

b.
a logic error

c.
an application

d.
Java

Answers

Answer:

The correct answer is a. Machine code

Explanation:

The syntax of a language is a set of rules that indicates how to write programs.

A compiler is a system that in most cases has to handle an incorrect entry. Especially in the early stages of creating a program.

Syntactic errors are those that occur at the time of writing the program in the high level programming language and that do not comply with the grammatical rules of said programming language. These errors are generally detected by the compiler itself, since it only translates programs that are ''well written''. Therefore, a program that contains syntactic errors can never be compiled.

In summary, syntax errors are detected in the process of translating source code into binary code. On the contrary that happens with the errors of execution and of logic, that can only be detected when the program in being executed.

Answer:

a. machine code

Explanation:

When we code a program, be it in C, C++, Java, etc,..., the role of the compiler is to translate our code to machine code, so it can be executed.

This only happens if we do not violate any of the language rules. Otherwise, there are going to be compilation errors and we will have to fix our code before it is compiled, that is, translated to machine code.

So the correct answer is:

a. machine code

Write a function that accepts an argument for a persons name. The method should loop through the number of characters in the name sending each character to the screen each on a separate line.



#include

#include

using namespace std;

int main()

{

Plese fill in.....thanks

Answers

Answer:

#include <iostream>

#include<string.h>

using namespace std;

void printCharacter(string name){

   for(int i=0;name[i]!='\0';i++){

       cout<<name[i]<<endl;

   }

}

int main()

{

   string name;

   cout<<"enter the name: ";

   cin>>name;

   printCharacter(name);

}

Explanation:

first include the two libraries iostream for input/output and string library for using the string.

then, create the main function and declare the variable type string.

cout instruction is used o display the message on the screen.

cin is used to store the value in the name variable.

after that, call the function. The program control move to the the function. In the function for loop is used to print the character one by one until end of the name.

The algorithm ____ is used to find the elements in one range of elements that do not appear in another range of elements.

A.
set_union

B.
set_difference

C.
set_join

Answers

Answer:

A. set_union

Explanation:

The algorithm set_union is used to find the elements in one range of elements that do not appear in another range of elements.

The true or false questions.

The command: find . -type f -mtime +10 will search in the current directory and its subdirectories for all regular files that have not been modified in more than 10 minutes.

Answers

Answer:

False

Explanation:

The command find . -type f -mtime +10  will search for all files in the current directory and its subdirectories which have not been modified in more than 10 days.

-type argument specifies the type of entity to be searched which in this case corresponds to f (or file).

-mtime argument specifies the last modified time check for the files in terms of number of days and not number of minutes.

Create a program to determine the largest number out of 15 numbers entered (numbers entered one at a time). This should be done in a function using this prototype:


double larger (double x, double y);

Answers

Answer:

Output:-

Enter number:  

2

Enter number:  

1

Enter number:  

4

Enter number:  

3

Enter number:  

5

Enter number:  

7

Enter number:  

6

Enter number:  

8

Enter number:  

9

Enter number:  

11

Enter number:  

10

Enter number:  

12

Enter number:  

14

Enter number:  

13

Enter number:  

15

Largest number: 15.0

Explanation:

Below is a java program to determine the largest number out of 15 numbers entered: -

import java.util.Scanner;

public class Largest {

double larger(double x,double y){

 if(x>y)

  return x;

 else  

  return y;

}

double findLargest(){

 double y;

 double greatest=0.0;

 Scanner s=new Scanner(System.in);

 for(int i=0;i<15;i++){

  System.out.println("Enter number: ");

  y=s.nextDouble();

  greatest=larger(greatest,y);

 }

 return greatest;

}

public static void main(String[] args){

 Largest l=new Largest();

 System.out.println("Largest number: "+l.findLargest());

}

}

A major advantage of a method is that it is easily reusable. What does it mean to reuse a method and what are the advantages of doing so?

Answers

Answer: To reuse a method means to use a code which has been done or prepared already and just we need to change some of the functionalities.

This helps a great deal of saving time as well as helps in making the code manageable.

Explanation:

This has been practiced since long that methods can be reused. for example we need to build a calculator in c. then we can simply reuse the same method  just we need to change the sign of the operator. So in this process we can speed up our operations and work and also can make the code easy to understand and manage it when we have have to deal with large lines of code.

Final answer:

Reusing a method in programming allows for using the same code in multiple places efficiently and consistently, saving time and reducing the potential for errors. It's the easiest and least disruptive way to add functionality to programs and aligns with sustainable practices.

Explanation:

Reusing a method in programming means employing a piece of code that has already been written to perform a function or a task in multiple places throughout your application. This is akin to creating a tool that can be used repeatedly in different contexts without the need to rewrite the code each time.

Advantages of Reusing Methods:

Efficiency: Reusing methods is a quick and easier way to add functionality to your programs without rewriting code, saving time and effort.Consistency: It contributes to a more robust and error-free program as the method has been tested and debugged once, ensuring consistency across its applications.Implementing reusable methods is often the easiest and least disruptive way to enhance a program, aligning with the Process Reaction Method which emphasizes simplicity and minimal interruption.

Well-designed functions and methods enhance the maintainability and scalability of software by allowing the same logic to be utilized in different parts of an application or even in different projects entirely. This reusability can lead to economic and environmental benefits, as it aligns with the principles of reduce, reusable, and recycle.

True / False
The meaning of bit patterns is determined by the way the HW and SW treat them.

Answers

Answer: True

Explanation:

 The meaning of bit pattern are determined by the hardware and software treat them as, different types of computer used different pattern of bit for the instruction because they all are potentially different so the bit pattern are determine accordingly to the function of hardware and the software of particular devices.Instruction are stored in the form of bits in the similar memory as the data. Bit pattern are used to communicate in the memory as the sequence of bits.

Which statement about images is correct? A) A virtual image cannot be formed on a screen. B) A virtual image cannot be viewed by the unaided eye. C) A virtual image cannot be photographed. D) Mirrors always produce real images.

Answers

Answer:

A) A virtual image cannot be formed on a screen.

Explanation:

A virtual image cannot be formed on a screen is correct about images.

A virtual image can be viewed by the unaided eye.

A virtual image can be photographed.

Mirrors don't always produce real images.

Final answer:

The correct statement about images is that a virtual image cannot be formed on a screen, as virtual images are created by diverging light rays. However, they can still be seen and photographed because devices like cameras and the human eye can focus these rays.

Explanation:

The correct statement about images is A) A virtual image cannot be formed on a screen. Virtual images are formed when light rays diverge in front of a mirror or behind a lens, creating an image that appears to be located behind the mirror or lens. Unlike real images, which can be projected onto a screen because they are formed by converging light rays, virtual images are not formed at a point in space where a screen can capture them. However, virtual images can be seen by the unaided eye and can also be photographed, contrary to some misconceptions. This is because cameras and eyes can focus diverging rays to form an image.

Define a class Complex for complex numbers. A complex number is a number of the form: ???? + ???? ∗???? where a and b are real and imaginary part of a complex number and i is a number that represents the quantity √−1 . Addition of two complex numbers: (???? +???????? )+(???? +????????) = (???? +????) + (???? +????)???? Subtraction of two complex numbers: (???? +????????)−(???? +????????) = (???? −????)+(???? −????)???? Create a class Complex that contains:  Two private variables real and imaginary of type double.  Define accessor and mutator functions of real and imaginary variables.  Overload the following operators "+" and "–" so that they apply correctly to the type Complex. Test your program with inputs (5+4i) and (2+2i).b

Answers

Explanation:

--!#&?&#&#(-$(-$)-"-)"(-'-)';'!'+%

What is internal recruitment ?

Answers

Answer:

The term ‘Internal Recruitment’ refers to the process of identifying and attracting candidates from a certain organization to another position within the same organization.

Instead of opening the position to the public and attracting random candidates some companies may choose to advertise the vacancy internally and only allow members of the staff to apply.

Internal recruitment also refers to a strategy mostly big corporations use to advertise their jobs internally. Due to the size of these companies, these job openings would otherwise go unnoticed by employees in other departments.

Which of these suggestions is an effective way to deal withstress?
a. Meditation
b. Exercise
c. Talking with others
d. All of the given options

Answers

Answer:

d

Explanation:

all of those are good ways to deal with stress

What are the requirement analysis for COREBANKING?

Answers

Answer:

Core Banking is the system which is defined as the backbone  of products and service that Bank offers. with the upcoming technology it becomes a value differentiator, and a wrong system selection  that may cost tremendous opportunity losses. Core banking solution are transformed in the way bank used to operate in different manner.

 The requirement analysis for CORE-BANKING is:

FunctionalityService-oriented architectureFlexibilityProgram management

What is infix, prefix and postfixexpressions in data structures?

Answers

Explanation:

Infix notation: A+B

Operators are written in-between their operands. Expression  X * ( Y + Z) / P is means: "First add Y and Z together, then multiply the result by X, then divide by P to give the final answer."

Postfix notation : A B +

Operands are written before their operators. Expression given above is equivalent to X Y Z + * P /  

Operators evaluation is always left-to-right, we will not consider brackets for the order.

Prefix notation : + A B

Operands are written after their operators. Expression given above is equivalent to / * X + Y Z P

Operators evaluation is always right-to-left,we will not consider brackets for the order.

The _________ statement causes a function to end immediately.

Answers

Answer:

return

Explanation:

return is the statement which is used to return the value from the function definition to the function calling.

it is also used as exit from the function.

for example:

int count()

{

     return 0;

     printf("hello");

}

In the above the function return 0 without print the message "hello". we can used return any where inside the function for immediately ending the execution of function.

Final answer:

The statement that causes a function to end immediately is the 'return' statement, which halts function execution and returns the flow of execution to where the function was called.

Explanation:

The statement that causes a function to end immediately in most programming languages is a return statement. When the return statement is executed, it ends the function execution and the flow of execution goes back to where the function was called, which can be likened to coming back from a 'detour'. It's important to realize that defining a function also creates a variable with the same name, which can be used to call the function later in the code.

A functional approach to programming includes various other concepts. For instance, to end the function, you have to enter an empty line in some interactive environments like REPLs (Read-Eval-Print Loop), although this is not necessary in a script. The last statement of a function plays a role similar to a 'Note of Finality' in a speech, indicating the end of the logic encapsulated by the function.

Write a program that lets the user guess the coin's head or tail. The program randomly generates an integer 0 or 1, which represents the head or the tail. The program prompts the user to enter a guess and reports whether the guess is correct or incorrect. include step by step commentary.

Answers

Answer:

#include <iostream>

#include <stdlib.h>

#include <time.h>

using namespace std;

int main()

{

   srand (time(NULL));  //initialize random seed

   int guess;

    int number = rand() % 2;  //generate random number 0 or 1

    cout<<"Enter the guess (0 or 1): ";

    cin>>guess;     //store in guess

    if(number == guess){     //check if number equal to guess

       cout<<"Guess is correct."<<endl;   //if true print correct message.

    }else{

        cout<<"Guess is incorrect."<<endl;  //otherwise print correct message.

    }

    return 0;

}

Explanation:

first include the three library iostream for input/output, stdlib,h for using the rand() function and time for using the time() function.

create the main function and initialize the random number generation seed, then generate the random number using the function rand() from 0 to 1.

after that, take input from user and then with the help of conditional statement if else check if random number is equal to guess number or not and print the appropriate message.

Open addressing can be implemented in several ways.

True

False

Answers

Answer: True

Explanation:

yes, open addressing can be implemented in several ways as it is a method of collision resolution in hash table. Open addressing can be implemented in different ways as linear probing, quadratic probing and double hashing. As open addressing requires more computation. In open addressing as everything is stored in the same table.

Give Short and to the point answers(Answer the question keeping in view itsmarks)

Why we called COBOL as a professional language and not ataught language

Answers

Answer:

COBOL(Common Business Oriented Language).As the name suggests it is most commonly used to develop business tools and hence it is called a professional language and it is not used in schools or colleges as a teaching tool like FORTAN hence it is not called a taught Language.

COBOL is also used to develop business applications.It is mainly designed for businesses.

Which of the following are primitive types?

A. Byte

B. String

C. Intege

D. Float

E. Choice (C) & (D)

Answers

Answer:

A. Byte, C. Integer, and D. Float

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

To answer this question we need to know what a primitive type actually is.

Primitive Data Types: are data entries that have a specific simple value of the kind that is entered. Examples of these are Bytes, Integers, Char, and Float.

Non Primitive types hold more than one entries with their own values. Examples of these are String, Array's, and Classes.

Therefore the answer is A. Byte, C. Integer, and D. Float

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp = {90, 92, 94, 95}, print: 90, 92, 94, 95 Your code's output should end with the last element, without a subsequent comma, space, or newline.

Answers

Answer:

#include <iostream>

using namespace std;

int main() {

   int NUM_VALS;//variable NUM_VALS for the size of the array..

   cout<<"Enter the size of the array"<<endl;

   cin>>NUM_VALS;//taking input the size of the array..

   int hourlyTemp[NUM_VALS]; //declaring array hourlyTemp of size n..

   cout<<"Enter values of the array "<<endl;

   for(int i=0;i<NUM_VALS;i++)

   cin>>hourlyTemp[i];//taking input of hourlyTemp

   for(int i=0;i<NUM_VALS;i++) //for loop for iterating over the array..

   {

       if(i!=NUM_VALS-1)

       cout<<hourlyTemp[i]<<", ";// print statement.

       else

       cout<<hourlyTemp[i];//print statement.

   }

return 0;

}

Explanation:

I have taken NUM_VALS variable for the size of the array hourlyTemp. First i am taking input the size of array form user and after that array elements are also entered by the user.I am iterating over the array using for loop and checking that it is not the last element if it is simply printing it if it is not then printing comma and space also.

What is the typical data transfer rate (in bps) over a SS7 transfer link?

Answers

Answer: 55 Kbits/sec - 64 KBits/sec

Explanation:

Signal System 7 (SS7) is used one of the protocols used for communication for mobile operators and it uses circuit switching. As it uses circuit switching it transfers data using a dedicated channel and hence more comparatively faster.  It communicates and sends signals among Service Switching (SSPs), Signal Transfer Points (STPs), and Service Control Points (SCPs) using a different path apart from the data transfer path.

The data transfer rate which is the transfer of data among the various network elements is 55 Kilo bits/sec - 64 kilo bits/sec.

How to declare a structure of a linked list?

Answers

Answer:

struct Node{

   int data;

   struct Node *next;

};

Explanation:

Linked list is the data structure which is used to store the series data but not in continuous memory location .

Linked list contain node which store the data and pointer which store the address of next node. If their is no next node, then it store the NULL.

so, the structure must declare the data and a pointer variable.

Can you comment on the advantages and disadvantages of having ARP responses implemented as broadcasts?

Answers

Answer:

The advantages of ARP implemented as broadcast is that it enables easy and faster transfer of messages in a network. The disadvantage of ARP is that many of the nodes in the network may update their ARP cache locally without forwarding it to other nodes.

Explanation:

Address resolution protocol(ARP) has both advantages and disadvantages when implemented as broadcast. Broadcast technology enables to transmit messges across all the nodes.

The advantages of ARP implemented as broadcast is that it enables easy and faster transfer of messages in a network. The disadvantage of ARP is that many of the nodes in the network may update their ARP cache locally without forwarding it to other nodes.

A binary search can be performed only on ____.

A.
ordered lists

B.
comparable lists

C.
unordered lists

Answers

A binary search can be performed only on a comparable lists

You can pin applications to which two areas?

A. Start screen

Control Panel

C. Taskbar’

D. Title bar

Answers

Answer:

A and C.

Explanation:

The taskbar and the Start are both shortcuts to use when opening applications. The taskbar is at the bottom of your computer or pc. And the start can be opened by pressing the windows key or clicking on windows at the bottom right (Windows only.)

Hope that helps!

Identify three different meanings of the word "interface" in Java Programing language.

Answers

Answer: Interface methods, interface variables and interface markers.

Explanation:

Interface methods are public and abstract by default.

Interface variables can be declared public, static and final

Marker interfaces are simply empty interfaces without any methods.

Other Questions
Oil is poured into the open side of an open-tube manometer containing mercury. What is the density of the oil if a column of mercury 5.50 cm high supports a column of oil 85.0 cm high? (The density of mercury is 13,600 kg/m) A student is solving the system of equations below. In which line is a mistake first made? 2x + y - 2z = 23 3x + 2y + z = 11 x - y + z = -2 Line 1 z = 11 + 3x + 2y Line 2 2x + y - 2(11 + 3x + 2y) = 23 Line 3 -4x - 3y = 45 Line 4 x - y + (11 + 3x + 2y) = - 2 Line 5 4x + y = - 13 Line 6 -2y = 32 Line 7 y = 16, x = , z = -11/4 PLS HELPCan you put these cats in the right order (from Largest to Smallest) according to their actual real-life size?Answers:A: DCABB: BADCC: CBADD: ADCB 17. What's mass?A. A measure of an element's attraction for electronsB. The force that gravity exerts upon an objectC. The sum of the number of protons and neutrons in an atomD. A measure of the amount of matter an object contains At what point in history did the human population reach its peak growth rate? Select one: a. 1900-1920 b. 1940-1960 c. 1965-1970 d. 1970-1985 What is the convivencia Find the equation, in standard form, of the line passing through the points (2,-3) and (4,2). Selected financial information for Feemster Company for 2012 follows. Sales $ 2,000,000 Cost of goods sold 1,400,000 Merchandise inventory Beginning of year 155,000 End of year 195,000. Required: Assuming that the merchandise inventory buildup was relatively constant, how many times did the merchandise inventory turnover during 2012? Which of the following is an acceptable IUPAC name?(A) 3,6-dimethylheptane (B) 2-ethyl-3-methylheptane (C) 5-methyl-3-ethylheptane (D) 4-ethyl-4-methylheptaneD An atom that undergoes radioactive decay and has a large nucleus most likely contains Audrey Graco plans to conduct book signings in several cities to promote her new novel. She wishes to visit Knoxville, Chattanooga, Chapel Hill, Charlotte, Raleigh, and Richmond. How many different ways can she visit each of these cities and return to her starting point in Wilmington? O A. 720 O B. 30 O C. 29 O D. 120 Click to select vour answer You obtain a loan of $7500 at 16.5% compounded monthly. If you make $300 payments monthly, what is the term of the loan? Find the size of the concluding payment if: a. the last full payment is increased to pay off the loan b. the last smaller payment is made one month after the last full payment. A child is punished and temporarily stops his or her well-established bad behavior. However, the child soon goes back to acting badly. This is probably because ________. Solve sin 0 + 1 = cos20 on the interval 0 0 < 2pi. Show work please! help me i need this please Metals often form several cations with different charges. Cerium, for example, forms Ce3+ and Ce4+ ions, and thallium forms Tl+ and Tl3+ ions. Cerium and thallium ions react as follows:2Ce4+(aq)+Tl+(aq)2Ce3+(aq)+Tl3+(aq)This reaction is very slow and is thought to occur in a single elementary step. The reaction is catalyzed by the addition of Mn2+(aq) according to the following mechanism:Ce4+(aq)+Mn2+(aq)Ce4+(aq)+Mn3+(aq)Mn4+(aq)+Tl+(aq) Ce3+(aq)+Mn3+(aq)Ce3+(aq)+Mn4+(aq)Mn2+(aq)+Tl3+(aq)Part AWhat is the rate law for the uncatalyzed reaction?rate=k[Ce4+]2[Tl+]2rate=k[Ce4+][Tl+]rate=k[Ce4+]rate=k[Tl+]rate=k[Ce4+]2[Tl+]rate=k[Ce4+][Tl+]2If the uncatalyzed reaction occurs in a single elementary step, why is it a slow reaction?Check all that apply.All reactions that occur in one step are slow.The reaction requires the collision of three particles with the correct energy and orientation.The probability of an effective three-particle collision is low.The transition state is low in energy.The catalyzed reaction is first order in [Ce4+] and first order in [Mn2+]. Which of the steps in the catalyzed mechanism is rate determining?The catalyzed reaction is first order in and first order in . Which of the steps in the catalyzed mechanism is rate determining?Ce4+(aq)+Mn2+(aq)Ce3+(aq)+Mn3+(aq)Ce4+(aq)+Mn3+(aq)Ce3+(aq)+Mn4+(aq)Mn4+(aq)+Tl+(aq)Mn2+(aq)+Tl3+(aq) Suppose you multiplied the cereal box dimensions in a different order:V = (x)(4x+3)(4x)First, (X)(4x+3) =DONE What is the x-coordinate of the vertex of the parabola whose equation is y = 3x^2 + 12x + 5? A stroke can lead to nutritional impairment because of all of the following except:Difficulty chewingDifficulty swallowingAlzheimers diseaseProblems with eating independently Which values of a,b and c represent the answer in simplest form