answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

void main()

{

int i;

for(i=1;i<=50;i+=2)

{

printf("\t %d", i);

}

getch();

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

How do you write a C program to find out perfect numbers from 1 and 50?

To find perfect numbers between 1 and 50 in a C program, you can iterate through each number in that range and check if it is equal to the sum of its proper divisors. A perfect number is defined as a number that is equal to the sum of its positive divisors, excluding itself. Here's a basic outline of the program: #include &lt;stdio.h&gt; int main() { for (int num = 1; num &lt;= 50; num++) { int sum = 0; for (int i = 1; i &lt;= num / 2; i++) { if (num % i == 0) sum += i; } if (sum == num) printf(&quot;%d is a perfect number\n&quot;, num); } return 0; } This code checks each number from 1 to 50 and prints out the perfect numbers found in that range.


Write a c or c plus plus program to print first 50 odd numbers using do while loop?

unsigned count = 0;unsigned num=1; do { std::cout &lt;&lt; num &lt;&lt; std::endl; num +=2; } while (++count&lt;50);


Write a recursive function to find sum of even numbers from 2 to 50 using C?

I can't imagine a useful reason to have a recursive function to find this, but here you go: int sumEvens(int start, int end) { // end condition if (start &gt; end) { return 0; } // correction if we start on an odd number if (start % 2 == 1) { return sumEvens(start + 1, end); } // actual work return start + sumEvens(start + 2, end); } Invoke with sumEvens(2, 50) to get the sum of all even numbers in the range [2,50]


How many files are created for c program when execute the program?

That's entirely up to the programmer. A program could create 0 files or 50 million files (or any number in between).


Display odd number using for loop?

It is actually quite easy to write a program in java to do this. The easiest way to do this that I can think of is to use the remainder operator (%) to test whether a number is odd or not. Here is a simple program that will print out all the odd numbers between 1 and 50. public class OddNumbers { public static void main(String[] args) { int i=1; while(i &lt; 50) { if(i%2 != 0) { System.out.println(i); } i++; } } }

Related Questions

Shell program to generate the prime numbers betwee 1 to 50?

2,3,5,7,9,11,13,17,19,23,29,31,37,39,41,43,47,49


Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i &lt;= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


C program to generate numbers from 1 to 100 divisible by 2?

(rand()&amp;50+1)*2


How do you write C program to print a Series of Odd Numbers and Even Numbers.?

Generate a random number in half the range you are interested in. If generating odd values, subtract 1 from the upper bound of the range. That is, if the range is 0 to 100, then generate a random number in the range 0 to 50 for even numbers and 0 to 49 for odd numbers. Double the generated number to obtain the even value, or double it and add 1 to obtain the odd value.


What percent of these numbers are even numbers from 1-50?

Even numbers account for 50% of the numbers from 1 to 50.


Write a program to generate the first 50 perfect numbers?

I don't believe that 50 perfect numbers have ever been found, last time I checked there were only about 47 known perfect numbers. It would also require an extremely powerful computer.


Simple java program to find even numbers?

Here is a simple program that will list all the even numbers between 1 and 50: public class EvenNumbers { public static void main(String[] args) { for(int i=1; i&lt;=50; i++) { if(i%2 ==0) { System.out.println(i); } } } }


Shell program to generate prime number between 1 and 50?

There are several shell programs available for download on the Internet that will generate prime numbers. The best way to find a prime number is through calculation, however.


What is the ratio of odd numbers to even numbers?

The ratio of odd numbers to even numbers is 1 : 1 or 50-50.


Sum of first 50 even numbers?

The sum of the first 50 even numbers is 2,550.


What are the even composite numbers from 50 to80?

All even numbers between 50 and 80 are composite.


What are the even numbers of 150?

The even numbers of 150 are: 2,6,10,30,and 50