To compute this sum, we can use a nifty algebraic approach:
Let S be the sum, so:
S = 3 + 6 + 9 + 12 + ... + 996 + 999
We can also write S as:
S = 999 + 996 + ... + 12 + 9 + 6 + 3
Adding these two equations together we get:
2S = 1002 + 1002 + ... + 1002 + 1002
Where there are 333 1002's in the above equation.
This leads us to:
2S = 1002 * 333
S = 501 * 333 = 166,833.
#include<stdio.h> #include<conio.h> void main() { clrscr(); for (int i=1;i<=100;i++) { if(i%2 !=0 && i%3 !=0) { printf("\n Numbers that are not divisible by 2 or 3:%d \n ",i); } printf("\n"); } getch(); }
The numbers divisible by all five numbers must be multiples of the LCM (LCD) of the numbers, which is 22 x 3 x 5 = 60. There are 5 numbers: 240, 300, 360, 420, and 480. --- There is also a C program that can be used to find these: #include <stdio.h> void main() { for (int i=200;i<=500;++i) if (!((i%6)(i%4)(i%5)(i%3)(i%2))) printf("%d ",i); printf("\n"); }
include<stdio.h> #include<conio.h> main() { int i; /* looping variable */ for(i=1;i<=100;i++) /* goes from 1 to 100 */ { if((i % 2 == 0) && (i % 3 != 0) && (i % 5 != 0)) /* checks all three conditions */ { printf("%d ",i); /* note the space after 'd' */ } } printf("\nEnd of Program"); /* End */ getch(); }
#include<stdio.h> #include<conio.h> void main() { int i,c,n; printf("Enter the number of terms you want which are divisible by 7"); scanf("%d",&n); c=0; for(i=7;;i+=7) { printf("\n %d ",i); c++; if(c==n) break; } getch(); }
Write a program which takes any number of days from the user. the program should display the number of years, number of months formed by these days as well as the remaining days.
PRINT 2,3,5,7,11,13,17,19,23,29,31,37
This isn't a question!
JAVA
To write a C++ program to display the student details using class and array of object.
$n = 10*(1+10)/2;
By learning how to program on C+.
(rand()&50+1)*2
/* a number divisible by x should be a multiple of x */ int i, n,x; scanf ("%d", &n); scanf ("%d",&x); for(i=x;i =< n;i+=x) { printf ("%d", x); }
nr\m;laeoh9y0m g.qthnedxc In fortran: do i=1,5 write(6,*)i enddo stop end This program will write the numbers 1 to 5 on the screen.
you do this 10 print "0112358132134" use the whole of the thing
To create a program that asks the user to enter four numbers and then displays the sum and average, you can follow these steps: First, prompt the user to input four numbers and store them in variables. Next, calculate the sum by adding these numbers together. Finally, compute the average by dividing the sum by four, and then display both the sum and the average to the user. Here's a simple example in Python: numbers = [float(input("Enter number {}: ".format(i+1))) for i in range(4)] total = sum(numbers) average = total / 4 print("Sum:", total, "Average:", average)
Identification division. Program-id. Quadratic. Environment division. Data division. Working-storage section. 01 a pic 9(3) value 0. 01 b pic 9(3) value 0. 01 c pic 9(3) value 0. 01 d pic 9(3) value 0. 01 e pic 9(3) value 0. 01 f pic 9(3) value 0. 01 g pic 9(3) value 0. 01 h pic 9(3) value 0. 01 x1 pic 9(3) value 0. 01 x pic z(3).z(2) value 0. 01 x2 pic 9(3) value 0. 01 y pic z(3).z(2) value 0. Procedure division. Display "Written by Martin O. Egua, but not complete". Display "Quadratic equation solver for three values a, b & c" Display "Enter a number: " Accept a. Display "Enter the second number: " Accept b. Display "Enter the last number: " Accept c. compute d = (b * b) compute e = 4 * a * c compute f = 2 * a compute g = d - e compute h = function sqrt (g). compute x1 = (-b) + h compute x = x1 / f Display "X = " x compute x2 = (-b) - h compute y = x2 / f Display "Y = " y Display "Send the accurate program". Stop run.