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

Please I would like the codes in c programming KCULEARN BackForw Back Forward 1

ID: 3858180 • Letter: P

Question


Please I would like the codes in c programming

KCULEARN BackForw Back Forward 1 of 3 Assignment 1 (100 points) Purpose. To allow you to exercise with a logical thinking process to formulate algorithms, and to implement the algorithms using the C Programming Language. The logic will include simple inputs and outputs, looping, using counter%, condit onal statements (if and else), arrays, and functions. This assignment can be done in groups of two. Make sure you write both your names on the subission Some Instructions: A zip file containing files for ProblemA, ProblemB, etc. needs to be submitted on CULearn on or before the deadline. All code must commpile agrade Questions Write a separate C program for each of the following a. Print all the numbers divisible by n in the range [start, end]. (Hint you can check divisibility by using the modulus operator). Your program needs to be general such that you have variables as follows i. A variable start to indicate the start of the range il. A variable end to indicate the end of the range, and ii. A variable n to indicate the number to check divisibility for For example, if you set start, end, n respectively as 1000, 3500, and S your program will print all the numbers divisible by 5 in [1000,3500 bInput five numbers from the keybeard (see code below),compute and print to the screen their standard deviation. The standard deviation is given as: (20 points) To compute the standard deviation, you are to: L Compute the Il average of the five numbers Subtract the average from each number, then square the result, call this quantity the square of the difference square of the differences lil Sum up all of the iv. Divide the square of the differences by 5

Explanation / Answer

// Question 1
#include <stdio.h>
int main()
{
int start,end,divisor;
printf("Enter start number : ");
scanf("%d",&start);
printf(" Enter end number : ");
scanf("%d",&end);
printf(" Enter divisor : ");
scanf("%d",&divisor);

printf(" Numbers divisible by %d from %d to %d are : ",divisor,start,end);

for(int i = start;i<= end;i++)
{
if((i%divisor) == 0)
{
printf("%d ",i);
}

}
return 0;
}

//------------------------------------------
// Question 2
#include <stdio.h>
#include<math.h>

int main()
{

float arr1[5];
int i,number;
float SD,sum=0,difference,sum2= 0,mean,variance;

printf("Please enter the number of elements : ");
scanf("%d",&number);

printf(" Enter %d real numbers :",number);

for(i= 0;i<number;i++)
{
scanf("%f",&arr1[i]);
}

for(i= 0;i<number;i++)
{
sum = sum + arr1[i];
}

mean = sum/(float)number;

for(i= 0;i<number;i++)
{
difference = arr1[i] - mean;
sum2 = sum2+pow(difference,2);
}

variance = sum2/(float)number;
SD = sqrt(variance);

printf(" Standard Deviation = %.2f ",SD);
return 0;
}

//----------------------------------------
//question 3

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int getRandomNumber(int min, int max)
   {
   return ((rand() % (((max) + 1) - (min))) + (min));  
}
  
  
int main()
{
int x,y,z;
printf("Enter x and y : ");
scanf("%d %d",&x,&y);
srand(time(NULL));

z = getRandomNumber(x,y);
printf(" Random Number between [%d ,%d] is %d ",x,y,z);

return 0;
}

//---------------------------------------
//question 4
#include <stdio.h>

void Drawline(char c,int n){

if (n<0 || n>50)
{
n= 50;
}

printf(" Output : ");
for(int i= 0;i<n;i++)
{
printf("%c",c);
}
}

int main()
{
char c;
int n;
printf("Enter the character : ");
scanf("%c",&c);
printf(" Enter the count : ");
scanf("%d",&n);
Drawline(c,n);
return 0;
}
//------------------------------------
//question 5

#include <stdio.h>
long factorial(int);

int main()
{
int number;
    long fact = 1;
   long arr1[20];
  
   for(int i= 0;i<20;i++)
{
arr1[i] = factorial(i);
}
for(int i= 0;i<20;i++)
{
printf("%d! = %ld ",i,arr1[i]);
}
return 0;
}

long factorial(int n)
     {
     int c;
     long result = 1;
     for (c = 1; c <= n; c++)
     result = result * c;
       return result;
    }
// please upvote,,if u find the answer useful...Thanx