Skip to main content


C++ Diamond Pattern

C++ program to print the diamond pattern using '#' symbols. In this program two for loops are used to print the pattern. The first loop prints the upper part to the diamond ( triangle part ). The second for loop prints the lower part of the diamond (an inverted triangle ) . By combining both of the triangles an diamond pattern structure is formed. PROGRAM CODE: #include<iostream> using namespace std; int main() { int i,j,k=1,s=6,l; for(i=0;i<5;i++,k-=2,s-=1) { for(l=s-1;l>=0;l--) cout<<' '; for(j=k;j<0;j++) cout<<"#"; cout<<endl; } k = 9; s = 0; for(i=0;i<5;i++,k-=2,s+=1) { for(l=s;l>=0;l--) cout<<' '; for(j=k;j>0;j--) cout<<"#"; cout<<endl; } return 0; } OUTPUT:            #         # # #      # # # # #    # # # # # # # # #
Recent posts

UniPolar Encoding

Unipolar encoding has 2 voltage states with one of the states being 0 volts. Since Unipolar line encoding has one of its states being 0 Volts, it is also called Return to Zero (RTZ). A common example of Unipolar line encoding is the logic levels used in computers and digital logic. A logic High (1) is represented by +5V and a logic Low (0) is represented by 0V. Unipolar line encoding works well for inside machines where the signal path is short but is unsuitable for long distances due to the presence of stray capacitance in the transmission medium. On long transmission paths, the constant level shift from 0 volts to 5 volts causes the stray capacitance to charge up. There will be a "stray" capacitor effect between any two conductors that are in close proximity to each other. Parallel running cables or wires are very suspectible to stray capacitance. If there is sufficient capacitance on the line and a sufficient stream of 1s, a DC voltage component will be

Operator Precedence

Simple program for operator precedence parser in C. It takes the expression as input and calculates the precedence of the operators. Subscribe to the blog to get instant updates via E-Mail. PROGRAM CODE: #include<stdio.h> #include<string.h> void main() { int i,j,cnt=1; char operators[] ="*/%+-",input[100]; printf("Enter the statement : "); gets(input); for(i=0;i<strlen(operators);i++) { for(j=0;j<strlen(input);j++) { if(input[j]==operators[i]) { printf("%d %c=%c%c%c\n",cnt++,input[j-1],input[j-1],input[j],input[j+1]); input[j+1]=input[j-1]; } } } } OUTPUT: Subscribe to the blog to get instant updates via E-Mail. Notify the Suggestions about the program through comments ... :)

Lexical Analyzer

Simple Lexical Analyzer program. It takes the filename in the same directory as the input and analyzes the program for variables operators and special characters. and prints the output for each values separately. #include<stdio.h> #include<conio.h> #include<string.h> void main() { FILE *fp; int i=0; char input[100],filename[20]; clrscr(); printf("Enter Filename : "); scanf("%s",filename); fp=fopen(filename,"r"); while(!feof(fp)) { input[i]=fgetc(fp); i++; } input[--i]='\0'; for(i=0;i<strlen(input);i++) { if(isalpha(input[i])) { printf("%c is a Character.\n",input[i]); } else if(input[i]=='='||input[i]=='+'||input[i]=='-'||input[i]=='*'||input[i]=='/'||input[i]=='

Text analyzer

The following Text analyzer program is implemented in c program. It program analyzes the given text from the user and calculate the number of words and total number of characters in the line of text. It determines the numbers of vowels, consonants, white space characters and other characters for each line. And finally determines average number of vowels, consonants per line. Concepts used: Array concept is used to store the input text which is to be analysed. The input text is entered during run time. The text contains space hence gets function is used to get the input text from the user. Local variables and global variables are used. For loops and while loops are used to calculate the number of characters and words. Function is used to check whether the given character matches with the available character. Source code: #include<stdio.h> #include<conio.h> #include<string.h> int stc(char *,char); void main() { int ch,ln=0,space,vow,con,

Library Management System ( CPP coding ) :

Library Management System has been implemented as a C++ program. Complete program code is given below. Complete project is available on user request. User comments are welcome to notify any Bugs or to improve the further posts. :) Concepts used: Multilevel inheritance is used in this program. The files concepts were also used to store and retrieve the required data's for the login details, membership details and book details. Modules :   1. Login maintenance  2. Library maintenance  3. Book issue maintenance  4. Book return maintenance  LOGIN MAINTENANCE  Separate login for administrator, member and guest should be provided.  Should accept user name and password from the user.  Should compare the user name and password (case sensitive).  If the user name and password matches then the menu for the respective login should be displayed.  If the user name or password is incorrect it should display an error message.  If the user name