ABC

27Jun10

hello……………..


Share BCA was just an idea emerged out of my head when i was appearing for my FYBCA University examination.

At that time i was in need of Question papers and notes for better perfomance in xamination. But I couldnt find any Domain who could fulfill my needs..

So at that time it was my dream to set-up the Domain which could provide everything that a BCA Student is in need of And look at 2day that little idea got a Huge success my Dream came into existence ….

I would say that initiative that i took was the only root after it and I believe “DONT JUST DREAM BUT MAKE YOUR DREAM SUCCESS AND THAN SHARE IT WITH PEOPLE “………….

People might laugh at your Failure. They wont see how much amount of Trouble you face but what they will notice is “ONE OF YOUR NEGATIVE POINT”. And will try to demoralize you which i experienced in FY, SY and will be experiencing in TY too…Some people called it “Waste of time”, “non-sense” ,”Cheap Marketing”, “Spoiling the students” etc etc

But that “DEMORALIZATION” makes my dream more stronger, more powerful and gives me strength to prove myself………

Now i have another dream to prove……..Wish me a luck Friends….


this is calculator


Code for calculator is

<html>
<body>
<table>
<form name=”b”>
<tr>
<td colspan=”3″ align=”center”><input type=”text” name=”a” >
<tr><td><input type=”button” value=” 1 ” onClick=”document.b.a.value+=1″><td><input type=”button” value=” 2 ” onClick=”document.b.a.value+=2″><td><input type=”button” value=” 3 ” onClick=”document.b.a.value+=3″></tr>
<tr><td><input type=”button” value=” 4 ” onClick=”document.b.a.value+=4″><td><input type=”button” value=” 5 ” onClick=”document.b.a.value+=5″><td><input type=”button” value=” 6 ” onClick=”document.b.a.value+=6″></tr>
<tr><td><input type=”button” value=” 7 ” onClick=”document.b.a.value+=7″><td><input type=”button” value=” 8 ” onClick=”document.b.a.value+=8″><td><input type=”button” value=” 9 ” onClick=”document.b.a.value+=9″></tr>
<tr><td><input type=”button” value=” 0 ” onClick=”document.b.a.value+=0″><td><input type=”button” value=” + “onClick=”document.b.a.value+=’+'”><td><input type=”button” value=” – “onClick=”document.b.a.value+=’-'”></tr>
<tr><td><input type=”button” value=” /  ” onClick=”document.b.a.value+=’/'”><td><input type=”button” value=” * ” onClick=”document.b.a.value+=’*'”><td><input type=”button” value=” = ” onClick=”document.b.a.value=eval(document.b.a.value);”>
<tr><td><input type=”reset” value=” C ” ><td>
</table>
</body>
</html>

In this tutorial you will learn about C Programming – Decision Making, Branching, if Statement, The If else construct, Compound Relational tests, Nested if Statement, The ELSE If Ladder, The Switch Statement and The GOTO statement.

Branching

The C language programs presented until now follows a sequential form of execution of statements. Many times it is required to alter the flow of the sequence of instructions. C language provides statements that can alter the flow of a sequence of instructions. These statements are called control statements. These statements help to jump from one part of the program to another. The control transfer may be conditional or unconditional.

if Statement:

The simplest form of the control statement is the If statement. It is very frequently used in decision making and allowing the flow of program execution.

The If structure has the following syntax

if (condition)

{

statement;

}

The statement is any valid C’ language statement and the condition is any valid C’ language expression, frequently logical operators are used in the condition statement. The condition part should not end with a semicolon, since the condition and statement should be put together as a single statement. The command says if the condition is true then perform the following statement or If the condition is fake the computer skips the statement and moves on to the next instruction in the program.

Example program


# include <stdio.h> //Include the stdio.h file

void main () // start of the program

{

int numbers;   // declare the variables

printf ("Type a number:");  // message to the user

scanf ("%d", &number);  // read the number from standard input

if (number < 0)  // check whether the number is a negative numbe

number = -number ;  // if it is negative then convert it into positive

printf ("The absolute value is %d \n", number);  // print the value

}

The above program checks the value of the input number to see if it is less than zero. If it is then the following program statement which negates the value of the number is executed. If the value of the number is not less than zero, we do not want to negate it then this statement is automatically skipped. The absolute number is then displayed by the program, and program execution ends.

The If else construct:

The syntax of the If else construct is as follows:-

if (condition)

{

statement;

}

else

{

statement;

}

The if else is actually just on extension of the general format of if statement. If the result of the condition is true, then program statement 1 is executed, otherwise program statement 2 will be executed. If any case either program statement 1 is executed or program statement 2 is executed but not both when writing programs this else statement is so frequently required that almost all programming languages provide a special construct to handle this situation.

Sample Code


#include <stdio.h>  //include the stdio.h header file in your program

void main ()   // start of the main

{

int num ; // declare variable num as integer

printf ("Enter the number") ; // message to the user

scanf ("%d", &num) ;  // read the input number from keyboard

if (num < 0)   // check whether number is less than zer
{
printf ("The number is negative") ;  // if it is less than zero then it is negative
}
else  // else statemen
{
printf ("The number is positive")  // if it is more than zero then the given number is positive
}
}

In the above program the If statement checks whether the given number is less than 0. If it is less than zero then it is negative therefore the condition becomes true then the statement The number is negative is executed. If the number is not less than zero the If else construct skips the first statement and prints the second statement declaring that the number is positive.

Compound Relational tests:

C language provides the mechanisms necessary to perform compound relational tests. A compound relational test is simple one or more simple relational tests joined together by either the logical AND or the logical OR operators. These operators are represented by the character pairs && // respectively. The compound operators can be used to form complex expressions in C.

Syntax

a> if (condition1 && condition2 && condition3)

b> if (condition1 // condition2 // condition3)



The syntax in the statement ‘a’ represents a complex if statement which combines different conditions using the and operator in this case if all the conditions are true only then the whole statement is considered to be true. Even if one condition is false the whole if statement is considered to be false.

The statement ‘b’ uses the logical operator or (//) to group different expression to be checked. In this case if any one of the expression if found to be true the whole expression considered to be true, we can also uses the mixed expressions using logical operators and and or together.

Nested if Statement

The if statement may itself contain another if statement is known as nested if statement.

Syntax:

if (condition1)

if (condition2)

statement-1;

else

statement-2;

else

statement-3;



The if statement may be nested as deeply as you need to nest it. One block of code will only be executed if two conditions are true. Condition 1 is tested first and then condition 2 is tested. The second if condition is nested in the first. The second if condition is tested only when the first condition is true else the program flow will skip to the corresponding else statement.

Sample Code


#include <stdio.h> //includes the stdio.h file to your program

main () //start of main function

{

int a,b,c,big; //declaration of variables

printf ("Enter three numbers"); //message to the user

scanf ("%d %d %d", &a, &b, &c); //Read variables a,b,c,

if (a > b) // check whether a is greater than b if true the

if (a > c) // check whether a is greater than

big = a ;// assign a to big

else big = c; // assign c to big

else if (b > c) // if the condition (a > b) fails check whether b is greater than

big = b; // assign b to big

else big = c ;// assign c to big

printf ("Largest of %d, %d & %d = %d", a,b,c,big) ;//print the given numbers along with the largest number

}

In the above program the statement if (a>c) is nested within the if (a>b). If the first If condition if (a>b)

If (a>b) is true only then the second if statement if (a>b) is executed. If the first if condition is executed to be false then the program control shifts to the statement after corresponding else statement.

Sample Code


#include <stdio.h> //Includes stdio.h file to your program

void main () // start of the program

{

int year, rem_4, rem_100, rem_400; // variable declaration

printf ("Enter the year to be tested"); // message for user

scanf ("%d", &year) ;// Read the year from standard input.

rem_4 = year % 4 ;//find the remainder of year by 4

rem_100 = year % 100; //find the remainder of year by 100

rem_400 = year % 400 ;//find the remainder of year by 400

if ((rem_4 == 0 && rem_100 != 0) rem_400 == 0)

//apply if condition 5 check whether remainder is zer

printf ("It is a leap year. \n") ;// print true condition

else

printf ("No. It is not a leap year. \n") ;//print the false condition

}

The ELSE If Ladder

When a series of many conditions have to be checked we may use the ladder else if statement which takes the following general form.

Syntax

if (condition1)

statement – 1;

else if (condition2)

statement2;

else if (condition3)

statement3;

else if (condition)

statement n;

else

default statement;

statement-x;

This construct is known as if else construct or ladder. The conditions are evaluated fromthe top of the ladder to downwards. As soon on the true condition is found, the statement associated with it is executed and the control is transferred to the statement– x (skipping the rest of the ladder. When all the condition becomes false, the final else containing the default statement will be executed.

* Example program using If else ladder to grade the student according to the following rules.

Marks Grade
70 to 100

60 to 69

50 to 59

40 to 49

0 to 39
DISTINCTION

IST CLASS

IIND CLASS

PASS CLASS

FAIL

Sample Cod


#include <stdio.h> //include the standard stdio.h header fil

void main () //start the function main

{

int marks; //variable declaration

printf ("Enter marks\n"); //message to the user

scanf ("%d", &marks); //read and store the input marks.

if (marks <= 100 && marks >= 70) //check whether marks is less than 100 or greater than 7
{
printf ("\n Distinction") ; //print Distinction if condition is True
}
else if (marks >= 60) //else if the previous condition fails Chec
{
printf("\n First class"); //whether marks is > 60 if true print Statement
}
else if (marks >= 50) //else if marks is greater than 50 prin
{
printf ("\n second class"); //Second class
}
else if (marks >= 35) //else if marks is greater than 35 prin
{
printf ("\n pass class"); //pass class
}
else
{
printf ("Fail"); //If all condition fail apply default condition print Fail
}
}
}

The above program checks a series of conditions. The program begins from the first if statement and then checks the series of conditions it stops the execution of remaining if statements whenever a condition becomes true.

In the first If condition statement it checks whether the input value is lesser than 100 and greater than 70. If both conditions are true it prints distinction. Instead if the condition fails then the program control is transferred to the next if statement through the else statement and now it checks whether the next condition given is whether the marks value is greater than 60 If the condition is true it prints first class and comes out of the If else chain to the end of the program on the other hand if this condition also failsthe control is transferred to next if statements program execution continues till the end of the loop and executes the default else statement fails and stops the program.

The Switch Statement:

Unlike the If statement which allows a selection of two alternatives the switch statementallows a program to select one statement for execution out of a set of alternatives. During the execution of the switch statement only one of the possible statements will be executed the remaining statements will be skipped. The usage of multiple If else statement increases the complexity of the program since when the number of If else statements increase it affects the readability of the program and makes it difficult to follow the program. The switch statement removes these disadvantages by using a simple and straight forward approach.

The general format of the Switch Statement is :

Switch (expression)

{

Case case-label-1;

Case case-label-2;

Case case-label-n;

………………

Case default

}

When the switch statement is executed the control expression is evaluated first and the value is compared with the case label values in the given order. If the label matches with the value of the expression then the control is transferred directly to the group of statements which follow the label. If none of the statements matches then the statement against the default is executed. The default statement is optional in switch statement in case if any default statement is not given and if none of the condition matches then no action takes place in this case the control transfers to the next statement of the if else statement.

Sample Code


#include <stdio.h>

void main ()

{

int num1, num2, result ;

char operator ;

printf ("Enter two numbers") ;

scanf ("%d %d", &num1, &num2) ;

printf ("Enter an operator") ;

scanf ("%c", &operator) ;

switch (operator)

{

case '+':

result = num1 + num2 ;

break

case '-':

result = num1 - num2 ;

break ;

case '*':

result = num1 * num2 ;

break ;

case '/':

if (num2 != 0)

result = num1 / num2 ;

else

{

printf ("warning : division by zero \n") ;

result = 0 ;

}

break ;

default:

printf ("\n unknown operator") ;

result = 0 ;

break ;

}

printf ("%d", result) ;

}

In the above program the break statement is need after the case statement to break out of the loop and prevent the program from executing other cases.

The GOTO statement:

The goto statement is simple statement used to transfer the program control unconditionally from one statement to another statement. Although it might not be essential to use the goto statement in a highly structured language like C, there may be occasions when the use of goto is desirable.

Syntax



a>

goto label;

…………

…………

…………

Label;

Statement;

b>

label;

…………

…………

…………

goto label;

The goto requires a label in order to identify the place where the branch is to be made. A label is a valid variable name followed by a colon.

The label is placed immediately before the statement where the control is to be transformed. A program may contain several goto statements that transferred to the same place when a program. The label must be unique. Control can be transferred out of or within a compound statement, and control can be transferred to the beginning of a compound statement. However the control cannot be transferred into a compound statement. The goto statement is discouraged in C, because it alters the sequential flow of logic that is the characteristic of C language.


#include <stdio.h> //include stdio.h header file to your program

main () //start of main

{

int n, sum = 0, i = 0 ;// variable declaration

printf ("Enter a number"); // message to the user

scanf ("%d", &n); //Read and store the number

loop: i++ ;//Label of goto statement

sum += i ;//the sum value in stored and I is added to sum

if (i < n) goto loop //If value of I is less than n pass control to loop

printf ("\n sum of %d natural numbers = %d", n, sum) ;

//print the sum of the numbers & value of n

}

Introduction to SQL

  • SQL(Structured Query Language) is a widely used database language, providing means of data manipulation (store, retrieve, update, delete) and database creation.
  • SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating databases.
  • SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database.
  • Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, MySQL etc.
  • Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system.
  • However, the standard SQL commands such as SELECT, INSERT, UPDATE, DELETE, CREATE, and DROP can be used to accomplish almost everything that one needs to do with a database.

My SQL



SQL Database Tables

A relational database system contains one or more objects called tables. The data or information for the database is stored in these tables. Tables are uniquely identified by their names. Information is stored in the form of columns (also called fields) and rows (also called records). Columns contain the column name, data type, and any other attributes for the column and rows contain the records or data for the columns.

Example below shows a simple database table, containing customer’s data. The first row contains the names of the table columns.


SQL Syntax List


Select

SELECT “column_name” FROM “table_name”

Distinct

SELECT DISTINCT “column_name”

FROM “table_name”

Where

SELECT “column_name”

FROM “table_name”

WHERE “condition”

And/Or

SELECT “column_name”

FROM “table_name”

WHERE “simple condition”

{[AND|OR] “simple condition”}+

In

SELECT “column_name”

FROM “table_name”

WHERE “column_name” IN (‘value1′, ‘value2′, …)

Between

SELECT “column_name”

FROM “table_name”

WHERE “column_name” BETWEEN ‘value1′ AND ‘value2′

Like

SELECT “column_name”

FROM “table_name”

WHERE “column_name” LIKE {PATTERN}

Order By

SELECT “column_name”

FROM “table_name”

[WHERE "condition"]

ORDER BY “column_name” [ASC, DESC]

Count

SELECT COUNT(“column_name”)

FROM “table_name”

Group By

SELECT “column_name1″, SUM(“column_name2″)

FROM “table_name”

GROUP BY “column_name1″

Having

SELECT “column_name1″, SUM(“column_name2″)

FROM “table_name”

GROUP BY “column_name1″

HAVING (arithematic function condition)

Create Table

CREATE TABLE “table_name”

(“column 1″ “data_type_for_column_1″,

“column 2″ “data_type_for_column_2″,

… )

Drop Table

DROP TABLE “table_name”

Truncate Table

TRUNCATE TABLE “table_name”

Insert Into

INSERT INTO “table_name” (“column1″, “column2″, …)

VALUES (“value1″, “value2″, …)

Update

UPDATE “table_name”

SET “column_1″ = [new value]

WHERE {condition}

Delete From

DELETE FROM “table_name”

WHERE {condition}

For more details visit Share IT Tips


Share BCA will help you with learning VB.Net tutorials. Its a new service started which has SYBCA VB.Net tutorials, sybca tutorials and TYBCA Tutorials. Through which one can learn the VB.Net of BCA in an easy manner

You can learn the sybca subjects like VB.Net, Vb.Net, SSC, OOPS via SYBCA tutorial. Here you will be learning the SYBCA VB.Net .


C Language Syntax

  • Main Function Syntax

#include<stdio.h>

void main()

{

//Your Code goes here

//For more details log on to www.sharebca.com

}

  • Syntax For Printing or Outputting .

printf(“Hello World”);

[Note : Every Line in C Language Ends up with ; ]

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

printf(“Hello World”);

//For more details log on to www.sharebca.com

}

  • Declaring a Variable in C :

<data type> <variable name>;

eg :

int no;

char ch;

float no;

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int no;

no=10;

printf(“The no variable is assigned value %d “, no);

//For more details log on to www.sharebca.com

}

  • Syntax For Scanning the variables :

scanf(“%d”,<variable name>);

[Note : You need to have %d (for integer values), %f (for floating values), %c (for char values), %s (for String values) | Followed by variable name]

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int no;

printf(“Enter any number : Note only number else program will hang up\n”);

scanf(“%d”,&no);

printf(“You have entere the %d “,no);

//For more details log on to www.sharebca.com

}

  • Working with Arithmetic Operators & its  Syntax :

There are mainly 5 arithmetic operators. They are

  1. +
  2. /
  3. *
  4. %

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int no;

no=10;

int no1;

no1=20;

int r;

r=no+no1;

printf(“The addition of two number is %d\n”,r);

r=no/no1;

printf(“The divisionof two number is %d\n”,r);

r=no*no1;

printf(“The multiplication of two number is %d\n”,r);

r=no-no1;

printf(“The substration of two number is %d\n”,r);

r=no%no1;

printf(“The modul of two number is %d\n”,r);

//For more details log on to www.sharebca.com

}

  • If Condition Syntax :

if(<condition>)

{

}

else if(<condition>)

{

}

else

{

}

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int no;

no=10;

if(no<20)

{

printf(“Number is less than 20”);

}

else

{

printf(“Number is less than 20”);

}

//For more details log on to www.sharebca.com

}

  • Declaring Array :

int no[<number>];

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int no[3];

no[0]=1;

no[1]=2;

no[2]=3;

printf(“The number at 2nd position in array is  %d “,no[1]);

//For more details log on to www.sharebca.com

}

  • For Loop :

for(i=0; i<5; i++)

{

//your code which u wanna repear 5 times

//For more details log on to www.sharebca.com

}

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int i=0;

for(i=0; i<5; i++)

{

printf(“This will be displayed 5 times\n”);

}

//For more details log on to www.sharebca.com

}

  • while Loop :

while(i<5)

{

//your code which u wanna repear 5 times

//For more details log on to www.sharebca.com

}

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int i=0;

while(i<5)

{

printf(“This will be displayed 5 times\n”);

i++;

}

//For more details log on to www.sharebca.com

}

  • Do while Loop :

do

{

//your code which u wanna repear 5 times

//For more details log on to www.sharebca.com

}

while(i<5);

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int i=0;

do

{

printf(“This will be displayed 5 times\n”);

i++;

}

while(i<5);

//For more details log on to www.sharebca.com

}

  • The Switch Case :

Switch(i)

{

case 1:

printf(“1\n”);

break;

case 2:

printf(“2\n”);

break;

//For more details log on to www.sharebca.com

}

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int i=1;

switch(i)

{

case 1:

printf(“1\n”);

break;

case 2:

printf(“2\n”);

break;

//For more details log on to www.sharebca.com

}

}

  • Pointer Variable :

int *no;

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int a=10;

int *no;

no=&a;

printf(“This will print address of the variable where pointer variable is pointing to that is a’s address %d\n”,no);

printf(“This will print address of the pointer variable no %d\n”,&no);

printf(“This will print number stored on the variable which is been pointed bye the pointer no, That is a’s value %d\n”,*no);

printf(“We are simpli printing address of variable a %d\n”,&a);

//For more details log on to www.sharebca.com

}

  • Defining Functions :

<Function return type> <function name> (<argument list>)

{

}

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void show(char c);

void main()

{

show(‘*’);

//For more details log on to www.sharebca.com

}

void show(char c)

{

for(int i=0; i<=4; i++)

{

for(int j=0; j<=i; j++)

{

printf(“%c”,c);

}

printf(“\n”);

}

}

  • Defining Constants :

const int no=10;

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

const int no=10;

void main()

{

printf(“%d”,no);

//For more details log on to www.sharebca.com

}

  • The ?: Operator :

conditional expression ? expression 1 : expression 2

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

(1<0)?printf(“True”): printf(“False”);

//For more details log on to www.sharebca.com

}

  • Goto Startement syntax :

Goto label;

Label:

//statements to be executed

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

void main()

{

int x;

read:

scanf(“%d”,&x);

if(x<0)

{

goto read;

}

printf(“%d”,x);

//For more details log on to www.sharebca.com

}

  • Structure syntax :

struct

{

<data type> <variable name>;

<data type> <variable name>;

}

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

struct product

{

char p_name[50];

int p_date;

float p_price;

char p_supply[50];

}p1,p2,p3;

void main()

{

printf(“Enter product 1 detail”);

scanf(“%s%d%f%s”,p1.p_name,&p1.p_date,&p1.p_price,p1.p_supply);

//For more details log on to www.sharebca.com

}

  • Union syntax :

union

{

<data type> <variable name>;

<data type> <variable name>;

}

Eg  : ( 100% working just copy and paste it will work)

#include<stdio.h>

union product

{

char p_name[50];

int p_date;

float p_price;

char p_supply[50];

}p1,p2,p3;

void main()

{

printf(“Enter product 1 detail”);

scanf(“%f”,&p1.p_price);

printf(“%f”,p1.p_price);

//For more details log on to www.sharebca.com

}


Share BCA will help you with learning Data & file Structure (DFS) tutorials. Its a new service started which has SYBCA Data & file Structure (DFS) tutorials, FYBCA tutorials and TYBCA Tutorials. Through which one can learn the Data & file Structure (DFS) of BCA in an easy manner

You can learn the FYBCA subjects like DFS, Vb.Net, SSC, OOPS via SYBCA tutorial. Here you will be learning the SYBCA Data & file Structure (DFS).


Share BCA will provide you with tutorials for learning bca. Its a new service started which has FYBCA tutorials, SYBCA tutorials and TYBCA Tutorials. Through which one can learn the BCA in an easy manner

You can learn the FYBCA subjects like C, Access, IH, PC’s via FYBCA tutorial. Here you will be learning the FYBCA Internet and HTML Tutorials.

For more details visit Internet and HTML Tutorials




Follow

Get every new post delivered to your Inbox.