Here is the Programming Fundamentals Quiz No 01
Question:
Making diamond using loop in cpp
Code:
Here is the Programming Fundamentals Quiz No 01
#include<iostream> using namespace std; int main() { int width = 7; // print upper half of the diamond for(int i = 0; i < width/2 + 1; i++) { // print spaces for(int j = 0; j < width/2 - i; j++) { cout << " "; } // print asterisks for(int k = 0; k < 2*i + 1; k++) { cout << "*"; } cout << endl; } // print lower half of the diamond for(int i = width/2 - 1; i >= 0; i--) { // print spaces for(int j = 0; j < width/2 - i; j++) { cout << " "; } // print asterisks for(int k = 0; k < 2*i + 1; k++) { cout << "*"; } cout << endl; } return 0; }
For more details about Huffman coding click here
For other assignments and quizzes click here
Output: