Saturday, March 6, 2010

SERIES 20 TO 1

WAP to print series from 20 to 1
#include
void main ()
{
int a;
clrscr ();
a=20;
while (a>=1)
{
printf ("\n%d",a);
a--;
}
getch ();
}

PRINT SERIES (VARIABLE)

WAP to print series from start to end using do-while loop
void main ()
{
int a,b;
clrscr ();
printf ("Enter Start: ");
scanf ("%d",&a);
printf ("Enter End: ");
scanf ("%d",&b);
do
{
printf ("%d\n",a);
a++;
}
while (a<=b);
getch ();
}

PRINT STARS

WAP to print Stars on screen
void main ()
{
int i,j;
clrscr();
for (j=1;j<4;j++)
{
for (i=1;i<=5;i++)
{
printf ("*");
}
printf ("\n");
}
getch ();
}

TABLE OF 5

WAP to print table of 5

void main ()
{
int a,tab;
clrscr ();
a=1,tab=0;
while (a<=10)
{
tab=5*a;
a++;
printf ("%d\n",tab);
}
getch ();
}

PASSWORD VERIFICATION

WAP to print the detail of the programmer
if the given number is 464
void main ()
{
int pass;
clrscr();
do
{
printf ("Enter Password to see the detail of programmer:\n");
scanf ("%d",&pass);
}
while (pass!=464);
printf ("\nJagjeet Singh");
printf ("\nB.Sc. (I.T.)\nPunjab Technical University");
getch ();
}

VALUE OF DATA TYPE

WAP to print value of multiple data types
#include
#include
void main ()
{
int a=10;
float d=40.50;
char ch='A';
double dbl=78.9786;
long lng=7897711;
char nm [10]="JIMMY";
clrscr ();
printf ("\nInteger value is %d",a);
printf ("\nFloat value is %.2f",d);
printf ("\nCharacter value is %c",ch);
printf ("\nDouble value is %.4lf",dbl);
printf ("\nLong value is %ld",lng);
printf ("\nString value is %s",nm);
getch ();
}

SUM,SUB,PRODUCT,DIVISION

WAP to Sum, Subtract, Multiply & Division of two numbers (5 Variables)

#include

void main ()
{
int a,b,c,d,e,f;
clrscr();
printf ("Enter A: ");
scanf ("%d",&a);
printf ("Enter B: ");
scanf ("%d",&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
printf ("\nSum is : %d",c);
printf ("\nSubtraction is : %d",d);
printf ("\nMultiplication is : %d",e);
printf ("\nDivision is : %d",f);
getch ();
}