Posts

Showing posts from 2016

Some Useful Functions

Image
typedef ◘ It is used to give another name to the previous or existing data type. ◘ It is not creating new data type. ◘ typedef data_type another_name ; Example- #define ◘ It is also called compiler directive. ◘ It is also called pre-processor ◘ It is used to define Symbolic constants. ◘ #define pi 3.14; ◘ It is also used to define mricros (small single line statement function) Example of micros, #include ◘ It is used to add contains of a file which is written inside the angular bracket < > . Example -               #include <iostream> * It will help to include fine iostream in our program. #if ◘ It is used to test whether a compiler time condition is true. #under ◘ It is used to un-define micros. #else ◘ It is used to specify the alternative . ◘ It used to perform an action if a test fail. #endif ◘ To end the pre-processor conditions. By - Somesh Sah

Structure

Image
In C++  " It is a collection of variables referred under one name.  " Structure can be Defined as - - struct is the keyword. - structure is a collection of related data types known as a members of structure. - It is very powerful. - In array , we group of same data type but in structure we can able to group different data types. - structure is always end up with a (;) semicolon . Now we have to makes the object of the structure student [ name_of_the_structure obj; ] Object -  - Is an run time entity. - It contains all the members and its functions - we can not use structure without making its object. - object of student S1 . - S1 has its own name , roll number and percent.  - like that we can create as many as objects. Note - The Members of the object can be assessed bu using ( . ) dot operator. Ques - Write a program to make a structure to enter book name and its author name then dis...

Array

Image
"Array - It is a collection of variable of same data type and referred under a common name." In C++ ,  the declaration of an array is  int a [10] ;                  where  int is a Data Type , it can b float, char etc.  a is a Name of the Array (under which it is referred) [ index number ] is a size of array and it is always started from 0 to size-1 . Two Types Of Array ♣ Single Dimensional Array  ♣ Two Dimensional Array ♣ Multi Dimensional Array # Single Dimensional Array - it store its elements in linear form. - it has continuous memory location. - the size of array is always positive.   Here we declarer an array with size of 5 elements. ( int a[5]; ) a[5] = {55,45,78,67,28} a[0] = 55 a[1] = 45 a[2] = 78 a[3] = 67 a[4] = 28 Note- 5001 , 5002, .... 5005 is know as address of the array elements (store in...

User defined Function

Image
" Function is defined as a group of statements that together perform a specific task. " - Main() is a function, therefore every C++ program should have at least one function. - Function is divided into 3 part           1 - function declaration          2 - function definition          3 - function call  - A function declaration tells the compiler about a function's name, return type, and parameters. - A function definition means body of the function. - A function call  is a part of main programs and it specified which function should be called. Example - There are four possible style to write a function in your program - 1- void function with no argument                      e.g- 2- void function  with argument         ...

Call By Value & Call By Reference

Image
FORMAL PARAMETER - These are the parameters which appear in the function definition or declaration is called Formal Parameter.  ACTUAL PARAMETER - These are the parameters which appear in the function call is called Actual Parameter. Call By Value - In Call By Value , value of actual parameter is copied into Formal Parameter. The function work on formal parameter only. Actual parameter is intact. Change are not reflected is called function. Call By Reference -  In this type, instead of copying a value of actual parameters into formal parameter, the function receive address of the actual parameter. Works on the original value, Changes are reflected in the calling function. Summary -    By - Somesh Sah

Nested Loop

Image
"In Computer Science a nested loop is a loop within a loop, an inner loop within the body of an outer loop." How this works is that the first pass of the outer loop triggers the inner loop, which executes to completion. Then the second pass of the outer loop triggers the inner loop again.  This repeats until the outer loop finishes. 0r In Simple Words -  consider yo have to plot a graph , so you need (x,y) point... Similarly the outer for loops provide you x values and the inner for loop provides y values. Of course, a break within either the inner or outer loop would interrupt this process. The concept of Nested loop is very Important. Nested loop is very useful in Advance programming. Syntax - For Example - Please watch this video ...to understand nested loop clearly. Generally Nested Loops used in pattern programming... Please follow this link - http://www.programiz.com/article/c%2B%2B-programming-pattern ...

Loop Statement Programs

Image
  " In computer programming, a loop is a sequence of instruction that is continually repeated until a certain condition is reached " There are three types of loops ♣ for loop ♣ while loop ♣ do while loop FOR LOOP Defination - For loop is used for counting purpose. - For loop is divided into three parts 1- initialization 2-  condition 3- increment/decrement Initialization is that part of the loop where counting starts. Condition is that part of the loop which defines the end point of the counting till it satisfy the parameter(condition) Increment/Decrement is that part of the loop which defines the order of counting in increment/decrement order. Syntax of for loop for(initialization; condition; increment/decrement) { Statements ; } Programming (Example) Ques - Display the number from 0 to 9 using for loop Output WHILE LOOP - WHILE loops are very simple. - If conditions is true ...

Standard Library Functions

Image
According to wikipedia ... Standard stands for a level of quality or attainment.       Library stand for collection of book. Function is an activity that is for a purpose of a person or thing. Therefore The Standard Library Functions  are defined as  ... "Standard Library are the collection of subprograms (function) which is used to develop other programs or software." ♥ Types of Functions 1- Library Functions  (Header Files function)                         //In this post 2- User Defined Function (User Defined Functions)               // In next post ♣ Character Functions Character Functions, are the collection of all the function related with characters. The header file is "ctype.h" is used to use following functions. # isalnum() - is - " Is " is used to form question. al-   al stands " alphabet " . num...

If and If-Else Program

Image
If statement :- The if statement evaluates the test expression inside parentheses. If test expression is evaluated to true ( nonzero ), statements inside the body of if is executed. If test expression is evaluated to false ( 0 ), statement inside the body of if is skipped. Flow Chart of if statement :- Basic if syntax :- if ( statement is TRUE ) { /* between the braces is the body of the if statement */ Execute all statements inside the body } Example :- Ques - Program to Print number is even. #include <iostream> //Header file using namespace std; int main () //Main function { int number ; cout<<"Enter a number :"; // Print on the screen cin>>number; // Take input from the console / user. // Test expression is true if number is perfectly divide by 2 if ( number % 2 == 0 ) // % means find remainder , == means perfectly equal { cout<< "Even number" ; ...

Pseudo Code, Algorithm, Flow Chart and Programing

Image
In computer Science , Any Programing Question will be answered by four ways... 1- Pseudo Code 2- Algorithm 3- Flow Chart 4- Programming (Coding) Let's see all These with example. Ques - Write a Program to take two numbers from users and return its sum along with its Pseudo code, Algorithm and Flowchart.  ♥ Pseudo Code Pseudo Code is also called Program Design Language. It is high level language. It is used to wright steps of a program in English. It is very simple to understand and easy to wright. Answer- Step 1- Include Header Files Step 2- Declare three variables Step 3- Get the input from user Step 4- Perform operation (Sum operation) Step 5-  Display Sum Step 6- Terminate program ♥ Algorithm Algorithm is an Step by Step instruction to performs operation. It is well defined Language used to describe Programs. It is written in English language with programing Syntax. It is very efficient and very useful. It can be ...

Syntax in C++

Image
Syntax is defined as a way of writing a program. It just like when we write English Sentences we think about grammar that our sentence should be grammatically right...same thing with the program's Syntax is like a grammar in our programs. " The Valid Structure of Statement in a program is called Syntax. " # if Syntax if (condition) { block statement1; } # if else Syntax if (condition) { block statement_1; } else { block statement_2; } # if else ladder Syntax if (condition) {block statement1;} else if (condition1) {block statement2;} else if (condition2) {block statement3;} else {default statement4;} # switch syntax switch (choice) { case 1: statement 1; break/continues ; case 2: statement 2; break/continues; case 3: statement 3; break/continues; . . . case n: statement n; Default : default statement; } # while loop Syntax while (condition) { statement1; statement2; . . statement n; ...