Tuesday, April 28, 2020

C language chapter-4. Escape sequence in c language.




Consider the following program.

Example-1

#include <stdio.h>
int main()
{
    printf("Hello world");
    printf("How are you?");
    return 0;
}
There are two printf statements. You may expect two lines of output. But the output is simply one line.
Output:
Hello worldHow are you?
Process returned 0 (0x0)   execution time : 0.016 s
Press any key to continue.
To make the output on two different lines you have to put ‘\n’ at the end of first printf statement.
Example-2
#include <stdio.h>
int main()
{
    printf("Hello world\n");
    printf("How are you?");
    return 0;
}
Output:
Hello world
How are you?
Process returned 0 (0x0)   execution time : 0.047 s
Press any key to continue.
‘\n’ is the type of escape sequence.it is called as new line escape sequence.
There are other escape sequences also.
‘\t’ is tab space escape sequence.
Example-3
#include <stdio.h>
int main()
{
    printf("Hello world\t");
    printf("How are you?");
    return 0;
}

Output:
Hello world     How are you?
Process returned 0 (0x0)   execution time : 0.047 s
Press any key to continue.
Instead of new line certain no of spaces are inserted at the output.
Like that two print a ‘\’ character on the output you have to type ‘\\’ in the program.
Also ‘\”’ is used to printf double quotes in the output:
And ‘\’’ is used to print single quote in the  output.
Thank you.
Contact: 91 9629329142
You tube channel: programming Digest.

Java chapter-2


Object oriented programming.


A large application consists of components objects, which interact with each other. These components can be used to develop various applications. This is referred to as the object oriented approach to develop an application.
Ravi, a programmer develops a code to calculate the employees’ salaries by using object oriented language. This code is reused for all employees at all levels. Re usability of code enables Ravi to use the same code for employees at all levels.
Advantages of object oriented programming.
1.    Real world programming.
In OOP, you create a basic structure of a program and keep extending the functionality of the program as per the requirements. The object oriented approach models the real world more accurately than the conventional, procedural approach.
2.    Reusability of code
In the object-oriented approach, you build classes, which can be used by several applications.
3.    Modularity of code.
Another advantage of object oriented programming is its modularity. It means that an object can be maintained independently of other objects. All these objects are independent of each other and maintained separately. You can make modification in one application without affecting the functionality of other objects.
4.    Resilience to change.
Object oriented programming also enables you to evolve various versions of software. When a change is suggested, the old system need not be completely abandoned and re-built from scratch.
5.    Information hiding
Objects provide the benefit of information hiding. Only a limited access to information is provided to the user. Information hiding enables data security in a program. An end user is given an access to the information only to the data that is required to run an application and not to the internal working of the application.

Class and objects.
A class defines structure and behavior of an object or set of objects.
Objects are the basic building block of object oriented programming. The concept of object oriented methodology is based on objects. You create independent entities that can be reused across various programs. Objects have the following characteristics:
State: The state of an object is indicated by set of attributes and the values of these attributes. For example you design an online shopping site for books, each book, which is an object in the program, has its size, number of pages, type of binding, and its shipping details.
Behavior: The behavior of an object refers to a change of its state over a period of time. For example, in the online shopping site, when you place an order for a book, the status of book might change from available to sold out. The changed status of the book its behavior.
Identity: Each objects has a unique identity, just as each person has a unique Identity. For example all the books may have same title, author, price etc but have a unique book id.

Thank you.

Muthu karthikeyan, Madurai
Contact: 91 96293 29142.
Visit my you tube channel: programming Digest.





C language chapter-3.comments



      Comments are the text which will not be compiled by the compiler. It will just ignore them.
      Comments are used to give documentation to the program
      When we will revisit our program after sometime or any other programmer visit your program they must understand what is the purpose of the code.



Example
/* this print output on the screen*/
Starts with /*
Ends with */
Multi line comment
/* this is
Example for
multiline comment */
End line comment
Printf(“hello world”); /*prints output */


Thank you.
contact:9629329142.
please visit my youtube channel programming digest