I need a solution for this problems, I prefer to get the answer using printf and
ID: 3890236 • Letter: I
Question
I need a solution for this problems, I prefer to get the answer using printf and scanf not cout and cin.
Program: C Compiler
4. The below program outlines the requirements for obtaining state medical insurance in a country Analyse, comment each line, and execute the program for various cases and present the output. (ASCII CODES FOR 'U' is 21 and 'M' is 13) Listing 6: Question 4 # include # include #include main () int sex, mart sta; int age, taxes, pre_ext; printf (" ENTER SEX and MARITAL STATUS "); scanf-s("%d%d", &sex;, &mart-sta;); printf("AGE Taxes PAID or NOT ANY PRE EXISTING CONDITIONS and AGE n") scanf-s("%d%d%d", &age;, &taxes;, &pre-ext;); if ((mart-sta- ,M") 11 (mart-sta- ,U, && sex ,M'&& > 25 && taxes- == age 1) ll (mart-sta-= ,U' && sex-,F, && age > 30 && taxes -- 1) 11 (pre-ext printf (" GRANT INSURANCE n"); else printf ("REFER TO REGIONAL OFFICE: REQUEST FOR FURTHER INFORMATION n"); 5. The formula for the area of any triangle is Area = y's(s-a)(8-5)(8-c) a+b where s= Given the sides a, b, and c of a triangle determine whether it is a right triangle. Print the sides and the area. A triangle is right triangle if c2-a2 + b2 where c is the longest sideExplanation / Answer
5.
#include <stdio.h>
#include<math.h>
int main(void) {
// your code goes here
int a,b,c,s,x,y;
float area;
printf("enter the values a,b,c");
scanf("%d %d %d",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
x=c*c;
y=(a*a)+(b*b);
if(x==y)
{
printf(" Triangle is Right angled");
}
else
printf(" Triangle is not Right angled");
printf(" The sides are %d %d %d",a,b,c);
printf(" Area is %f",area);
return 0;
}
output:
enter the values a,b,c : 3 4 5
Triangle is Right angled
The sides are
3
4
5
Area is 6.000000
4)
#include <stdio.h>
#include<math.h>
int main()
{
char sex,mar_sta;
int age,tax,pre_ext;
printf(" ENTER THE SEX AND MARITAL STATUS:");
scanf("%c %c",&sex,&mar_sta); \Getting sex and marital status
printf(" AGE TAX PAID OR NOT ANY PRE EXISTING CONDITION and AGE:");
scanf("%d %d %d",&age,&tax,&pre_ext); \ Getting input
if((mar_sta=='M')||(mar_sta=='U'&&sex=='M'&&age>25&&tax==1)||(mar_sta=='U'&&sex=='F'&&age>30&&tax==1)||(pre_ext==1)) \condition for granting insurance
printf(" GRANT INSURANCE "); \if Conditions are true then this will be displayed
else
printf(" REFER TO REGIONAL OFFICE OR REQUEST FOR FURTHER INFORMATION "); \ If condition failed
}
Output:
ENTER THE SEX AND MARITAL STATUS: M M
AGE TAX PAID OR NOT ANY PRE EXISTING CONDITION and AGE: 24 1 1
GRANT INSURANCE
ENTER THE SEX AND MARITAL STATUS: M F
AGE TAX PAID OR NOT ANY PRE EXISTING CONDITION and AGE:25 1 1
GRANT INSURANCE
ENTER THE SEX AND MARITAL STATUS: U F
AGE TAX PAID OR NOT ANY PRE EXISTING CONDITION and AGE:35 1 1
GRANT INSURANCE
ENTER THE SEX AND MARITAL STATUS: U M
AGE TAX PAID OR NOT ANY PRE EXISTING CONDITION and AGE: 30 1 1
GRANT INSURANCE
ENTER THE SEX AND MARITAL STATUS: U F
AGE TAX PAID OR NOT ANY PRE EXISTING CONDITION and AGE:27 1 1
REFER TO REGIONAL OFFICE OR REQUEST FOR FURTHER INFORMATION
ENTER THE SEX AND MARITAL STATUS: U M
AGE TAX PAID OR NOT ANY PRE EXISTING CONDITION and AGE:20 1 1
REFER TO REGIONAL OFFICE OR REQUEST FOR FURTHER INFORMATION
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.