Apply Now :

Members

Sikkim Manipal University

Rank No. 1

Find Odd Even Number in Java

Monday, 12 December 2011

/*
JAVA Program : Find Odd Even Number
Calibre IT & Management Institute
[ Krishna Suman ]
*/

public class FindEvenOrOddNumber
{

public static void main(String[] args) {


int[] numbers = new int[]{1,2,3,4,5,6,7,8,9,10};

for(int i=0; i < numbers.length; i++){

if(numbers[i]%2 == 0)
System.out.println(numbers[i] + " is even number.");
else
System.out.println(numbers[i] + " is odd number.");

}

}
}




String Printinng in Java

/*
JAVA Program : String Printinng
Calibre IT & Management Institute
[ Krishna Suman ]
*/

public class Hello
{
public static void main(String[] args)
{
System.out.println("Calibre IT & Management Institute");
System.out.println("Contact :- 07432 232300 , 232400");


}
}




Sum of Two No. Example in C

/* C Program Sum of Two No. Example
Calibre IT & Management Institute
[ Krishna Suman ]
*/

#include<stdio.h>
main()
{
int A, B, Sum ;
clrscr();
printf("\n Enter First No. : ");
scanf("%d",&A);
printf("\n Enter Second No. : ");
scanf("%d",&B);
Sum = A + B ;
printf("\n Sum of two No. : %d",Sum);
getch();

}





File Handeling in C Language

/* C Program => File Handeling
Calibre IT & Management Institute
[ Krishna suman ]
*/


#include<stdio.h>

void main()
{
FILE *file1;
char c;
int choice;
char op;
clrscr();
do
{
printf("\t\tMenu\n\t1. Enter The Information\n\t2. Display The Information\n");
printf("\n \t Enter Your Choice : ");
scanf("%d",&choice);

switch(choice)
{
case 1:
printf("\n\t\t\t Information \n");
file1=fopen("Krishna.doc","w");


while((c=getchar())!=EOF)
{

putc(c,file1);
}
fclose(file1);
break;

case 2:
printf("\n\t\t\t Information\n");
printf("\nResult :");
file1=fopen("Krishna.doc","r");
while((c=getc(file1))!=EOF)
printf("%c",c);
fclose(file1);
break;

default:
exit(1);
}
printf("Enter Y To Continue:");
flushall();
scanf("%c",&op);
}while(op=='y' || op=='Y');
getch();
}






Select Option ( Form Attributes) Java Script

<! HTML JAVA SCRIPT Program Select Option
<! Calibre IT & Management Institute
<! [ Krishna Suman ]


<FORM METHOD="POST" ACTION="someplace/foo.cgi"
ENCTYPE="application/x-www-form-urlencoded">
<B><I><U>Calibre</B></I></U> IT & Management Institute
<BR>
Contact :- 07432 232300, 232400
<br>
Computer Experience:<P>
<SELECT NAME="choice" >
<OPTION VALUE="Less than 1 year.">Less than 1 year.
<OPTION VALUE="1-5 years.">1-5 years.
<OPTION VALUE="More than 5 years.">More than 5 years.
</SELECT>
<BR>
<INPUT TYPE="reset">
<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
</FORM>




Form Example in Java Script 2

<! HTML JAVA SCRIPT Program Form Attributes
<! Calibre IT & Management Institute
<! [ Krishna Suman ]


<FORM action="http://somesite.com/prog/adduser " method="post">
<P>
<TABLE BORDER=4>

<TR>
<TD>

First name: <INPUT type="text" name="firstname"><BR>
Last name: <INPUT type="text" name="lastname"><BR>
email: <INPUT type="text" name="email"><BR>
<INPUT type="radio" name="sex" value="Male"> Male<BR>
<INPUT type="radio" name="sex" value="Female"> Female<BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">

</P>
</TR>
</TD>

</FORM>




Simple Calculator Program in Java Script

<! HTML JAVA SCRIPT Program Calc Example
<! Calibre IT & Management Institute
<! [ Krishna Suman ]


<FORM NAME="Calc">
<TABLE BORDER=4>
<TR>
<TD>
<INPUT TYPE="text" NAME="Input" Size="16">
l<$
<br>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" NAME="one" VALUE=" 1 " OnClick="Calc.Input.value += '1'">
<INPUT TYPE="button" NAME="two" VALUE=" 2 " OnCLick="Calc.Input.value += '2'">
<INPUT TYPE="button" NAME="three" VALUE=" 3 " OnClick="Calc.Input.value += '3'">
<INPUT TYPE="button" NAME="plus" VALUE=" + " OnClick="Calc.Input.value += ' + '">
<br>
<INPUT TYPE="button" NAME="four" VALUE=" 4 " OnClick="Calc.Input.value += '4'">
<INPUT TYPE="button" NAME="five" VALUE=" 5 " OnCLick="Calc.Input.value += '5'">
<INPUT TYPE="button" NAME="six" VALUE=" 6 " OnClick="Calc.Input.value += '6'">
<INPUT TYPE="button" NAME="minus" VALUE=" - " OnClick="Calc.Input.value += ' - '">
<br>
<INPUT TYPE="button" NAME="seven" VALUE=" 7 " OnClick="Calc.Input.value += '7'">
<INPUT TYPE="button" NAME="eight" VALUE=" 8 " OnCLick="Calc.Input.value += '8'">
<INPUT TYPE="button" NAME="nine" VALUE=" 9 " OnClick="Calc.Input.value += '9'">
<INPUT TYPE="button" NAME="times" VALUE=" x " OnClick="Calc.Input.value += ' * '">
<br>
<INPUT TYPE="button" NAME="clear" VALUE=" c " OnClick="Calc.Input.value = ''">
<INPUT TYPE="button" NAME="zero" VALUE=" 0 " OnClick="Calc.Input.value += '0'">
<INPUT TYPE="button" NAME="DoIt" VALUE=" = " OnClick="Calc.Input.value = eval(Calc.Input.value)">
<INPUT TYPE="button" NAME="div" VALUE=" / " OnClick="Calc.Input.value += ' / '">
<br>
</TD>
</TR>
</TABLE>
</FORM>






Form Example in Java Script

<! HTML JAVA SCRIPT Program Form Example
<! Calibre IT & Management Institute
<! [ Krishna Suman ]


<html>
<head>
<script type="text/javascript">
function formSubmit()
{
document.getElementById("frm1").submit();
}
</script>
</head>
<body>

<p>Enter some text in the fields below, then press the "Submit form"

button to submit the form.</p>

<form id="frm1" action="form_action.asp">
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br /><br />
<input type="button" onclick="formSubmit()" value="Submit form" />
</form>

</body>
</html>






Message Box Example

<! HTML JAVA SCRIPT Program Message Box Example
<! Calibre IT & Management Institute
<! [ Krishna Suman ]

<HTML>
<HEAD>
Calibre IT & Management Institute
<BR>
<TITLE> Pass value from HTML to JavaScript </TITLE>
<script language="JavaScript" >
function hello(name)
{
alert("Hello! "+name);
}
</script>
</HEAD>
<BODY>
Get Hello Message<br>
<input type="button" onclick='hello("Rose India");' value="Click"/>
</BODY>
</HTML>




Simple Table Example

<! HTML Program Table Example Example
<! Calibre IT & Management Institute
<! [ Krishna Suman ]

<html>
<Head>
<title> Table Example</title>
<head>
<body>
<table border="1">
<tr>
<td>S No </td>
<td>Name </td>
</tr>
<tr>
<td>1</td>
<td>Krishna Suman</td>
</tr>
<tr>
<td>2</td>
<td>Mukesh Suman</td>
</tr>
<tr>
<td>3</td>
<td>Mahavir Suman</td>
</tr>
</table>


</body>
</html>




Heading & Paragraph Example

<! HTML Program => Heading & Paragraph Example
<! Calibre IT & Management Institute
<! [ Krishna Suman ]

<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>




Structure in C

/* C Program => Structure in C
Calibre IT & Management Institute
[ Krishna Suman ]
*/

#include <stdio.h>
#include <conio.h>
int main()
{
struct dob
{
int day;
int month;
int year;
};
struct student
{
struct dob d;
int rollno;
char name[25];
int totalmark;
}stud[25];
int n,i;
clrscr();
printf("Enter total number of students\n\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter details of %d-th student\n\n",i+1);
printf("\nName : ");
scanf("%s",&stud[i].name);
printf("\nRoll number : ");
scanf("%d",&stud[i].rollno);
printf("\nTotal mark : ");
scanf("%d",&stud[i].totalmark);
printf("\nDate of birth (Format:01 06 2010) : ");
scanf("%d%d%d",&stud[i].d.day,&stud[i].d.month,&stud[i].d.year);
}
clrscr();
printf("\n\n\tSTUDENTS DETAILS:\n");
for(i=0;i<n;i++)
{
printf("\n\nRoll number\t\t:\t%d",stud[i].rollno);
printf("\nName\t\t\t:\t%s",stud[i].name);
printf("\nTotel mark\t\t:\t%d",stud[i].totalmark);
printf("\nDate of birth\t\t:\t%d / %d / %d \n\n",stud[i].d.day,stud[i].d.month,stud[i].d.year);
}
getch();
return 0;
}






compute the fibonacci series

// C++ Program => Program to compute the fibonacci series
// Calibre IT & Management Institute
// [ Krishna suman ]

#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
int a,b,x,y,num1,ct;
a=0;
b=1;
cout << "Enter the number of terms (less than 25) : " << endl;
cin>>num1;
cout << a << endl;
cout << b << endl;
for(ct=1;ct<=num1-2;ct++)
{
x=a+b;
cout << x << endl;
y=a;
a=b;
b=x;
}
getch();
}




Find Total Days in the Year Till Date

// C++ Program => Program to find the total days in the year till date
// Calibre IT & Management Institute
// [ Krishna suman ]

#include <iostream.h>Publish Post
#include <conio.h>

void main()
{
clrscr();
int day,month,total;
int days_per_month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
cout << "Enter the month : " << endl;
cin>>month;
cout << "Enter the day : " << endl;
cin>>day;
total=day;
for(int x=0;x<month-1;x++)
total+=days_per_month[x];
cout << "The number of days in this year till date = " << total << endl;
getch();
}




Convert days to year & Weeksty

// C++ Program => Convert days to year & Weeksty
// Calibre IT & Management Institute
// [ Krishna suman ]

#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
int days,years,weeks,num1;
cout << "Enter the number of days : " << endl;
cin>>days;
years=days/365;
num1=days-(years*365);
weeks=days/7;
num1=days-(weeks*7);
cout << days << " days = " << endl;
cout << weeks << " weeks OR " << endl;
cout << years << " years." << endl;
getch();
}




Table of Multiply 15 No.

// C++ Program => Table of Multiply 15 No.
// Calibre IT & Management Institute
// [ Krishna suman ]


#include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int x;
cout << "Enter an integer less than 2185 : ";
cin>>x;
cout << "The first 15 multiples of " << x << " are : ";
for(int y=1;y<16;y++)
cout << "\n" << x << "x" << y << "=" << x*y;
getch();
return 0;
}




Reverse Integer Number

// C++ Program => Revers Integer Number
// Calibre IT & Management Institute
// [ Krishna suman ]
#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
long int num1,num2,rnum=0;
cout << "Enter an integer : " << endl;
cin>>num1;
num2=num1;
do
{
rnum=rnum*10;
int digit=num1%10;
rnum+=digit;
num1/=10;
}
while(num1);
cout << "The integer you typed is " << num2 << "." << endl;
cout << "The reversed integer is " << rnum << "." << endl;
getch();
}




Find Cube Of Given Number

// C++ Program => Qube of given No.
// Calibre IT & Management Institute
// [ Krishna suman ]
#include <iostream.h>
#include <conio.h>
int cube(int x); //The prototype.

void main()
{
clrscr();
int a;
cout << "Enter an integer : ";
cin>>a;
cout << "The cube of " << a << " is : " << cube(a) << endl; //Call the function cube(a).
getch();
}
//Defining the function.
int cube(int x)
{
int y;
y=x*x*x;
return(y);
}




Find String Length


// C++ Program => Find String Length
// Calibre IT & Management Institute
// [ Krishna suman ]

#include <iostream.h>
#include <conio.h>
#include <string.h>

void main()
{
clrscr();
int slength;
char x[81]; //Allowing the user to input a maximum of 80

characters.
cout << "Enter the string : " << endl;
cin>>x;
slength=strlen(x);
cout << "The length of the string " << x << " is " << slength <<

"." << endl;
getch();
}



Find Prime Number

// C++ Program => Prime No.
// Calibre IT & Management Institute
// [ Krishna suman ]

#include <iostream.h>
#include <conio.h>
#include <process.h>

void main()
{
clrscr();
int num1,x;
cout << "Enter an integer : " << endl;
cin>>num1;
for(x=2;x<num1;x++)
{
if(num1%x==0)
{
cout << num1 << " is a composite number." << endl;
getch();
exit(0);
}
else
{
cout << num1 << " is a prime number." << endl;
getch();
exit(0);
}
}
}






Font Style in C (Graphics)

/* C Program Graphics in C
Font Style in C
Calibre It & Management Institute
[ Krishna suman ]*/

#include<graphics.h>
#include<conio.h>

main()
{
int gd = DETECT, gm, x = 25, y = 25, font = 0;
initgraph(&gd,&gm,"C:\\TC\\BIN");

for ( font = 0 ; font <= 10 ; font++)
{
settextstyle(font, HORIZ_DIR, 1);
outtextxy(x, y, "Text with different fonts");
y = y + 25;
}

getch();
closegraph();
return 0;
}




Graphics in C (Shape Drawing)

/* C Program (Graphics in C)
Calibre IT & Management Institute
[ Krishna Suman ]
*/


#include<graphics.h>
#include<conio.h>

void main()
{
int gd=DETECT, gm;
int poly[12]={350,450, 350,410, 430,400, 350,350, 300,430, 350,450 };
initgraph(&gd, &gm, "");
outtextxy(180,10,"Calibre IT & Management Institute");
circle(100,100,50);
outtextxy(75,170, "Circle");
rectangle(200,50,350,150);
outtextxy(240, 170, "Rectangle");
ellipse(500, 100,0,360, 100,50);
outtextxy(480, 170, "Ellipse");
line(100,250,540,250);
outtextxy(300,260,"Line");

sector(150, 400, 30, 300, 100,50);
outtextxy(120, 460, "Sector");
drawpoly(6, poly);
outtextxy(340, 460, "Polygon");
getch();
closegraph();
}






Nested For Loop Example 3


/* C Program [ Krishna Suman] */
#include<stdio.h>
main()
{
int i, j,a=9 ,k;
clrscr();
for(i=1; i<=9; i++)
{ printf("\t\t");

a=a-1;
for(j=a; j>=1; j--)
{
printf(" ");
}
for(k=1; k<=i; k++)
{
printf("0");
printf(" ");
}
printf("\n");
}
for(i=8; i>=1; i--)
{
printf("\t\t");
a= a+1;
for(j=1; j<=a; j++)
{
printf(" ");
}
for(k=i; k>=1; k--)
{
printf("0");
printf(" ");

}
printf("\n");
}

getch();
}








Nested For Loop Example 2


/*C Program [ Krishna ]*/
#include<stdio.h>
main()
{
int i, j,a=9 ,k;
clrscr();
for(i=8; i>=1; i--)
{
printf("\t\t");
a= a+1;
for(j=1; j<=a; j++)
{
printf(" ");
}
for(k=i; k>=1; k--)
{
printf("0");
printf(" ");

}
printf("\n");
}



for(i=1; i<=9; i++)
{ printf("\t\t");

a=a-1;
for(j=a; j>=1; j--)
{
printf(" ");
}
for(k=1; k<=i; k++)
{
printf("0");
printf(" ");
}
printf("\n");
}

getch();
}

Nested For Loop Example

/* C Program [Krishna Suman]*/
#include<stdio.h>
main()
{
int i, j,a=9 ,k;
clrscr();
for(i=8; i>=1; i--)
{
printf("\t\t");
a= a+1;
for(j=1; j<=a; j++)
{
printf(" ");
}
for(k=i; k>=1; k--)
{
printf("0");
printf(" ");

}
printf("\n");
}


for(i=1; i<=9; i++)
{ printf("\t\t");

a=a-1;
for(j=a; j>=1; j--)
{
printf(" ");
}
for(k=1; k<=i; k++)
{
printf("0");
printf(" ");
}
printf("\n");
}
for(i=8; i>=1; i--)
{
printf("\t\t");
a= a+1;
for(j=1; j<=a; j++)
{
printf(" ");
}
for(k=i; k>=1; k--)
{
printf("0");
printf(" ");

}
printf("\n");
}


for(i=1; i<=9; i++)
{ printf("\t\t");

a=a-1;
for(j=a; j>=1; j--)
{
printf(" ");
}
for(k=1; k<=i; k++)
{
printf("0");
printf(" ");
}
printf("\n");
}

getch();
}








Piramid Usinf For Loop

/*
C Program : Piramid
Calibre IT & Management Institute
[ Krishna Suman ]
*/

#include<stdio.h>
main()
{
int i, j,a=9 ,k;
clrscr();
for(i=1; i<=9; i++)
{ printf("\t\t");

a=a-1;
for(j=a; j>=1; j--)
{
printf(" ");
}
for(k=1; k<=i; k++)
{
printf("0");
printf(" ");
}
printf("\n");
}

getch();
}

=====================  OUTPUT  ==================================



Print Star Using For Loop

/*
C Program : Piramid
Calibre IT & Management Institute
[ Krishna Suman ]
 */

#include<stdio.h>
main()
{
int i, j,a=0 ,k;
clrscr();
for(i=8; i>=1; i--)
{
a= a+1;
for(j=1; j<=a; j++)
{
printf(" ");
}
for(k=i; k>=1; k--)
{
printf("%d",k);
printf(" ");

}
printf("\n");
}

getch();
}







=====================  Out Put  =================================

SMU

SMU
Sikkim Manipal University