You are on page 1of 6

Computer A computer is an electronic device that receives input, manipulates it, and provides output in a useful format.

Computer Language A way of communication between people and computer. Category : (1) Low-level Language (a)Machine Language : - It is lowest-level programming language which is directly executated by a computer's CPU . Its code is written in binary form 0 and 1 . Examples ARM , Motorola 6800 , Intel 8086 . (b) Assembly Language:- To write any program in 0 and 1 form is very difficult thus some symbols are used instead of these 0 and 1. These symbols are called mnemonics . Thus program written in mnemonics is called assembly language. Examples -Flat Assembler , Basic AssembLer , GNU Assembler , Borland (2) High-level Language High level languages are in which it is much easier to write a program than the low level language. These languages require translators (compilers and interpreters) for execution. Examples C ,C++ , Java, Java script . .. .. .. .. ..

C Language C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.It was derived from another language BCPL . Its first version was B (First letter of BCPL) . Later it was modified and named as C (Second letter of BCPL) .It is a procedural programing language.

Fundamentals of C (1) Keywords :Words whose meaning are fixed and they are already known by compiler . C has 32 keywords . Examples int , float , if , else, then , long , break , continue , default ... .. . (2) Identifiers : Names of variables are known as identifiers.

(3) Constants :Any unchanged value in program is called constant.it contains Integer constant (no fractional value) Real or float constant (with fractional value) Character constant (Any string enclosed in apostrophes) (4) Data Types :Data types are used to store various types of data that is processed by program. It is of three types Primary () Derived () User-defined () (5) Operators :An operator is a symbol that tells computer to perform certain manipulations. Mainly these are Arithmetic (+ , - , / , * , %) Relational (< , > , =) Logical (&& , || )

Function A function is a block of statements that performs similar type of task . Prototype function ( type of parameter) function (arguments); prototype function (parameters with type) { Statement 1; Statement 2; } y y y //function declaration // Function is called

//Function is defined

y y y y y y

Prototype is type of function it may be void , int ,float. By default function is declared as int. Name of variable whose values changes at each execution known as parameter and value given to this parameter at a particular execution is known as argument. There are two types of functions . Liberary Function (already written in compiler like printf(),scanf() ) UserDefined Function (defined by user like show() , pass() ). Any C program contain atleast one function known as main() function main() function is responsible for calling all other functions. Whenever any function is called control is transferred to it from main() function and returned back when its task finished. Function can be called from other function but can not be defined in another function. A function can call itself such a function is known as recursion . Example main() { int a,b,sum; int function (int,int); printf(Enter two numbers ); //main function scanf(%d%d,&a,&b); sum=function(a, b) printf(sum is %d,sum); } int function (int x,int y) { int z = x + y; return(z); }

//sum function

y y y y y

y
y

In program a , b are actual arguments and variable x , y are formal arguments. We cant use a , b in function sum .It will be treated there as different variable because scope of any variable is local to the function in which it is defined. If we dont want to declare any function then it should be defined before main function so it will run without any error. Each function which is not declared void returns some value , if there is no any return statement then it returns some garbage value. If function doesnt have retutn statement but have a printf function.then it will return number of characters in printf statement rather any garbage value . Example int function() { Printf(hii); } Ans 3 will be return rather any garbage value. All fowolling are valid return statements return(a); , return(23), return;
A function can be called by passing variable(Call by value) or by passing address of variables . As shown below . Example main()

{ int a,b,sum; int function (int *x , int *y); printf(Enter two numbers ); scanf(%d%d,&a,&b); sum=function(&a , & b) printf(sum is %d,sum); }

// main function

int sum(int *x , int *y) { int z = (*x) + (* y); return(z); } y Here & and * are pointer parameters. & (address of variable , it uses %u as format specifier) * (value at address )

//sum function

Using call by refrence we can return more than one value at a time.Which cant be ordinarily. Example main() { int a=10 , b , c ; int show (int x , int *y , int *z); show(a , &b , &c); printf(value of b %d , b); printf(value of c %d , c); }

int show (int x , int *y , int *z) { *y=a+10; *z=a+20; }

#include<stdio.h> #include<conio.h> void main() { clrscr(); int a,factorial(int); printf("Enter any number"); scanf("%d",&a); int var=factorial(a); printf("%d",var); getch();

} int factorial(int x) { int i,f=1; for(i=x;i>=1;i--) f=f*i; return(f); }

. In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code. 2. In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code

Java is a platform independent, object oriented language while C++ is having some of its features from C, which is a procedural language so it is not pure object oriented. Even Java is not 100% pure object oriented. 1. Pointers are supported in C++ while not in Java. The memory management is done automatically with help of part of JVM called Garbage Collector. 2. Multiple inheritance is not supported in Java but supported in C++. 3. There are no structures and unions in Java. 4. There is no scope resolution operator in Java (::). 5. There are no destructors in Java like C++. 6. There is no virtual keyword in Java because all non-static method use dynamic binding

You might also like