Tuesday, 14 January 2014

Explain Input and Output function in C



I/O function

Input function-A program takes data through input function.
Output function-A program displays result on screen through output function

2 Types

a)  Formatted b) Unformatted function

Formatted function-It read and write all types of data types.

2 Types

a) printf( ) b) scanf( )

printf() statement-It prints data values to the console.It need conversion symbols to print  variable values.Here escape sequence \n is used for new line.

scanf() statement-It reads data values.It need conversion symbols to read variable values.
The '&' address operator is used to indicate memory location of variable,so that value read should be placed in that location.

Unformatted function-It work with only character data type.
 Types
(a) getchar( ) (b) putchar( ) (c) getch( ) (d) getche ( ) (e) gets( ) (f) puts( )

Friday, 10 January 2014

Explain arithematic operator in C

binary arithmetic operator-This is used for calculation between two constant values.They are +,-,*,/,%.
unary arithmetic operator-This is used for calculation with one value.They are unary minus(-),increment(++),decrement(--),address operator(&),sizeof.

Write a program to show effect of increment operator as a prefix and suffix.

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,x=10,y=20;
clrscr();
a=x * ++y;  /* increment as prefix,here  value of y is increased  and then used for multiplication*/
c=x*y;
b=x * y++; /*increment as suffix,here  after multiplication y is increased */
d=x*y;
printf(" \n %d %d ",a,c,b,d);
}

output


210 210 200 210

address (&) operator-It prints address of variable in memory.
sizeof() operator-It gives bytes occupied by variable.

Write a program to use address (&) operator and sizeof() operator.


#include<stdio.h>
#include<conio.h>
main()
{
int x=2;
float y=2;
clrscr();
printf("\n sizeof(x)=%d bytes,sizeof(y)=%d bytes ",sizeof(x),sizeof(y));
printf("\n Address of x=%u,Address of y=%u",&x,&y);
}


output
sizeof(x)=2,sizeof(y)=4
Address of x=4066,Address of y=25096

Explain variable in C

Variable
A variable is a data name used for storing a data value.
Its value may change during execution.
It should not be a C keyword.
It may be a combination of uppercase and lowercase characters.
Ex-
sUm and SUM both are different.
It should start with a character not a digit
Declare variable
Its declaration should be done in declaration part of C program because it helps in allocating memory.
Syntax-
datatype variablename;
ex-
int age;
int a,b,c;
Initialize variable
Initialization and declaration of variable can be done in same line.
syntax-
datatype varaible = constant;
ex-
int y=2;
Constant variable
To make value of variable constant use keyword const before declaration
ex-
const int m=1;

Monday, 6 January 2014

Explain data types in C

Data types 
They are used to define  variables before its use.As per need different data types are used in C.
For example
a)int is used to define integer numbers
{
int count;
count=4;
}
b)float is used to define floating point numbers
{
float miles;
miles=5.6;
}
c)double is used to define big floating point numbers,it reserves twice the storage for numbers.
{
double atoms;
atoms=25000;
}
d)char defines character
{
char letter;
letter='c';
These are common data types.Others are short,long,signed,unsigned.
short int<int<long int
float<double<long double
signed and unsigned
when a variable is declared as unsigned then negative range of data type is declared as positive.
example
unsigned long int c;
Memory size of different data types
short integer occupies memory of 2 bytes
long integer occupies memory of 4 bytes
signed and unsigned integer occupies memory of 2 bytes
float occupies memory of 4 bytes
double occupies memory of 8 bytes
character occupies memory of 1 byte

Friday, 13 December 2013

How to insert data with query into table in visual studio using c#?

Firstly select the option new query from tables.


 Then a tab displays on screen from that click add and close the tab.


Then write the code for inserting data into table.

Execute SQL by clicking the symbol ! on top.

Then you can see the label one row affected.So SQL query is executed.
See data by clicking option"show table data"



Thursday, 12 December 2013

How to create a database with tables to store inputs in visual studio using c#

Take the option server explorer from  view.
On top of data connections click the image with label "connect to database".
Then you can view a tab where we have to fill database new or existing with a new name like "dbs" or any other name.

Then you can see dbs.mdf symbol,which shows database is created.
Click it and you can see many options from that select option "Tables".

From Tables click option "add new table".


Then a  tab comes where you can fill the table details.
Here you have to select the apt data type for each column.


Thursday, 5 December 2013

How to add image into a webform in visual studio using c#.





Firstly add image by clicking the option "add existing item" from the website "demo"(can give any name) on solution explorer.
Then we can select any image from computer and add it in solution explorer.
From toolbox then select "image " into web form demo1.
Then change properties of it where imageurl option is to be changed by adding image.
web form demo1 in website demo
Clicking option add existing item from website demo
Here remember to change file name to all files and select any image
Now add image from toolbox to webform like this

select image and change property by adding image into  image url like this
image added