Monday, 6 August 2018

Algorithm To Displays Color According To The Enter Character From User in C

Program To Displays Color According To The Enter Character From User in C

/*program to print color*/
# include <stdio.h>
void main ()
{
char ch ;
clrscr () ;
printf ("/n enter a character :") ;
scanf ("%c", & ch) ;
switch (ch)
{
case 'r' ;
printf ("\n colour is red :") ;
break ;
case 'w' ;
printf ("\n color is white :") ;
break ;
case 'y' ;
printf ("\n color is yellow :") ;
break ;
case 'g' ;
printf ("\n color is green :") ;
break ;
case 'b' ;
printf ("\n color is blue :") ;
break ;
default :
printf ("\n invalid character :") ;
}
getch () ;
}

Algorithm To Displays Color According To The Enter Character From User in C

ALGORITHM :: DISPLAY COLOR AFTER INPUT CHARACTER FROM USER.

This is program to input a character from user and display color.

STEP 1. START.
STEP 2. INPUT A.
STEP 3. { DISPLAY COLOR }
             
              1. IF ENTER WORD IS R.
              2. DISPLAY COLOR IS " RED ".
              3. IF ENTER WORD IS W.
              4. DISPLAY COLOR IS " WHITE " .
              5. IF ENTER WORD IS Y.
              6. DISPLAY COLOR IS " YELLOW ".
              7. IF ENTER WORD IS G.
              8. DISPLAY COLOR IS " GREEN ".
              9. IF ENTER WORD IS B.
              10. DISPLAY COLOR IS " BLUE "

OTHERWISE
11. PRINT " INVALID CHARACTER " .
STEP 4. STOP





No comments:

Post a Comment

Featured post

Program to find maximum of three number using user define function in C++

A function can be define by the user as per the requirement of the user or programmer . To implement a user define function , a programmer ...