98.6k views
3 votes
Question 1: Write a complete C program that reads from the user the area of a triangle and the base of the triangle, then your program should calculate and display the height of the triangle. Hint: Area of Triangle =1/2× base × height. Question 2: Write a C program that reads a character from the keyboard and check whether the entered character is a vowel or not. Question 3: Write a C program that reads sequence of non-zero integer numbers from the keyboard and find the greatest of them. Hint: use a sentinel value of zero to indicate the desire of the user to stop entering additional numbers. Question 4: Write a loop program to display the multiplication table of the entered number. For example: Please enter a number to display its multiplication table: 5 5∗1=55∗2=10⋯5∗12=60

User BronzeByte
by
8.6k points

1 Answer

4 votes

Answer:

Question 1: C program to calculate the height of a triangle given its area and base

#include <stdio.h>

#include <math.h>

int main() {

double area, base, height;

printf("Enter the area: ");

scanf("%lf", &area);

printf("Enter the base: ");

scanf("%lf", &base);

height = sqrt(area / (base * 2.0));

printf("The height of the triangle is: %.2lf\\", height);

return 0;

}

Question 2: C program to check whether the entered character is a vowel

#include <stdio.h>

int main() {

char c;

printf("Enter a character: ");

scanf("%c", &c);

if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {

printf("It's a vowel!");

} else {

printf("It's not a vowel!");

}

return 0;

}

Question 3: C program to find the greatest number in a sequence

#include <stdio.h>

#include <math.h>

int main() {

int num;

int max = 0;

while (scanf("%d", &num) == 1) {

if (num > max) {

max = num;

}

}

printf("The greatest number is: %d\\", max);

return 0;

}

Question 4: C program to display the multiplication table of an entered number

#include <stdio.h>

int main() {

int num, i, j;

printf("Enter a number: ");

scanf("%d", &num);

for (i = 1; i <= num; i++) {

for (j = 1; j <= num; j++) {

No related questions found