Monday 4 February 2019

C exercices

#exercices1#

1) Write a C program to print a block F using hash (#), where the F has a height of six characters and width of five and four characters.
Expected Output:
######
#
#
#####
#
#
#
 
2) Write a C program to print a big 'C'.

Expected Output: 
    ######
  ##      ##
 #
 #
 #
 #
 #
  ##      ##
    ###### 


Solutions 
1)

 int main() 
 {
 printf("######\n");
 printf("#\n");
 printf("#\n");
 printf("#####\n");
 printf("#\n");
 printf("#\n");
 printf("#\n");

 return(0);
}
2) 
#include <stdio.h> 
 int main() 
 {
   printf("    ######\n");
   printf("  ##      ##\n");
   printf(" #\n");
   printf(" #\n");
   printf(" #\n");
   printf(" #\n");
   printf(" #\n");
   printf("  ##      ##\n");
   printf("    ######\n");

 return(0);
}
 
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.