Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Working with switch case



Specifer



Comment



Iterative statement



" ; " after loop




A general instruction for cleaning room by a robot



// AHF C PROGRAM SOLVING

//solving here basic type of programming problem

#include<stdio.h> #define pf printf int main() { char ch,a,b; pf("\nEnter the room status,\nc for clear and d for dirty\n\n and\n enter the room number (A or B): "); scanf("%c %c %c",&a,&b,&ch); if(ch=='A') { if(a=='c') { pf("\nMove room B."); } if(a=='d') { pf("\nClear the room A."); pf("\nMove to room B."); } if(b=='d') { pf("\nClear room B."); pf("\nWait for dirty."); } if(b=='c') { pf("\nWait for dirty."); } } else if(ch=='B') { if(b=='c') { pf("\nMove to room A."); } if(b=='d') { pf("\nClear room B."); pf("\nMove to room A."); } if(a=='c') { pf("\nWait for dirty."); } if(a=='d') { pf("\nClear room A."); pf("\nWait for dirty."); } } return 0; }
OUTPUT:


© 2018 - All rights reserved