C # is executed when converted into a language understood by target operating system.This code is called native code.This compilation is a two stage process.When code using .net framework is compiled first,it is converted into (microsoft intermediate language code)MSIL.This comiplation is done by VS.Just In Time compiler compiles MSIL into native code.Here MSIL is independent of machine,OS,CPU.
Tuesday, 4 March 2014
How C# is executed?
C # is executed when converted into a language understood by target operating system.This code is called native code.This compilation is a two stage process.When code using .net framework is compiled first,it is converted into (microsoft intermediate language code)MSIL.This comiplation is done by VS.Just In Time compiler compiles MSIL into native code.Here MSIL is independent of machine,OS,CPU.
Explain visual studio with features.
It is the environment which support many languages like c#,c++,visual basic etc. and with ease .net features can be integrated into your code.
The code created will be entirely C# but will use .net framework and you can make use of additional tools in VS when necessary.
Main features of VS is -
Main window contain a start page by default when VS is started.It is the place where all codes will be displayed.
Toolbars is above the main window.It is pops up when mouse mouse over it.Its function range from saving and loading files to building and running projects to dubbing projects.
Server explorer is selectable via View->server explorer from menu option.It provide access to data sources,server settings,services etc.
Solution explorer is selectable via View->solution explorer from menu option.
It displays various view of projects in a solution ie,what files they contain and what is contained in those files.
Properties window is selectable via View->properties window from menu option.It provide detailed view of contents in a project and allow to perform additional configuration of individual elements.
Error list window is selectable via View->Error list menu option.It displays error,warning and other information related to projects.It updates continuously,although some information will appear only when a project is compiled.
The code created will be entirely C# but will use .net framework and you can make use of additional tools in VS when necessary.
Main features of VS is -
Main window contain a start page by default when VS is started.It is the place where all codes will be displayed.
Toolbars is above the main window.It is pops up when mouse mouse over it.Its function range from saving and loading files to building and running projects to dubbing projects.
Server explorer is selectable via View->server explorer from menu option.It provide access to data sources,server settings,services etc.
Solution explorer is selectable via View->solution explorer from menu option.
It displays various view of projects in a solution ie,what files they contain and what is contained in those files.
Properties window is selectable via View->properties window from menu option.It provide detailed view of contents in a project and allow to perform additional configuration of individual elements.
Error list window is selectable via View->Error list menu option.It displays error,warning and other information related to projects.It updates continuously,although some information will appear only when a project is compiled.
How to write applications using .net framework.
Writing application means writing code on any language(like C#,C++,VB,J# etc,,) that support .net framework using .net code library.
Explain .net framework.
It is a software framework.It is developed by microsoft.It runs on microsoft windows operating system.It was released on 2002.It has library of codes which consist of different modules which can be used from any language(like C++,C#,VB,J SCRIPT etc) to create applications(like WEB,WINDOWS,CONSOLE,WEB SERVICES etc) without any restriction.You can use portions of it depending on results you want to achieve.
Friday, 28 February 2014
Explain types of function with example.
Types of function
1)without arguments and return values-Here neither the data is passed from calling function nor the data is sent back from called function.
The function is executed,they print result in same block.Such type is used for printing messages,drwa a line or split line etc.
Write an example of function without argument and return values.
#include<stdio.h>
#include<conio.h>
void main()
{
void a(),b(),c();
a(); //Here main() function calls 3 functions//
b();
c();
}
void a()
{
printf("\n A");
}
void b()
{
printf("\n B");
}
void c()
{
printf("\n C");
}
Output
ABC
2)with arguments but without return values-The arguments are passed to the called function,but no result is sent back.
write an example of function with arguments and no return values.
#include<stdio.h>
#include<conio.h>
main()
{
int datee(int,int,int);
int d,m,y;
clrscr();
printf("Enter date:");
scanf("%d \t %d \t %d",&d,&m,&y);
datee(d,m,y);
return 0;
}
datee(int x,int y,int z)
{
printf("Date=%d/%d/%d",x,y,z);
}
Output
Enter date:11 2 2013
Date=11/2/2013
3)with arguments and return values-The arguments are passed to called fucntion and result is sent back to calling function.
write an example of function with arguments and return value.
#include<stdio.h>
#include<conio.h>
main()
{
int datee(int,int,int);
int d,m,y;
clrscr();
printf("Enter date:");
scanf("%d \t %d \t %d",&d,&m,&y);
t=datee(d,m,y);
printf("Tomorrow=%d/%d/%d",t,m,y);
return 0;
}
datee(int x,int y,int z)
{
printf("Today=%d/%d/%d",x,y,z);
return(++x);
}
Output
Enter date: 12 2 2013
Today=12/2/2013
Tomorrow=13/2/2013
4)without arguments and with return values-No arguments are passed to called function,but called function returns values.
It reads values from keyboard.
write an example of function without arguments and with return values.
#include<stdio.h>
#include<conio.h>
main()
{
int sum,s
clrscr();
s=sum();
printf("\n Sum=%d",s);
}
sum()
{
int x,y,z;
printf("\n Enter 3 values:");
scanf("%d %d %d",&x,&y,&z);
return (x+y+z);
}
Output
Enter 3 values: 3 4 5
Sum=12
Explain return statement with example.
Return statement
Itis used to return value to calling function.
It is used for exit from called function to calling function.
When it is executed it always returns 1.
Absence of return statement indicates no value is returned.Such functions are called void.
Next statement following return statement willnot be executed.
The return statement can be used in different ways-
return;
It returns always 1
return(expression);
example-
return(a+b+C)
if such a statement is executed then expression within parenthesis is first solved and result obtained is returned.
Multiple return statement within a function-
example-
if(a>b)
return a;
else
return b;
return(&p)-It returns address of the variable.
return(*p)-It returns value of variable through pointer.
return NULL-It return NULL value.
Write a program to show return statement in different ways.
#include<stdio.h>
#include<stdio.h>
main()
int pass(int);
int x,y;
clrscr();
printf("Enter value of x:");
scanf("%d",&x);
y=pass(x);
switch(y)
{
case 1:
printf("Returned value is %d",y);
break;
default:
printf("Cube of x is %d",y);
}
return NULL;
}
pass(a)
{
if(a==0)
return;
else
return(a*a*a)
}
Output
Enter value of x:5
Cube of x is 125
Itis used to return value to calling function.
It is used for exit from called function to calling function.
When it is executed it always returns 1.
Absence of return statement indicates no value is returned.Such functions are called void.
Next statement following return statement willnot be executed.
The return statement can be used in different ways-
return;
It returns always 1
return(expression);
example-
return(a+b+C)
if such a statement is executed then expression within parenthesis is first solved and result obtained is returned.
Multiple return statement within a function-
example-
if(a>b)
return a;
else
return b;
return(&p)-It returns address of the variable.
return(*p)-It returns value of variable through pointer.
return NULL-It return NULL value.
Write a program to show return statement in different ways.
#include<stdio.h>
#include<stdio.h>
main()
int pass(int);
int x,y;
clrscr();
printf("Enter value of x:");
scanf("%d",&x);
y=pass(x);
switch(y)
{
case 1:
printf("Returned value is %d",y);
break;
default:
printf("Cube of x is %d",y);
}
return NULL;
}
pass(a)
{
if(a==0)
return;
else
return(a*a*a)
}
Output
Enter value of x:5
Cube of x is 125
Use of Local and global variable in function with example
Local and global variable
Local variable is defined within the body of the fucntion.Other function cannot access these variables.
Global variables-These are defined outside main () fucntion.Mulitiple functions can use them.
Write a program to show local variables.
#include<stdio.h>
#include<conio.h>
main()
{
int a=10,b=20;
clrcsr();
printf("a=%d , b=%d",a,b);
}
func()
{
int a=20,b=10;
printf("a=%d b=%d",a,b);
}
Output
a=10,b=20
a=20,b=10
//here variable a and b are defined in both functions,There effect is only within the function in which they are defined//
Write a program to show global variables.
#include<stdio.h>
#include<conio.h>
int a =10,b=10;
main()
{
clrcsr();
printf("a=%d , b=%d",a,b);
func();
printf("a=%d , b=%d",a,b);
}
func()
{
a++;
b--;
}
Output
a=10 ,b=10
a=11 ,b=9
Local variable is defined within the body of the fucntion.Other function cannot access these variables.
Global variables-These are defined outside main () fucntion.Mulitiple functions can use them.
Write a program to show local variables.
#include<stdio.h>
#include<conio.h>
main()
{
int a=10,b=20;
clrcsr();
printf("a=%d , b=%d",a,b);
}
func()
{
int a=20,b=10;
printf("a=%d b=%d",a,b);
}
Output
a=10,b=20
a=20,b=10
//here variable a and b are defined in both functions,There effect is only within the function in which they are defined//
Write a program to show global variables.
#include<stdio.h>
#include<conio.h>
int a =10,b=10;
main()
{
clrcsr();
printf("a=%d , b=%d",a,b);
func();
printf("a=%d , b=%d",a,b);
}
func()
{
a++;
b--;
}
Output
a=10 ,b=10
a=11 ,b=9
Subscribe to:
Posts (Atom)