11. Write a program that counts the numbers of the given consonants (B, b, W, w,
ID: 3754894 • Letter: 1
Question
11. Write a program that counts the numbers of the given consonants (B, b, W, w, X, x, Z, z) in a sentence: Hint: Use getchar to read the characters you enter and count the number of the consonants while the character 'n' (the end of sentence) is not entered. Example Enter a sentence: Be well prepared for the exam. Your sentence contains 3 of the given consonants are subject to the income tax: Income is less than $1,000: From $1,000 to less than $50,000: From $50,000 to less than $100,000: $1,000 plus 10% of income over $50,000 $100,000 and over: Write a program to ask the user to enter the income, and then display the tax due. no taxes 20% of income over $1,000 no taxesExplanation / Answer
11th Answer:
#include<stdio.h>
#include <string.h>
int main()
{
char sentence[100],c;
int length;
int i = 0,v=0,w=0,x=0,y=0,z=0,sum;
printf("Enter sentence: Full stop to terminate sentence ");
while (( c = getchar()) != '.')
sentence[i++] = c;
sentence[i] = '';
length = strlen(sentence);
for(i=0;i<length;i++)
{
if(sentence[i]=='a' || sentence[i]=='A')
{
v=1;
}
if(sentence[i]=='e' || sentence[i]=='E')
{
w=1;
}
if(sentence[i]=='i' || sentence[i]=='I')
{
x=1;
}
if(sentence[i]=='o' || sentence[i]=='O')
{
y=1;
}
if(sentence[i]=='u' || sentence[i]=='U')
{
z=1;
}
}
sum=v+w+x+y+z;
printf("Your Sentence contains %d of the given consonants",sum);
return 0;
}
12th Answer:
#include<stdio.h>
int main()
{
int income;
float tax;
printf("Enter Income ");
scanf("%d",&income);
if(income<1000)
{
tax=0;
printf("Tax Due=%f",tax);
}
else if(income>=1000 && income<50000)
{
income=income-1000;
tax=(income*0.2);
printf("Tax Due=%f",tax);
}
else if(income>=50000 && income<100000)
{
income=income-1000;
tax=(income*0.1);
printf("Tax Due=%f",tax);
}
else{
tax=0;
printf("Tax Due=%f",tax);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.