Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C Language: Program 1 Write a C program that accepts an integer between 1 to

ID: 3726696 • Letter: I

Question

In C Language:

Program 1

Write a C program that accepts an integer between 1 to 20 (both inclusive) as input from the user and computes the sum of all numbers that are divisible by the input number in the range 1 to 100 (both inclusive). Also, print all numbers that are divisible by the input number. Please comment your code well

Program 2

Write a program in C that accepts ten integers from the user and stores them in an array and then counts the frequency of each integer appearing in the array. Please comment your code well

Explanation / Answer

//question 1 answer

#include <stdio.h>

int main()

{

int n=0,i=0,j=0,sum=0;

printf("Enter the number:");

scanf("%d",&n);

if(n>0 && n<=20)

{

for(i=1;i<=100;i++)

{

if(n%i==0)//if divisible the add to sum

{

sum+=i;

}

}

printf("sum of all no's from 1 to 100 that divides %d is=%d ",n,sum);

printf("no's from 1 to 100 that divides %d are: ",n);

for(i=1;i<=100;i++)

{

if(n%i==0)//if divisible then print

{

printf("%d ",i);

}

}

}

else

printf("wrong input, you haven't enter no from 1 to 20 ");

return 0;

}

//question 2 answer

#include <stdio.h>

int main()
{
int arr[10],i=0,j=0,count=0;
printf("Eneter 10 numbers: ");
for(i=0;i<10;i++)
scanf("%d",&arr[i]);
printf("Frequency count: ");
for(i=0;i<10;i++)
{count=0;//for every element make intial count=0
for(j=0;j<10;j++)
{
if(arr[i]==arr[j])//if elements are equal then increase count
count++;
}//now print frequency
printf("number %d has occured %d times in the array ",arr[i],count);
}
return 0;
}