Google analytics

Wednesday, February 1, 2012

To search a given number from a given list of numbers entered using liner serach??


#include<stdio.h>
#include<conio.h>
void main()
{
int a[20];
int n,i,item,loc,count=0;
clrscr();
printf("\n Enter number of elements : ");
scanf("%d",&n);
printf("\n Enter numbers : ");
for(i=1;i<=n;i++)
{
scanf("%d", &a[i]);
}
printf("\n Enter item to be searched : ");
scanf("%d", &item);
for(i=1;i<=n;i++);
{
if (a[i] == item)
{
loc=i;
printf("\n %d present at loc %d",item,loc);
count++;
}
}
if (count != 0)
{
printf("\n The number is present %d times",count);
}
else
printf("\n Item is not present");
getch();
}

Wednesday, September 7, 2011

Program to find the Grade of the marks

/* Program to find the Grade of the marks */


#include<stdio.h>
#include<conio.h>
int main()
{
 int m;
 clrscr();
  printf("Enter The Marks : ");
  scanf("%d",&m);
 if
 (m>=90 && m>=80)
  printf("Grade is A!");
 else if
 (m>=80 && m>=70)
  printf("Grade is B!");
 else if 
 (m>=70 && m>=60)
  printf("Grade is C!");

 else if 
 (m>=60 && m>=50)
  printf("Grade is D!");
 else if 
 (m>=50 && m>=40)
  printf("Grade is E!");

 else if 
 (m>=40 && m>=33)
  printf("Grade is F!");
 getch();
}






Write a program to check whether a given number is even or odd

/* check whether a given number is even or odd   */

#include<stdio.h>

#include<conio.h>
int main()
{
int a;
printf("Enter number : \n");
scanf("%d",&a);
if
(a % 2 ==0)
printf("The given number is EVEN\n");
else
printf("The given number is ODD");
return0;
}

Salary of a Company

/*  Salary Bonus */


#include<stdio.h>
#include<conio.h>
main()
{
   int a,b=500;
   float c;
    printf(“Enter the salary = “);
    scanf(“%d”,&a);
   if
   (a>=b)
  c=a*0.05
    printf(“Bonus is = %d”,c);
  else
    printf(“Bonus is = 250”)
}

Sunday, August 28, 2011

Find the roots of Quadratic Equation?


/* Program to find the roots of Quadratic Equation */

#include<stdio.h> 
#include<conio.h>
#include<math.h>
int main()
{
int a , b, c, d;
float
x1, x2;
clrscr();
printf("Enter the value of a, b, c:");
scanf("%d%d%d", &a, &b, &c);
d=(b*b)-(4*a*c);
if(d==0)
{
printf("\nRoots are real and equal");
x1= x2=(-b)/(2*a);
printf("\nRoots are: %f \t %f ", x1, x2);
}
else
{
if(d<0)
printf("\nRoots are imaginary");
else
{
x1=((-b)+sqrt(d))/(2*a);
x2=((-b)-sqrt(d))/(2*a);
printf("\nRoots are real");
printf("\nRoots are : %f \t %f", x1, x2);
}
}
getch( );
}