C++ Learning the Basics: Multiplication of Two-Matrix

This program takes two matrices of order r1*c1 and r2*c2 respectively. Then, the program multiplies these two matrices (if possible) and displays it on the screen. Continue reading C++ Learning the Basics: Multiplication of Two-Matrix



Situation: User inputs a string and code tells you the number of lower case and upper case alphabets, numbers, spaces, and special characters. #include<iostream.h> #include<conio.h> #include<stdio.h> class Array { private: char string[30]; int len, vowel, conso, upper, lower, space, special, dig; public: Array() { len=vowel=conso-lower=upper=dig=space=special=0; } void process() { cout<<“\n\t Enter string: “; gets(string); } void display() { cout<<“\n\t Enter string: “; while (string[len]!=’\0′) cout<<string[len]; if(string[len])>=’a’&&string[len]<=’z’) … Continue reading #CoolCodez

C++: #CoolCodez Part 3

SITUATION: MAKING A RIGHT ANGLE TRIANGLE OF NUMBERS AND ALPHABETS. #include #include void main() { clrscr(); int row, temp=0, space, num=1, tempnum=1, cois; char alpha=’A’, tempalpha=’B’; cout<<“\n\n”; for(row=5;row>0;row–) { if(row%2==0) { tempnum–; num=tempnum; } else { tempalpha–; alpha=tempalpha; } cout<<“\t”; for(space=temp;space>0;space–) { cout<<“\t”; } temp++; for(cois=row;cois>0;cois–) { if(row%2==0) { cout<<“\t”<<alpha++; } else { cout<<“\t”<<num++; } } tempalpha=alpha; tempnum=num; cout<<“\n”; } getch(); } Continue reading C++: #CoolCodez Part 3

Introduction to Arrays

An array is a data structure which allows a collective name to be given to a group of elements which all have the same type. An individual element of an array is identified by its own unique index or subscript. An array can be thought of as a collection of numbered boxes each containing one data item. Simple code for an array: #include<iostream.h> #include<conio.h> void main() { char name[20]; int length=0; … Continue reading Introduction to Arrays

Java: Learning the Basics

Situation: Find the greater number between two numbers. import java.util.*; public class Greaternumber { private int num1, num2; Scanner scr = new Scanner(System.in); { System.out.print(“\n\t Enter first number: “); num1=scr.nextInt(); System.out.print(“\n\t Enter first number: “); num2=scr.nextInt(); } public void check() { if(num1>num2) { System.out.print(“\n\t Greater number is ” + num1); } else { System.out.print(“\n\t Greater number is ” + num2); } } public static void … Continue reading Java: Learning the Basics

Introduction to Object Orientated Programming (OOP)

What is OOP? Object Orientated Programming attempts to demystify and organize programming in a structured manner so that other programmers can work on it as well. It essentially works on objects rather than “actions” and data rather than logic. The language was formed by analyzing the very nature of the real world. The following principles are the four pillars of the Real World. They give breath to … Continue reading Introduction to Object Orientated Programming (OOP)

C++: Learning the Basics – Right Alignment

Situation 1: Pattern shown below but the text is aligned to the right. #include<iostream.h> #include<conio.h> void main() { clrscr(); int sym, rows, space=5; char alpha; for (rows=5, row=1; rows>=1; rows–, row++) { alpha=’A’; for(space=0; space<rows-1; space++) { cout<<“\t”; } for (sym=1; sym<=rows; sym++) { if(rows%2==0) { cout<<“\t”<<sym; } else { cout<<“\t”<<alpha; alpha++; } } cout<<“\n”; } getch(); } Situation 1: Pattern shown below but the … Continue reading C++: Learning the Basics – Right Alignment

C++: Learning the Basics – Making Patterns

Situation: Make the following patterns – 1. Patterns with asterisks #annotated #include <iostream.h> #include <conio.h> void main() { clrscr(); int rows=5, counter, sym; #you can ask the user for number of rows, but I have just stated that rows=5 for simplicity for (counter=1; counter<=rows; counter++) { for (sym=1; sym<=counter; sym++) #sym stands for symbol. sym essentially acts as a counter for the number of asterisks. … Continue reading C++: Learning the Basics – Making Patterns