congratulations to the toppers

B. Raji Murthy -881 marks

B. Bharat Kumar -837 marks

Ch. Sailaja -820 marks

J. Siva Krishna -815 marks

K. Vijaya Swathi -807 marks

P. Santhosh Kumar -855 marks

P. Swathi Priya -804 marks

P. Sagar -816 marks

T. Lakshminaga Rohita -840 marks

U. Bharat Kumar -850 marks

Saturday, November 7, 2009

A C program to find the roots of a quadratic equation.

#include " stdio.h "
#include " conio.h "
#include " math.h "

void main()
{
float a,b,c,root1,root2;
clrscr();
printf("\n Enter values of a,b,c for finding roots of a quadratic eq:\n");
scanf("%f%f%f",&a,&b,&c);

/*checking condition*/
if( b*b > 4*a*c )
{
root1=-b+sqrt(b*b-4*a*c)/2*a;
root2=-b-sqrt(b*b-4*a*c)/2*a;
printf("\n*****ROOTS ARE*****\n");
printf("\n root1=%f\n root2=%f",root1,root2);
}
else
printf("\n Imaginary Roots.");
getch();
}

c program for finding given number is arm strong or not with out using loops

#include " stdio.h "
#include " conio.h "
void main()
{
int a=371,b,c,arm=0,num;
num=a;
clrscr();
b=a%10;

arm=arm+b*b*b;
c=a/10;
b=c%10;

arm=arm+b*b*b;

c=c/10;
b=c%10;

arm=arm+b*b*b;


if ( num == arm )
printf("\n%d is arm strong number",num);
else
printf("\n%d is not arm strong number",num);


getch();
}

c program for finding greatest among three numbers using if else statement

#include" stdio.h "
void main()
{
int a=1,b=11,c=0;
clrscr();
if ( a > b && a > c )
{
printf("\n a is greater");
}
else
if ( b > c )
{
printf("\n b is greater");
}
else
{
printf("c is greater");
}

getch();
}

C program for finding greatest among 3 numbers using condtional operator(ternary operator)

#include
void main()
{
int a=1,b=11,c=13;
clrscr();
(a>b&&a>c)?printf("\n a is greater"):(b>c)?printf("\n b is greater"):printf("c is greater");

getch();
}

c program for special operators:sizeof

#include " stdio.h "
void main()
{
int a,b,c;
clrscr();
a=sizeof(int);
b=sizeof(float);
c=sizeof(char);
printf("size of int is %d",a);
printf("\n size of float is %d",b);
printf("\n size of char is %d",c);
getch();
}

C program for Bit wise Operators:bitwise AND ,bitwise OR, bitwise EX-OR

#include " stdio.h "
void main()
{
int a=6,b=4;
clrscr();
printf("bitwise and is %d",a&b);
printf("\n bitwise or is %d",a|b);
printf("\n bitwise exor %d",a^b);
getch();
}

c program for conversion of numbers from decimal to octal and hexa decimal

#include " stdio.h "
void main()
{
int a=10;

clrscr();

printf(" \n the value of c in decimal \t %d",a);
printf("\n the value of c in octal\t %o",a );
printf("\n the value of c in hexa decimal %x",a);
getch();
}