#include<stdio.h>
#include<conio.h>
void factor(int num)
{
int i,sum=0;
for(i=1;i<num;i++)
{
if(num%i==0)
{
sum=sum+i;
}
}
printf("Sum of the factor of %d is %d",num,sum);
}
void main()
{ int num;
printf("Enter the number=");
scanf("%d",&num);
factor(num);
getch();
}
In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT "Enter a number: "; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT "The sum of the digits is "; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.
Write a program to find the number and sum of all integers from 100 to 300 that are divisible by 11
public static final int getSum(final int n) { int sum = 0; for(int i = 1; i <= n; ++i) { sum += i; } return sum; }
This is a directive, not a question.
1. Get any no. 2. Find it factors. 3. Add its factor. 4. If sum of its factors is equal to itself then it is a perfect no. otherwise not
The number is 6.
In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT "Enter a number: "; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT "The sum of the digits is "; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.
int sum = 0; int n = 0; while( sum <= 999 ) { sum += (++n); }
no thanks
Write a program to find the number and sum of all integers from 100 to 300 that are divisible by 11
write an assembly language program to find sum of N numbers
program SumAndDifference; var num1, num2, sum, difference: integer; begin write('Enter first number: '); read(num1); write('Enter second number: '); read(num2); sum := num1 + num2; difference := num1 - num2; if sum > difference then written('The sum is greater: ', sum) else written('The difference is greater: ', difference); end. This program will prompt the user to enter two numbers, calculate their sum and difference, and then compare the two values. If the sum is greater than the difference, it will display the sum; otherwise, it will display the difference.
sum= answer of an addition question.. so the number of the sum is the answer.
public static final int getSum(final int n) { int sum = 0; for(int i = 1; i <= n; ++i) { sum += i; } return sum; }
The sum of the factors of any negative number is zero.
sum=0 i=1 echo "Enter any number " read num while [ $i -le 10 ] do sum=`expr $num \* $i` i=`expr $i + 1` echo "Table of a number is " $sum done
To write a program in QBasic that prints the sum of the even numbers from 1 to 20 in reverse order, you can follow these steps: DIM sum AS INTEGER sum = 0 FOR i = 20 TO 2 STEP -2 sum = sum + i NEXT i PRINT "The sum of even numbers from 1 to 20 is: "; sum This program initializes the sum to zero, iterates from 20 down to 2 in steps of -2 (to capture even numbers), adds each even number to the sum, and finally prints the result.