#include<stdio.h>
main()
{
char ch;
printf("Enter a character");
scanf("%c",&ch);
if((ch=='a')||(ch=='e')||(ch=='i')||(ch=='o')||(ch=='u')||(ch=='A')||(ch=='E')||(ch=='I')||(ch=='O')||(ch=='U'))
printf("%c is a vowel",ch);
else
printf("%c is a consonant",ch);
}
ASSIGNMENT 2)
TO DEMONSTRATE USE OF DECISION MAKING STATEMENTS SUCH AS if AND if-else
You should read following topics before starting this exercise
1. Different types of decision making statements available in C.
2. Syntax for this statements.
i ) if statements
Syntax = if (condition)
{
statement;
}
ii ) if-else
Syntax = if (condition)
{
statement;
}
else
{
statement;
}
iii ) Nested if
if (condition)
{
if (condition)
{ statement; }
else
{ statement; }
}
else
{
if (condition)
{ statement; }
else
{ statement; }
}
main()
{
char ch;
printf("Enter a character");
scanf("%c",&ch);
if((ch=='a')||(ch=='e')||(ch=='i')||(ch=='o')||(ch=='u')||(ch=='A')||(ch=='E')||(ch=='I')||(ch=='O')||(ch=='U'))
printf("%c is a vowel",ch);
else
printf("%c is a consonant",ch);
}
ASSIGNMENT 2)
TO DEMONSTRATE USE OF DECISION MAKING STATEMENTS SUCH AS if AND if-else
You should read following topics before starting this exercise
1. Different types of decision making statements available in C.
2. Syntax for this statements.
i ) if statements
Syntax = if (condition)
{
statement;
}
ii ) if-else
Syntax = if (condition)
{
statement;
}
else
{
statement;
}
iii ) Nested if
if (condition)
{
if (condition)
{ statement; }
else
{ statement; }
}
else
{
if (condition)
{ statement; }
else
{ statement; }
}
No comments:
Post a Comment