to print the sum of first ten numbers:-
void main()
{int i,sum;
sum=0;
while(i<=10)
sum=sum+i;
i=i+1;
}
printf("The sum is : %d",sum);
}
PRINT 2,3,5,7,11,13,17,19,23,29,31,37
You can't display ALL odd numbers because your program will be running forever, counting towards infinity. A much more useful program would be to display all odd numbers between some numbers x and y: void displayOdds(int x, int y) { // Ensure that x is an odd number if(x % 2 == 0) x++; for(; x <=y; x+=2) printf("%d\n", x); }
int sumNums(int n) { int sum = 0; while(n >= 1) { sum += (n--); } return sum; }
If you wanted to output numbers in PHP to get less than a thousand and display all those numbers you could put it in a while loop like this.
How do Iwrite a Program that prints all prime numbers from an array?
PRINT 2,3,5,7,11,13,17,19,23,29,31,37
You can't display ALL odd numbers because your program will be running forever, counting towards infinity. A much more useful program would be to display all odd numbers between some numbers x and y: void displayOdds(int x, int y) { // Ensure that x is an odd number if(x % 2 == 0) x++; for(; x <=y; x+=2) printf("%d\n", x); }
int sumNums(int n) { int sum = 0; while(n >= 1) { sum += (n--); } return sum; }
Develop an algorithm to display all prime numbers from 2 to 100. Give both the pseudocode version and the flowchart version. Convert your pseudocode into a Java program.
If you wanted to output numbers in PHP to get less than a thousand and display all those numbers you could put it in a while loop like this.
All numbers can create products.
How do Iwrite a Program that prints all prime numbers from an array?
5,050
Write a program that asks the user to enter five numbers.Use a floating point data type to hold the numbers.The program should create a file and save all five numbers to the file.
Initialise an unsigned integer to zero. As each number is input, increment the running total accordingly. When all numbers are input, display the total.
the following program will display all numbers given in the array in ascending order #include<stdio.h> void main() { int i,h,p; int numbers[10]={5,8,3,2,6,7,9,4,1,10}; for(p=0;p<=8;p=p+1) { for(i=0;i<=8;i=i+1) { if(numbers[i]>numbers[i+1]) { a=numbers[i]; numbers[i]=numbers[i+1]; numbers[i+1]=a; } } } for(i=0;i<=9;i=i+1) { printf("%d ",numbers[i]); } }
Yes