Sunday, August 30, 2020

 

Elements of programming -5.




Nested if statement.

First a condition is checked if it is true then another condition checked. If it is true another condition is checked. If it also true then a block of statement is executed. If the first condition is true, then else part will be executed. we can also check another condition in else part.

Example.

We are going to find big number among three numbers. The program for it.
#include <stdio.h> 
int main()
{
     int a,b,c;
     printf("enter a:");
     scanf("%d",&a);
     printf("enter b");
     scanf("%d",&b);
     printf("enter c");
     scanf("%d",&c);
     if(a>b)
     {
         if(a>c)
         {
             printf("a is big");

         }
         else
         {
             printf("c is big");

         }
     }
     else
     {
         if(b>c)
         {
             printf("b is big");
         }
         else
         {
             printf("c is big");
         }
     }
    return 0;
}
In the above program has been written in c language. It uses the method of nested if statement.  First a is greater than b is executed if it is true then it check for the second condition whether the second condition is true or not false. If it also true a is declared as big number. If the second condition is false then c is declared as big number .if the first condition is false then it comes to else part.  It also checks another condition. If it is true then b is declared as big number. If it is false then c is declared as big number.
                    Will continue
                                                                                Muthu karthikeyan,Madurai.
                                                     contact:919629329142
                                                          Email:muthu.vaelai@gmail.com. 

Elements of programming-4

 






If statement.
It is a conditional statement. It conditionally executing a branch of statements .There are different types of if statement.
1.       simple if
2.       if-else
3.       if-else if-else
4.       switch statement.
Simple If statement:
A relational expression is checked. If the condition is true a block of coding will be executed.if  it returns false the block of coding will not get executed.


For example take the following c program
.
#include<stdio.h>
#include<conio.h>
void main()
{
int mark;
Clrscr();
printf(“enter your score”);
scanf(“%d”,&mark);
printf(“your score is %d”,mark);
if(mark>=90)
{
printf(“excellent”);
}
getch();
}
Program explanation:

The above program asks the score as input. It prints your  mark.if your mark>=90 then it additionally prints the output excellent.

If—else
In this case a relational expression is tested .if the result is true then a block of coding will be executed.if it returns false another block of coding will be executed.

#include<stdio.h>
#include<conio.h>
void main()
{
int mark;
Clrscr();
printf(“enter your score”);
scanf(“%d”,&mark);
printf(“your score is %d”,mark);
if(mark>=40)
{
printf(“pass”);
}
Else
{
Printf(“fail”);
}
getch();
}

Program explanation:
In the above c program mark is input. If it is greater than or equal  to 40 result is printed as false.
If the mark<40 else part will be executed  and printed as fail


                                                --------to be continued
                                                                muthu karthikeyan madurai

Saturday, August 29, 2020

c# introduction-2

 



What is c#?
C#-pronounced as c sharp-is specially created for Dot net.
It is an object oriented language.
It is a modern language
It is easy to learn
It is  based on c,c++ languages.
It produces Efficient program
It contains simplicity of vb, powerful of c++, and elegance of java.


What is.NET?

After the invention of internet java was introduced to create web oriented applications. Java was also a successful one. There is no web language for  Microsoft. Then it  introduced web concepts in vb6. It was a failure. So Microsoft introduced dot-net.
Java creators tell like this
“write once in java and run anywhere”
It means java is a portable language. If you write a java program you can run it on any platform with out change. But you can write in any language in dot-net. Yes ,dot-net supports many languages such as c#,vb,c++ and COBOL.
You can write any language in dot-net. First they are compiled and changed in MSIL(Microsoft intermediate language. Then jit compiler runs the il.the il is not like Microsoft java’s class file. You can not read java’s class files. But MSIL  is a separate language. There are even books for MSIL.

Which languages are supported by .NET?
C#
C++
Visual basic
Jscript
And it also supports third party languages like
Cobol
Eiffel
Perl
Python
Small talk
Mercury.

1.       Simple
2.       Speed
3.       Contains a lot of library classes. Common to all languages.
4.       Installation is easy
5.       Low exceptions. 


 what type of applications can be created using .NET?


.NET can be used to creating different type of application. Also a .NET solution can consists of projects written in different languages. For example a vb.net project  can contain a data access component written in c#. This is possible because of inter operability of .NET between projects.

What are Console applications?


Console applications means graphics less applications. Only character will be present. The following statement is the entry point of console applications.
Public static void Main(String args)
The project uses Read,ReadLine, Write,WriteLine methods present in the system.console class.


 what are windows applications?
v

Example for windows application is ms-word. Normally it contain graphics as icon. We may run any commands by just clicking on the icon..Net can be used for creating such applications.
what are windows controls ?
A windows controls can be created using base controls in toolbox. If you have studied active x control creating using vb6 or vc++ it will be very useful to start learning on creating windows controls in .net.
what are web projects?
Web sites can be created using asp.net the server side asp.net engine will convert the asp.net codes in to pure HTML codes. The browser will execute the HTML code and display  website.Asp.net is used to create interactive, dynamic web sites.
what are Web services
The web services provide information to other web sites. For examples a website can get information such as climate, business news from web services. The main aim of the .Net is providing the software as services.



C# and dot-net.
 C# is a language invented specially  for dot-net. Dot-net developers always choose c# language for their programs. C# 8.0 is the recent version c#

c sharp introduction-1

 




What is c# pronunciation?

C sharp

Which company is it belongs  to?

Micro soft

What is speciality of csharp?

The first thing is it is object oriented language and it is also called as component oriented language. It combines the computing power of c++ with the programming ease of visual Basic. C# is designed to work with  Microsoft .NET(pronounced as Dot Net)

What is object oriented programming?

Object oriented programming(oop) refers to a type of computer programming in which programming defines not only the data type of a data structure. but also the types operations (Functions also called as mehods) that can  be applied to the data structure. so the data structure becomes  an object that includes both data and functions . programmer can also create relationship between data and functions.
What are the important topics in object oriented programming?
 

Class.
Object
Encapsulation
Abstraction
Inheritance.
Polymorphism

What is a class?

It is a collection of objects having similar properties are  Attributes of an object .Events are the actions done by user on object.class ‘s data is represented by its fields and behavior is represented by its methods

Why we need to create objects?

Class is just a template .It can be also compared with blueprint of a building. We need to create objects using this template  just as buildings arebbuilt by using blue print.
oops concepts



Applications written in c# requires the .NET framework to be installed to run the application.
C# does not  offer global variables or function. Every think is wrapped in the classes.



Encapsulation:

Binding code and data together into a single unit is known as encapsulation. Take a  television  to watch the programs on tv users should only do the action like on, off or mute etc .But internal details of electricity circuit are hidden from the user. It is called encapsulation. That means end users should only call the methods to work with data. Data should not be directly handles from the end user.

Abstraction:

Hiding internal details and focusing only essential functionality is known as abstraction .For example  to create  student class there may be many properties but we focus only on student no, sname, mark etc.

Inheritance:

When one object acquires all the properties and behaviors of parent objects is known as inheritance.
Inheritance is the mechanism by which one object requires some/all properties of another object.

Polymorphism: 

1.       Polymorphism means to process objects differently based on their type.
2.       Multiple methods can have same name but which implementation to be used is decided at runtime depending upon  the situation.

o.k oops concepts over. But note one thing c# is called as component oriented application .

what is component oriented language?
A software is divided in to no of component is developed and then joined. For example we know that there is a spell checker in Ms-word. It is a separate component developed separately and made  to work with ms-word .In available languages  c# is the best component oriented language.
                                                       
-------will   continue(Muthu karthikeyan,madurai)
contact :91 96293 29142

Elements of programming ----3

 




            

Operators:

 

Types of operator:


Arithmetic operator
Short hand assignment operator
Increment /decrement operator
Relational operators
Logic operator
Ternary operator

Arithmetic operator:

+, -, *, /, %
Plus, minus, multiplication, division         
First three are same as mathmetical  operations.
Fourth division operation is different. i.e if we divide a int by another int result is integer only
For example
13/5=2 is the result. Decimal portions were removed
If at least any one is float or double the result is float
For example:
13.0/5=2.6
13/5.0=2.6
13.0/5.0=2.6
o.k then what about % operator? do you think that it is percentage calculating operator?
No
It is called as modulus operator.
That is one integer is divided by another integer .it returns remainder value
Example : 13/5=3.
In c , c++   modulus  operations are performed on Integer type only. In advanced languages like java, c sharp,vb.net modulus operator is also can be used also on float and double.

Short hand Assignment operator:


a=a+5 can be also written as a+=5
a=a-5 can be also written as a-=5
It totally applied for all 5 types of arithmetic operator.
Increment/decrement operator:
++,--
a=10;
a++;
now a value will be eleven because ++ operator increases the value by one
also ++a will increment the values by one.
Next:
--
It is called as decrement operator.
a=10;
a--;
now q value be only nine. because decrement operator wil decrement by . one
and  --a  may also decrement the value by one.
But in order of execution ++a(pre increment operator )has order of process high in a mathematical expression is high. but a++ (post decrement operator).has low precedence. It also applies to decrement operator.

Relational operator:


It is used for comparing one value with other value. it returns only true or false value
<  less  than
<=less  than or equal to
> greater than
>=greater than or equal to
==equals to(note there are two = symbols
!=not equal to
Examples:
a=10;
b=5;
c=15;
d=10;
a>b   ----true
a>c-----false
a==d—true
a!=d---false
logical operators:
compare two or more relational expression. It also returns true or false value
&&,||,!
&&---(and) both side of relational expression must be true.
||-(or)at least one side of expression must be true.
!-it inverts the results (if the result is true  then the result is false and vice-versa
Examples:
(a>b)&&(a>c)
(a>b)||(a>c)
!(a>b)

Ternary operator:

Make a relational expression execution . if the expression returns true a value will be returned , if the result is false b value will be returned.

Syntax:

(a>b)?a : b;
a=10;b=5;
big=(a>b)?a:b;
First the comparison(a>b) returns true so a value(i.e 10) will be returned to big.

 contact:  91 96293 29142

Muthu karthikeyan, Madurai

Elements of programming-2

 







constants:
constants are also memory locations like variables but their values that can not be changed through out the program. only initial assignment is considered. most of the programming languages use const keyword to define constant.
Example:
const float PI=3.14;
some language also # define keyword to define a constant
Datatypes:
when we declare a variable at first time we should tell the compiler what type of data we are going to store.
it may be integer, floating point numbers or char. advanced language also have string type. following are thre primarydata types:
int
float
double
char:


int:
int means integer which indirectly means whole numbers. usually c,c++ int data type takes 2 bytes of memory. but modern c,c++ and alsoc#,java ,vb.net take 4 bytes of memory. modified long int data type take 8 bytes of memory in all modern languages.
float & double:
both are used to store floating point numbers.float data types takes only 4 bytes. double data type takes 8 bytes memory.if you want accuracy you are recommended to choose double data type.
char:
it takes 2 bytes of memory in java & c# because it follows unicode method to store data. it can store only one character .some basic languages uses array of characters to store more than one character.char data type is actually treated internally as char data type.
String:
modern languages like java and c# uses string data type to store more than one character. while char type data are put in to single quotes, string datas are put into double quotes.


contact :919629329142






Friday, August 28, 2020

Elements of programming-1:

 





This series is going to contain fundamentals of programming. it applies to all the major programming languages.
Variables

Variables are name of memory location. If we want to store any kind of data in memory it has to be  named.  Before using a variable it has to declared that what kind of data we are going store in that variable(int, float or char). In c language any variable declarations must be the first statement in main function.  Advanced languages(c++, java,c#) allow variables to be declared at any line .

Compiler:

In a program what we write are called as high level languages. It  can not be understandable by a computer. It has to be translated in to machine language(0 or 1). That job is done by compiler. So compilers are the software which translate high level language into machine level language.

Interpreters

Interpreters do the same work as compiler. The primary difference between compiler and interpreter is interpreters compile the program line by line where as compiler compiles the whole program at once.

Comments:
Comments are used for documentation purposes. It will be ignored by the compiler.
Single line  comments starts with //.
Multi line comment start with /* and ends with */.
Examples:
//this is a single line comment.
/*this is a
Multiline comments*/

IDENTIFIER

An identifier is the name given to the programming elements such as variable,method,class and objects.
There are some naming rules:
It can contain alphabets, digits and underscore(_)
Special characters other than underscore are not allowed.
Spaces not allowed in a identifier.
It should not be a keyword.

Key words:

Every language contain keywords which has a special meaning to the compiler. We can not use it for another purposes.for example we can not use it for naming an identifier
Example for keywords:
Int, do, while,for,if
     To be continued(MUTHUKARTHIKEYAN,MADURAI)