(C syntax) sum of approx. and sum of approx.

Source: Internet
Author: User

(C syntax) sum of approx. and sum of approx.

Knowledge point:

An algorithm used to calculate an appointment

For statement, if statement flexible use.

 

Content: enter a natural number and calculate the sum of all the approximate numbers of the natural number.

Input description:

An integer

Output description:

An integer

 

Input example:

6

Output example:

12

 

 1 #include <stdio.h> 2 int main() 3 { 4  int n,s=0,i; 5  scanf("%d",&n); 6  for (i=1;i<=n;i++) 7  { 8   if (n%i==0) 9   {10    s=s+i;11   }12  }13  printf("%d\n",s);14  return 0;15 }

 


How does one use the C language to calculate the sum of all the approximate numbers of an integer?

# Include <stdio. h>
Int main (int argc, char * argv [])
{
Int I, a, sum;
While (scanf ("% d", & )! = EOF)
{
Printf ("% d's approximate numbers include:", );
Sum = 0;
For (I = 1; I <= a; I ++)
If (a % I = 0)
Sum + = I, printf ("% d,", I );
Printf ("sum of approx. % d \ n", sum );
}
Return 0;
}

A is A prime number. 7A has () approx. A3 B4 C3 or 4 on A drawing with A scale of 10:1. The figure 2cm indicates the actual () 2 cm 2mm 20 cm.

A is A prime number, and 7A has (A has 3:, A) approx. A 3 B .4 C.3 or 4
On a drawing with a scale of, 2cm indicates the actual (20 cm) 2 cm 2mm
A's five or six products are equal to B's number. 80%. A's number is equal to B's number.
A and B cylinder, bottom area ratio, Volume Ratio A and B ratio ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.