Friday, July 20, 2007

Assignment 4 Loops and recursion

1.      Write a program that reads 3 characters from the keyboard and then prints them only if the letters have been read in alphabetical order (for example, print "boy" but do not print "dog").

 

 

 

#include <stdio.h>

 

 main()

 {

   char c1, c2, c3;

   scanf("%c%c%c",&c1, &c2, &c3);

   if (c1<=c2 && c2<=c3)

      printf("\n%c%c%c",c1,c2,c3);

   printf("\n");

 }

 

1 comment:

Caoimhin said...

In the coming term we will be hitting the ground running with some initial team events in the area of variable types which are very important to know and have covered correctly. So the first few labs will have you working in assigned groups (as posted on the blog or wiki