C Programrs
C Programrs
a) if(condition){ } b) if(condition) :
c) If { [condition] } d) None of these
(viii) When the condition of if statement is false, the flow of code will ___.
a) go into the if block b) Exit the program
c) Continue the code after skipping the if block d) None of these
(ix) Which of the following is not a standard C library function for mathematical
operations?
a) rand b) pow c) sqrt d)abs
2. Write a program in ‘C’ to find a root of the equation 𝑥 3 − 5𝑥 + 1 = 0 by Newton Raphson method.
1
3. Write a program in ‘C’ to evaluate ∫0 𝑥 𝑑𝑥 taking n=5 by using Trapezoidal rule.
4. Write a program in C to find the square of any number using the function.
6 1
5. Write a program in C to evaluate ∫0 (1+𝑥)2 𝑑𝑥 using Simpson’s one-third rule taking six equal sub-
intervals.
6. Write a program in C to print the first 10 natural numbers using i) for loop ii) do while loop
7. Write a C program to compute the value of y at x=2.8 from the following table using Newton’s
Backward interpolation formula.
x 0.0 1.0 2.0 3.0
y 1 2 11 34
8. Write a C program to compute the value of y at x = 0.33 from the following table
x 0.32 0.34 0.36 0.38 0.40
y 1.769 1.780 1.791 1.802 1.813
8 4 2 4 9
9. Write a C program to find the real root between 2 and 3 of the equation 𝑥 3 − 2𝑥 − 5 = 0 using
Regula Falsi method.
𝑑𝑦
10. Write a C program to compute y(0.8) for 𝑑𝑥 = 𝑥𝑦, 𝑦(0) = 2 taking h= 0.2.(Using RK-method of
order 4).
11. What is the difference between do-loop and do-while loop in C?
Write a program in C to print the first 10 natural numbers using do while loop
#include <stdio.h>
int main()
{
int n=1;
do
{
printf("%d ", n);
n++;
} while(n <= 10);
return 0;
Write a program in C to find the square of any number using the function.
#include <stdio.h>
float f(float x)
{
return (x* x);
}
int main()
{
float a,n;
printf("Input any number for square : ");
scanf("%f", &a);
n = f(a);
printf("The square of %f is : %f\n", a, n);
return 0;
}