answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

int main()

{

int a;

printf("the no from 1 to 10 are:\n");

for(a=1;a<=10;a++)

printf("%d\n", a);

getch();

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Write a program in c to print first n prime numbers? // simple program to generate first ten prime numbers

#include

#include

void main()

{

int c,i,j,n;

clrscr();

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

{

c=0;

for(j=2;j

{

if(i%j==0)

{c=c+1;

}

}

if(c==0)

printf("%d",i);

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

#include<iostream>

#include<string>

#include<sstream>

unsigned input_num (std::string prompt)

{

unsigned num = 0;

while (true)

{

std::cout << prompt << ": ";

std::string input = "";

std::getline (std::cin, input);

std::stringstream ss (input);

if (ss >> num)

break;

std::cout << "Invalid input." << std::endl;

}

return (num);

}

int main()

{

while (unsigned num = input_num ("Enter a real number (0 to exit)"))

for (unsigned multiple=1; multiple<=10; ++multiple)

std::cout << num << " * " << multiple << " = " << num * multiple << std::endl;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

puts ("2 3 5 7 11 13 17 19 23 29");

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in c to print first ten prime numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a c program to generate all prime numbers in the given range?

look man that would take alot &gt;&gt;&gt; Ill give you the way =============================================================================== this answer i write it now on net ! i read about that befor in it uni where i study i will chick out the answer and re write it best wishes 2024


What BASIC program can compute and display all prime numbers from 1 to 40?

PRINT 2,3,5,7,11,13,17,19,23,29,31,37


What is the Sum of first n natural numbers?

int sum = 0; int i; for(i = 0; i &lt; n; ++i) { sum += i; }


How do you write a program in Python to find the first n prime numbers?

One way to do this is to write a function that checks if a number is prime: def isPrime(number): for i in range(2, number): if number%i == 0: return False return True Then create variables to track how many primes have been found and a variable to track which number is being tested for being prime. Increment that variable and test it, and if it is prime print it out (or save it somewhere) and increment the variable being used to track how many primes have been found: targetPrimes = 10 #number of primes to find primesFound = 0 #number of primes found i = 1 while (primesFound &lt; targetPrimes): i += 1 #first number tested is 2 if isPrime(i): print(i) primesFound += 1


Write a c program to find out the prime numbers between 1 to 500?

Here is a simple program to generate prime numbers upto a given specific number /*Prime No. from 1 to 50*/ /*By-Himanshu Rathee*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int i,j,n; clrscr(); printf(" Enter the number upto which we have to find the prime number: "); scanf("%d",&amp;n); printf("\n"); for(i=2;i&lt;=n;i++) { for(j=2;j&lt;=i-1;j++) if(i%j==0) break; /*Number is divisble by some other number. So break out*/ if(i==j) printf("\t%d",i); /*Number was divisible by itself (that is, i was same as j)*/ } /*Continue loop upto nth number*/ getch(); }

Related questions

How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?


How do you write a program in objective c numbers 1-100 prime numbers?

fdsgfhgdfhgdf


Write a program to print first 100 alternative prime numbers?

This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.


Program for print prime all number from 1 to 100 in foxpro?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.


Write a C program to find the sum of all prime numbers?

Since there is an infinite set of prime numbers the answer would be infinity.


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


How do you write a program to print numbers to 50 except prime?

First, create a for loop from a,1 to 50. Inside of that create another for loop b,2 to a-1. If a/b=int(a/b) then you know it is not prime


How do you write a c program to get a range from user and give a list of prime numbers?

To get all tutorials of "c programming" Reference:cprogramming-bd.com/c_page2.aspx# prime number


When you write a number as a product of prime numbers?

A number as a product of prime numbers would be &quot;x&quot;.


Write down the first 6 prime numbers?

2, 3, 5, 7, 11, 13


What are the first three prime numbers?

The first three prime numbers are 2,3 and 5.