Compute this in C. 1. Write a Perl program that asks the values of the length an
ID: 3588671 • Letter: C
Question
Compute this in C. 1. Write a Perl program that asks the values of the length and width of a rectangle and prints the area of the rectangle. (10 points. File name:hw3_1) Write a Perl program that asks a number and prints the sum from 1 to the entered number. (10 points. Fille name:hw3_2) Ex) 2. S Enter a number: 10 $ The sum from 1 to 10 is 55 Write a Perl program that asks a series of words (with one word per line) until end-of-input then prints the series of words in an inverse order. (15 points. File name:hw33) 3. Ex) S Enter a series of words: Hello Apple World Good S The result is: Good World Apple Hello Write a Perl program that asks a series of words (with one word per line) until end-of-input, prints the above words in ASCII order, and then prints the repeated words. (15 points. File name hw3 4) 4. Ex) 5 Enter a series of words: Fred Barney Wilma Betty Fred $ The result is Barney Betty Fred Wilma $ The repeated words Fred
Explanation / Answer
#include<stdio.h>
int main(){
float a,b,area;
printf("Enter length and breadth of a rectangle : ");
scanf("%f %f",&a,&b);
area = a*b;
printf("Area of rectangle is %f",area);
return 0;
}
#include<stdio.h>
int main(){
int a,result=0;
printf("Enter number : ");
scanf("%d",&a);
for(int i=0;i<a;i++){
result = result+i+1;
}
printf("Sum from 1 to %d is %d",a,result);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.