Wednesday, 10 May 2017

Program to display ASCII value of any character.

Program

#include<studio.h>
#include<condo.h>
void main( )
{
char ch;
clrscr();
printf("\n enter any character");
scanf("%C",&ch);
printf("%C",ch);
printf("\n ASCII value of character is=%d",ch);

}

Sunday, 7 May 2017

Program to enter any number which is prime.

Program 

#include<studio.h>
#include<condo.h>
void main ( )
{int no,i=2;
printf("\n enter any number");
scanf("%d",&no);
while(i<no)
{
if(no%i==0)
{
printf("\n not a prime number");
break;
}
i++;
}
if(i==no)
printf ("\n prime no");
}

Wednesday, 3 May 2017

Concepts in C ++.

User defined data types 

Structures 
and 
Unions.

Standalone variables of primitive types are not sufficient enough to handle real world problems.
It is often required to group logically related data items together.

Unions are conceptually similar to structures as they allow us to group together dissimilar type elements inside a single unit.
However the size of union is equal to size of its largest number element.
Eg:
 union result
 {
   int marks;
  char grade;
  float percent;
};        


Concepts in C++.

Tokens:

As we know the smallest individual units in a program are called tokens.
C++has following tokens:

1.Keywords
2.Identifiers
3.Constants
4.Strings
5.Operators

A  C++ program is written using these tokens ,white spaces and the syntax of the language.Most of C++ tokens are basically similar to C tokens with the exception of some additions and minor modifications .


Data abstraction and encapsulation.

Data abstraction and encapsulation.

The wrapping up of data and functions into a single unit is called as encapsulation.
Data encapsulation is the most striking feature of class.
The data is not accessible to the outside world, and only those functions which are wrapped in a class can access it.
These functions provide an interface between object data and programmer.
This insulation of data from direct access by the program is called Data hiding or information hiding.


Abstraction 

refers to the act of representing essential features without including the background details or explanation .
Classes use the concepts of abstraction and are defined as list of abstract attribute such as size,weight and cost, the functions to operate on these attributes.
They encapsulate essential properties of objects that are to be created.
The attributes are some time called Data members because they hold information.
The functions that operates on these data are called member functions.

Operators .

Operators in C:

Operators are sign which performs some operation on operands.

Categories of operators:

1.Unary
It takes single operand.

2.Binary
It takes two operands.

3.Ternary
It takes three operands.

4.Bitnary
It takes more than 3 operands.

Types of operators in C

1.Arithmetic operators

(- unary ,+,*,%,/ all binary)

2.Releational operators(binary)

(>,<,>=,<=,==,!=)
All relational operators compare 2 values and return boolean value.

3.Logical operators 

&& AND operator (binary)
        OR operator (binary)
!     NOT operator (unary)

4.Increment/Decrement operator 

++X or --x prefix 
X++or x--postfix

5.Assignment operator

=, +=, -=, /=, *=(shorthand assignment operator)

=  (Bitwise assign operator)

6.Conditional operators (Ternary)

?:

             

/*Program to display tables of all number between range*/

Program:

#include<studio.h>
#include<conio.h>
void main( )
{ int lb,ub,i;
clrscr( );
printf ("\n enter lb and ub");
scanf ("%d%d",&lb,&ub);
{
for(i=1;i<=10;i++)
{
printf ("%d",lb*i);
}
printf ("\n");
}
}

Program to check no is Armstrong or not.

#include<studio.h>
void main( )
{ int no,sum =0,r,x;
printf ("\n enter no ");
scanf("%d",&no);
x=no;
while (no>0)
{
r=no%10;
sm=sm+(r*r*r);
no=no/10;
}
if(sum==x)
{
printf("\n It is Armstrong no");
}
else
{printf(" not Armstrong no");
}

Computer language

Computer language is a way of communication between the user and computer.

1.Low level language:

Here, we can directly interact with hardware.
It does not require any compiler and is tough in Learning due to it's complex syntaxes.

Eg: Assembly language for CPU.
         Machine language.

2.Middle level language:

We can write programming of both low level as well as high Level language.

Eg: C and C++.

3.High level language:

It requires compiler to convert high level into low level language.
It is very easy in learning due to its easy syntaxes.

Eg: BASIC, COBOL, Fortran etc.


Tuesday, 2 May 2017

C language

Compiler

It is a software which converts high level Lang or the source code in low level Language i.e, machine code and this procedure is called compilation.

Program to display ASCII value of any character.

Program #include<studio.h> #include<condo.h> void main( ) { char ch; clrscr(); printf("\n enter any character...