Posted by: pinakinayak on: 15/12/2008
Answers:
Write a program to find the roots of a quadratic equation.
Ans: #include<stdio.h>
main()
{
float a,b,c,r,l,d;
printf(“enter three nos of equation:”);
scanf(“%f %f %f”,&a,&b,&c);
if(a= =0)
printf(“value of a should not be zero.”);
else
{
d=b*b-4*a*c;
if(d>0)
{
r=(-b+sqrt(d))/(2*a);
l=(-b-sqrt(d))/(2*a);
printf(“roots are real and [...]
Posted by: pinakinayak on: 15/12/2008
‘C’ Probable Questions for Sem-end:
SIMPLE PROGRAMS:
1. Write a program that accept two integer numbers from user, and print their values in exchange form without using third variable.
2. Write a program to calculate total distance traveled by a vehicle in t seconds, distance = ut + (at^2)/2, Where ‘u’ is initial velocity, ‘a’ is acceleration [...]
Predict the output / error(s) for the following:
Note : All the programs are tested under Turbo C/C++ compilers.
1. void main ( )
{
int const * p = 5;
printf(“%d”,++ (*p));
}
Answer: Compiler error: Cannot modify a constant value.
Explanation: p is a pointer to a “constant integer”. But we tried to change the [...]