Wednesday, November 18, 2015

SLIPTEST QUESTIONS FOR CSE-B ON 20/11/2015(FRIDAY)



Slip test Questions for Cp To Cse-B on 20th Nov 2015
1 Briefly explain the structure of c-program?
2 How to create, run and execute the c-program?
3 Explain the different types of operators?
4 program development steps?
Programs
1. Sum of given n numbers.

2. Perfect number?

3. Palindrome number?

4. Roots of quadratics equations?

#include <stdio.h>
#include <math.h> /* This is needed to use sqrt() function.*/
int main()
{
  float a, b, c, determinant, r1,r2, real, imag;
  printf("Enter coefficients a, b and c: ");
  scanf("%f%f%f",&a,&b,&c);
  determinant=b*b-4*a*c;
  if (determinant>0)
  {
      r1= (-b+sqrt(determinant))/(2*a);
      r2= (-b-sqrt(determinant))/(2*a);
      printf("Roots are: %.2f and %.2f",r1 , r2);
  }
  else if (determinant==0)
  {
    r1 = r2 = -b/(2*a);
    printf("Roots are: %.2f and %.2f", r1, r2);
  }
  else
  {
    real= -b/(2*a);
    imag = sqrt(-determinant)/(2*a);
    printf("Roots are: %.2f+%.2fi and %.2f-%.2fi", real, imag, real, imag);
  }
  return 0;
}
Output 1 :Enter coefficients a, b and c: 2.3
4
5.6
Roots are: -0.87+1.30i and -0.87-1.30i
Output 2    :Enter coefficients a, b and c: 4
1
0
Roots are: 0.00 and -0.25
 
RECORD PROGRAMS:The following programs are shown in the lab in original record 
on 20/11/2015,in cp-lab
1.write a c program to print the area of triangle?
2.s=ut+1/2 *a*pow(t,2);
3 .write a c program to print the sum of given n numbers?
4 .write a c program to print the perfect number?
5 .write a c program to print the palindrome number?
6 .write a c program to find the roots of quadratic equation?
 

No comments:

Post a Comment