Showing posts with label Exercise 6. Show all posts
Showing posts with label Exercise 6. Show all posts

Sunday, 23 April 2023

Exercise 6-To demonstrate menu driven programs and use of standard library functions

SET A

1. Write a program, which accepts a character from the user and checks if it is an alphabet, digit
or punctuation symbol. If it is an alphabet, check if it is uppercase or lowercase and then change
the case.


 #include<stdio.h>
#include<conio.h>
void main()
{
 char ch;
 clrscr();
 printf("\nEnter charcter:");
 scanf("%c",&ch);
 if(isalpha(ch))
   {
    printf("\n%c is alphabet",ch);
    if(isupper(ch))
       printf("\n %c is uppercase alphabet",ch);
    else if(islower(ch))
      printf("\n %c is lowercase aplhabet",ch);
   }
 else if(isdigit(ch))
     printf("\n %c is digit",ch);
      else if(ispunct(ch))
          printf("\n %c is a punctuation ",ch);
 getch();
}
/*

Enter charcter:4

 4 is digit

Enter charcter:!

 ! is a punctuation

Enter charcter:D                                                               
                                                                               
D is alphabet                                                                  
 D is uppercase alphabet        

Questions

  Exercise 1 Set A . Apply all the three program development steps for the following examples.  1. Accept dimensions of a cylinder and p...