IF IT IS ALPHABET , CHECK IF IT IS UPPERCASE AND THEN CHANGE THE CASE
#include<stdio.h>
#include<math.h>
main()
{
char ch;
printf("Enter a character");
scanf("%c",&ch);
if(isalpha(ch))
{
printf("%c is an alphabet",ch);
if(isupper(ch))
printf("%c",tolower(ch));
else
printf("%c",toupper(ch));
}
else if(isdigit(ch))
{
printf("%c is a digit",ch);
}
else if(ispunct(ch))
{
printf("%c is a punctuation mark");
}
}
ASSIGNMENT 6)
math.h() : this function is used to perform various mathematical operations
ceil smallest integer not less than parameter
cos
cosh
exp(double x) computes e^x
fabs absolute value
floor largest integer not less than parameter
fmod floating point reamainder
log
log10
pow(x,y) computes x^y
sin
sinh
sqrt
tan
tanh
Menu-driven systems are advantageous in two ways: firstly, because input is via single key strokes, the system is less prone to user error; secondly, because only a limited range of characters are “allowed”, the way in which the input is to be entered is unambiguous. This contributes toward making the system more user-friendly. Compare command-line interface.
#include<stdio.h>
#include<math.h>
main()
{
char ch;
printf("Enter a character");
scanf("%c",&ch);
if(isalpha(ch))
{
printf("%c is an alphabet",ch);
if(isupper(ch))
printf("%c",tolower(ch));
else
printf("%c",toupper(ch));
}
else if(isdigit(ch))
{
printf("%c is a digit",ch);
}
else if(ispunct(ch))
{
printf("%c is a punctuation mark");
}
}
ASSIGNMENT 6)
TO DEMONSTRATE MENU DRIVEN PROGRAMS AND USE OF STANDARD LIBRARY FUNCTIONS
You should read following topics before starting this exercise
1) Use of Switch statement to create menus as in Assignment 3.
2) Use of while and do- while as in Assignment 4.
ctype.h : contains function prototypes for performing various operations on characters. Some commenly used functions are listed below.
FUNCTION PURPOSE
isalpha() check whether a character is alphabet
isalnum() check whether a character is alphanumeric
isdigit() check whether a character is a digit
isspace() check whether a character is space
ispunct() check whether a character is a punctuation mark
isupper() check whether a character is in uppercase
islower() check whether a character is in lowercase
toupper() converts a character to uppercase
tolower() converts a character to lowercase
math.h() : this function is used to perform various mathematical operations
ceil smallest integer not less than parameter
cos
cosh
exp(double x) computes e^x
fabs absolute value
floor largest integer not less than parameter
fmod floating point reamainder
log
log10
pow(x,y) computes x^y
sin
sinh
sqrt
tan
tanh
Menu Driven program
A program that obtains input from a user by displaying a list of options – the menu – from which the user indicates his/her choice. Systems running menu-driven programs are commonplace, ranging from microprocessor controlled washing machines to bank cash dispensers. In the case of the cash dispenser, single keys are pressed to indicate the type of transaction (whether a receipt is wanted with the cash, or if a statement of the bank balance is required) and with many, a single key is pressed to indicate the amount of money required.Menu-driven systems are advantageous in two ways: firstly, because input is via single key strokes, the system is less prone to user error; secondly, because only a limited range of characters are “allowed”, the way in which the input is to be entered is unambiguous. This contributes toward making the system more user-friendly. Compare command-line interface.
No comments:
Post a Comment