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

Assignment 4 Total 50 points 1. (10 points) Write a program as follows: (nl shou

ID: 3731988 • Letter: A

Question

Assignment 4 Total 50 points 1. (10 points) Write a program as follows: (nl should be less than n2) b. If the user enters the negative number(s), convert it/them to positive number(s). c. If nl is greater than n2, swap them. d. Use a while loop to output all the even numbers between nl and n2. e. Use a while loop to output the sum of all the odd numbers between nl and n2. f. Use a while loop to output the sum of squares of all the odd numbers between nl and n2. e Use a while loop to output all the lower case letters. Sample run: Enter two numbers (First number must be less than the second number) Enter the first number:-21 Enter the second number: 5 Even integers between 5 and 21 are: 6 8 10 12 14 16 18 20 Sum of odd integers between 5 and 21 117 Sum of the squares of odd integers between 5 and 21 1761 Lover case letters are: a bedefghijki mnoPqIStuvwxyz

Explanation / Answer

#include<stdio.h>

main()

{

int n1,n2,temp;

printf("Enter the value of n1::");scanf("%d",&n1);

printf("Enter the value of n2::");scanf("%d",&n2);

if(n1==n2)

{

printf("WRONG INPUT");

return 0;

}

if(n1<0)

{

n1=-(n1);

}

if(n2<0)

{

n2=-(n2);

}

if(n1>n2)

{

temp=n1;

n1=n2;

n2=temp;

}

int x=n1;int y=n2;int sum=0;

while(n1<=n2)

{

if(n1%2==0)

{

printf("%d ",n1);

}

n1++;

}

printf(" Odd numbers:");

while(x<=y)

{

if(x%2!=0)

{

printf("%d ",x);

sum=sum+x;

}

x++;

}

printf(" odd numbers sum::%d",sum);

}