/*WAP to count lenght of string*/
#include <stdio.h>
#include <string.h>
#include<conio.h>
void main()
{
char *string = "computer";
clrscr();
printf("%d\n", strlen(string));
getch();
}
there is some good c ,java, sql and vb6 programs,Windows tricks, sms shorthand etc
#include <stdio.h>
#include <string.h>
#include<conio.h>
void main()
{
char *string = "computer";
clrscr();
printf("%d\n", strlen(string));
getch();
}
class ForTest
{
public static void main(String args[])
{
int x;
for(x = 0; x<10; x = x+1)
System.out.println("This is x: " + x);
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int fahr, celsius;
clrscr();
printf("enter fahrenhiet tempreture");
scanf("%d",&fahr);
celsius = 5 * (fahr-32) / 9;
printf("%d",celsius);
getch();
}
import java.lang.*;
class evenodd
{
int i,flag;
void calculate()
{
for(i=1;i<=10;i++)
if(i%2==0)
{
System.out.println("No. is Even " + i);
}
else
if(i%2!=0)
System.out.println("No. is ODD " + i);
}
}
class eh
{
public static void main(String arg[])
{
evenodd e1=new evenodd();
e1.calculate();
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,hours,minutes,rh,rm,sec;
clrscr();
printf("enter seconds\n");
scanf("%d",&a);
hours=a/3600;
rh=a%3600;
minutes=rh/60;
rm=rh%60;
sec=rm;
printf("hours=%d",hours);
printf("\nminutes=%d",minutes);
printf("\nsec=%d",sec);
getch();
}
import java.lang.* ;
class table
{
int num,t;
table(int a)
{
num=a;
}
void display()
{
System.out.println("Table of :"+num);
for(int i=1;i<=10;i++)
{
t=num*i;
System.out.println(+t);
}
}
}
class Demo_table
{
public static void main(String arg[])
{
table t1=new table(5);
t1.display();
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,year,month,ry,rm,week,rw,days;
clrscr();
printf("enter day\n");
scanf("%d",&a);
year=a/365;
ry=a%365;
month=ry/30;
rm=ry%30;
week=rm/7;
rw=rm%7;
days=rw;
printf("year=%d",year);
printf("\nmonth=%d",month);
printf("\nweek=%d",week);
printf("\ndays=%d",days);
getch();
}
'controls Property Setting 'Shape1 Name shpshape ' Width 200 ' height 300 'Vertical Name SrcVertical 'Scrollbar ' Min 300 ' Max 200 'Horizontal Name SrcHorizontal 'Scrollbar ' Min 300 ' Max 200 '----------------------------------------------------- ' CODE Private Sub SrcHorizontal_click() shpshape.Width=SrcHorizontal.value End Sub Private Sub SrcVertical_click() shpshape.height=SrcVertical.value End Sub
import java.lang.*;
class sprime
{
int num,count=0;
sprime(int a)
{
num=a;
}
void display()
{
for(int i=1;i<=num;i++)
{
for(int j=1;j<=i;j++)
{
if(i%j==0)
count++;
}
if(count<3)
{
System.out.println(i);
count=0;
}
else
count=0;
}
}
}
class demo_sprime
{
public static void main(String arg[])
{
sprime p1=new sprime(100);
p1.display();
}
}
#include<stdio.h>
#include<conio.h>
int no;
void negpos();
void main()
{
clrscr();
printf("Enter -ive or +ive number");
scanf("%d",&no);
negpos();
getch();
}
void negpos()
{
if(no<0)
printf("Entered no. is negative");
else if(no>0)
printf("Entered no. is positive");
else
printf("Wrong entry");
}
'controls Property Setting
'Textbox1 Name txt
' Caption -
'Label1 Name lbl
' Caption Enter Password
'command1 Name cmdOk
' Caption OK
'command2 Name cmdCancel
' Caption Cancel
'-----------------------------------------------------
' CODE
Private Sub cmdOk_click()
If txt.text="123" Then
msgbox("Welcome")
else
msgbox("Wrong Password - enter 123")
End IF
End Sub
Private Sub cmdCancel_click()
End
End Sub
import java.lang.*;
class Array
{
int l[];
int x[];
int y[];
Array()
{
l=new int[]{1,2,3,4,5};
x=new int[]{2,3,4,5,6};
y=new int[5];
}
void display()
{
System.out.println("The addition of array is ");
for(int i=0;i<5;i++)
{
y[i]=l[i]/x[i];
System.out.println(y[i]);
}
}
}
class array_Div
{
public static void main(String arg[])
{
Array A = new Array();
A.display();
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("enter year");
scanf("%d",&a);
if(a%4==0)
printf("year is leap");
else
printf("year is'not leap");
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
char any;
clrscr();
printf("enter any character");
scanf("%c", &any);
if(any>=48&&any<=57)
{
printf("it is digit");
}
else
if(any>=97&&any<=122)
{
printf("it is lowercase alphabat");
}
else
if(any>=65&&any<=90)
{
printf("it is upper case alphabat");
}
else
if(any>=32&&any<=47)
{
printf("it is special symbol");
}
else
if(any>=58&&any<=64)
{
printf("it is special symbol");
}
else
if(any>=91&&any<=96)
{
printf("it is special symbol");
}
else
if(any>=123&&any<=127)
{
printf("it is special symbol");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int fact=1,n,i;
clrscr();
printf("enter number");
scanf("%d",&n);
for(i=1;i<=n;i++)
fact=fact*i;
{
printf("%d",fact);
getch();
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=1,fact=1;
clrscr();
printf("enter no.");
scanf("%d",&n);
while(i<=n)
{
fact=fact*i;
i++;
}
printf("%d",fact);
getch();
}
import java.lang.*;
class Array
{
int l[],m[],n[];
Array()
{
l=new int[] {1,2,3,4,5,6,7,8,9};
m=new int[] {1,2,3,4,5,6,7,8,9};
n=new int[9];
}
void display()
{
for(int i=0;i<9;i++)
{
n[i]=l[i]-m[i];
System.out.print(" "+n[i]);
}
}
}
class Array_Subtraction
{
public static void main(String arg[])
{
Array a1=new Array();
a1.display();
}
}
'controls Property Setting
'Textbox1 Name Text1
' Caption -
'Textbox2 Name Text2
' Caption -
'Label1 Name Lebel1
' Caption Enter first number
'Label2 Name Lebel2
' Caption enter second number
'Label3 Name Lebel3
' Caption Result
'command1 Name command1
' Caption Addition
'command2 Name command2
' Caption Subtraction
'command3 Name command3
' Caption Multiplication
'command4 Name command4
' Caption Dividetion
'command5 Name command5
' Caption Mod
'----------------------------------------------------------
' Code
Dim a as Integer
Dim b as Integer
Dim c as Integer
Private Sub command1_click()
a=Val(Text1.text)
a=Val(Text2.text)
c=a+b
Lebel3=c
End Sub
Private Sub command2_click()
a=Val(Text1.text)
a=Val(Text2.text)
c=a-b
Lebel3=c
End Sub
Private Sub command3_click()
a=Val(Text1.text)
a=Val(Text2.text)
c=a*b
Lebel3=c
End Sub
Private Sub command4_click()
a=Val(Text1.text)
a=Val(Text2.text)
c=a/b
Lebel3=c
End Sub
Private Sub command5_click()
a=Val(Text1.text)
a=Val(Text2.text)
c=aModb
Lebel3=c
End Sub
#include<stdio.h>
#include<conio.h>
void main()
{
int a[2][2],b[2][2],c[2][2],row,col;
clrscr();
printf("enter 2 metrix");
for(row=0;row<2;row++)
{
for(col=0;col<2;col++)
scanf("\t%d%d",&a[row][col],&b[row][col]);
}
for(row=0;row<2;row++)
{
printf("\n");
for(col=0;col<2;col++)
c[row][col]=a[row][col]+b[row][col];
}
printf("%d",c[row][col]);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int os,sm,dm,ppl,dsa,total;
float per,avg;
clrscr();
printf("enter five subjects marks");
scanf("%d%d%d%d%d",&os,&sm,&dm,&ppl,&dsa);
total=os+sm+dm+ppl+dsa;
per=total*100/50;
avg=total/5;
printf("\ntotal=%d",total);
printf("\npercentege=%f\navrege=%f",per,avg);
if(per>=60)
{
printf("\ndiv=first div.");
}
else
if(per>=45 &&per<60)
{
printf("\ndiv=second div");
}
else
if(per>=33 &&per<45)
{
printf("\ndiv=third div");
}
else
{
printf("\ndiv=fail");
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#include<process.h>
struct stack
{
int no;
struct stack *next;
}*top=NULL;
typedef struct stack st;
void push();
int pop();
void display();
void main()
{
char ch = 'y';
int choice,temp;
clrscr();
do
{
printf("\n1:push");
printf("\n2:pop");
printf("\n3:display");
printf("\n4:exit");
printf("\nEnter your choice");
scanf("%d",&choice);
switch(choice)
{
case 1:push();
break;
case 2:temp=pop();
printf("the deleted element is%d",temp);
break;
case 3:
display();
break;
case 4:
exit(0);
break;
default:
printf("\n wrong choice");
}
printf("do you want continue(y/n)");
flushall();
scanf("%c",&ch);
}
while(ch =='Y'|| ch =='y');
}
void push()
{
st*P;
P=(st*)malloc(sizeof(st));
printf("\nthe number");
scanf("%d",&P->no);
P->next=top;
top=P;
}
int pop()
{
st*P;
P=top;
if(top==NULL)
{
printf("stack is already empty");
getch();
exit(0);
}
else
{
top=top->next;
free(P);
}
return(P->no);
}
void display()
{
st*P;
P=top;
while(P->next != NULL)
{
printf("\n=%d",P->no);
P=P->next;
}
printf("\nno=%d",P->no);
}
#include<stdio.h>
#include<conio.h>
struct student
{
char name[25];
int marks[5];
int roll,clas;
}
main()
{
student s1,s2,s3,s4,s5;
int i;
int total=0,per;
clrscr();
printf("\nEnter first student name\n");
gets(s1.name);
printf("\nenter class");
scanf("%d",&s1.clas);
printf("\nenter roll no.");
scanf("%d",&s1.roll);
printf("\nEnter 5 sub. marks");
for(i=0;i<5;i++)
{
scanf("%d",&s1.marks[i]);
}
printf("\nEnter second student name\n");
gets(s2.name);
printf("\nenter class");
scanf("%d",&s2.clas);
printf("\nenter roll no.");
scanf("%d",&s2.roll);
printf("\nEnter 5 sub. marks");
for(i=0;i<5;i++)
{
scanf("%d",&s2.marks[i]);
}
printf("\nEnter thierd student name\n");
gets(s3.name);
printf("\nenter class");
scanf("%d",&s3.clas);
printf("\nenter roll no.");
scanf("%d",&s3.roll);
printf("\nEnter 5 sub. marks");
for(i=0;i<5;i++)
{
scanf("%d",&s3.marks[i]);
}
printf("\nEnter fourth student name\n");
gets(s4.name);
printf("\nenter class");
scanf("%d",&s4.clas);
printf("\nenter roll no.");
scanf("%d",&s4.roll);
printf("\nEnter 5 sub. marks");
for(i=0;i<5;i++)
{
scanf("%d",&s4.marks[i]);
}
printf("\nEnter fifth student name\n");
gets(s5.name);
printf("\nenter class");
scanf("%d",&s5.clas);
printf("\nenter roll no.");
scanf("%d",&s5.roll);
printf("\nEnter 5 sub. marks");
for(i=0;i<5;i++)
{
scanf("%d",&s5.marks[i]);
}
for(i=0;i<5;i++)
{
total+=s1.marks[i];
}
per=(total*100)/500;
printf("\nstudent name is %s\n",s1.name);
printf("\nstudent class is %d",s1.clas);
printf("\nstudent Roll No. is %d",s1.roll);
printf("\ntotal obtain mark is %d",total);
printf("\nstudent percentage is %d\n",per);
if(per>=60)
{
printf("first division");
}
else
if(per>=45&&per<60)
{
printf("second division");
}
else
if(per>=33&&per<45)
{
printf("third division");
}
else
if(per<33)
{
printf("\nfail");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
printf("Print all even numbers from 1 to 100\n");
printf("Even Numbers are:\n");
for(i=1;i<=100;i++)
{
if(i%2==0)
printf("%d ",i);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num,flage,i=2;
clrscr();
printf("enter no.");
scanf("%d",&num);
num1=num/2;
while(i<=num1)
{
if(num%i==0)
{
flage=1;
}
i++;
}
{
if(flage==1)
printf("not prime");
else
printf("prime");
getch();
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,rem,i,rev=0;
clrscr();
printf("enter no.");
scanf("\n%d",&n);
for(i=n;i>0;)
{
rem=i%10;
rev=rev*10+rem;
i=i/10;
}
printf("%d",rev);
if(n==rev)
{
printf("\nenter no. is palendron");
}
else
{
printf("\nenter no isn't palendron");
}
getch();
}