Tuesday, 25 September 2012

WAP for Heart Pattern.

  
  • WAP for Heart Pattern. 
       *       *
      ***   ***
    **********
     ********
      ******
        ****
         ** 
#include <stdio.h>
#include <conio.h>
void main()
{
    int i,j;
    for(i=5;i>=1;i=i-2)
    {
        for(j=i;j>=1;j=j-2)
        printf(" ");
        for(j=5;j>=i;j--)
        printf("*");
        for(j=i;j>1;j--)
        printf(" ");
        for(j=5;j>=i;j--)
        printf("*");
        printf("\n");
        }
        for(i=1;i<=6;i++)
        {
            for(j=1;j<=i;j++)
            printf(" ");
            for(j=6;j>i;j--)
            printf("*");
            for(j=4;j>=i;j--)
            printf("*");
            printf("\n");
        }
        }

WAP to Find out the day of the entered year.(Gregorian Calender)

  •  According to Gregorian Calender it was Monday on the date 01/01/01.If any year is input through the keyboard. WAP to find out what is the day on 1st January of this Year.
#include<stdio.h>
#include<conio.h>
void main()
{
int y,d=0,i,ch=0;
clrscr();
printf("enter the year");
scanf("%d",&y);
for(i=1990;i<y;i++)
{
if(i%4==0)
d=d+366;
else
d=d+365;
}
ch=d%7;
switch(ch)
{
case 0:
printf("monday");
break;
case 1:
printf("tuesday");
break;
case 2:
printf("wednesday");
break;
case 3:
printf("thursday");
break;
case 4:
printf("friday");
break;
case 5:
printf("saturday");
break;
case 6:
printf("sunday");
break;
defaut:
printf("invalid option");
}
getch();
}


Saturday, 22 September 2012

WAP to print the pattern.

  • WAP to print the follwing pattern:
                           *
                         ***
                       *****
                     *******
#include <stdio.h>
#include <conio.h>
void main()
{
    int i,j,l,k;
    for(i=1;i<=5;i++)
    {
        for(j=4;j>=i;j--)
        printf(" ");
        for(l=1;l<=i;l++)
        printf("*");
        for(k=1;k<=i-1;k++)
        printf("*");
        printf("\n");
        }
        }

Tuesday, 4 September 2012

WAP to Find the net salary on basis of basic salary.

  • WAP to Find the net salary on basis of basic salary.

#include <stdio.h>
#include <conio.h>
void main()
{
    float bs,gs,ns,hra,da,pf;
    char c;
    printf("Enter 'f' for female and 'm' for male");
    scanf("%c",&c);
    printf("Enter the basic salary");
    scanf("%f",&bs);
    if(bs>=5000)
    {
        if(c=='f')
            {
            hra=(15/100)*bs;
            da=(10/100)*bs;
            pf=(8/100)*bs;
            }
            else
            {
            hra=(20/100)*bs;
            da=(15/100)*bs;
            pf=(10/100)*bs;
            }
        }
            else
            {
                hra=(10/100)*bs;
                da=(9/100)*bs;
                pf=(8/100)*bs;
                }

                gs=bs+hra+da;
                ns=gs-pf;
                printf("%f is the gross salary",gs);
                printf("%f is the net salary",ns);
            }

WAP to enter Lower And Upper Limit and Print the Cost.

  • WAP to enter Lower And Upper Limit and Print the Cost.
#include <stdio.h>
#include <conio.h>
void main()
{
    int up,lo,d;
    float s;
    clrscr();
    printf("enter the upper limit");
    scanf("%d",&up);
    printf("enter the lower limit");
    scanf("%d",&lo);
    d=up-lo;
    if((d>200)&&(d<500))
    s=d*3.50;
    if((d>100)&&(d<200))
    s=d*2.50;
    if(d<100)
    s=d*1.50;
    printf("the sum is %lf",s);
    getch();
   }

WAP to display the Name of days of Week.

  • WAP to display the Name of days of Week.
#include <stdio.h>
#include <conio.h>
void main()
{
    int ch;
    printf("Enter the day number");
    scanf("%d",&ch);
    switch(ch)
    {
        case 1:
        printf("Sunday");break;
        case 2:
        printf("Monday");break;
        case 3:
        printf("Tuesday");break;
        case 4:
        printf("Wednesday");break;
        case 5:
        printf("Thusday");break;
        case 6:
        printf("Friday");break;
        case 7:
        printf("Saturday");break;
        default:
        printf("Wrong Choice");
        }
        getch();
        }

Write a menu driven Program to covert no of years into second,minutes,hours,days and month.

  • Write a menu driven Program to covert no. of years into second,minutes,hours,days and month.
#include <stdio.h>
#include <conio.h>
void main()
{
    int yr;
    double f;
    int ch;
    printf("Enter the number of years");
    scanf("%d",&yr);
    printf("Enter your choise:\n");
    printf("1 for seconds\n");
    printf("2 for minutes\n");
    printf("3 for hours\n");
    printf("4 for days\n");
    printf("5 for months\n");
    scanf("%d",&ch);
    switch(ch)
    {
        case 1:
        f=yr*365*24*60*60;
        break;
        case 2:
        f=yr*365*24*60;
        break;
        case 3:
        f=yr*365*24;
        break;
        case 4:
        f=yr*365;
        break;
        case 5:
        f=yr*12;
        break;
        default:
        printf("Worng Choise");
    }
    }
    printf("%lf",f);
    }