Skip to main content

Posts

array mcq questions in c

1. The elements of an array can be accessed by its            a) name            b) index            c) dimension            d) none of the above Solution: (b) An array is accessed by its index. 2. The elements of array are stored in contiguous memory due to             a) This way computer can keep track only the address of the first element and the addresses                     of  other elements can be calculated.             b) The architecture of computer does not allow arrays to store other than serially             c) Both             d) None Solution: (a) This way computer can keep track only the address of the first element and the addresses of other elements can be calc...
Recent posts

Perfect number in C, Pyramid pattern, Number is power of two or not and Sum of series in c programming

Write a C program to check whether a given number (N) is a perfect number or not? [Perfect Number - A perfect number is a positive integer number which is equals to the sum of its proper positive divisors. For example 6 is a perfect number because its proper divisors are 1, 2, 3 and it’s sum is equals to 6.] #include <stdio.h> int main() {     int N;     scanf("%d",&N); int i, sum=0;     for(i=1; i<N;i++)     {         if(N%i==0)             sum+=i;     }     if(sum==N)         printf("\n%d is a perfect number.",N);     else         printf("\n%d is not a perfect number.",N); } Input Output 8000 8000 is not a perfect number. 8128 8128 is a perfect number. 6 6 is a perfect number. 87 87 is not a perfect number. Write a C program to find sum of following series where t...

Control statement in c programming language MCQ

1. The statement that transfers control to the beginning of the loop is          a) break          b) continue          c) goto          d) none Solution: (b) continue 2. Compute the printed values of i and j of the C program given below:                                                       #include <stdio.h>                             int main()                             {                             int i = 0, j = 8;                             while (i ...

C program for practice

1.Write a C Program to calculates the area (floating point number with two decimal places) of a Circle given it’s radius (integer value).  The value of Pi is 3.14. #include <stdio.h> #define PI 3.14 void main() {     int radius;     float area;     /* Enter the radius of a circle */     /* The radius of the circle is taken from the test cases */      scanf("%d", &radius); area = PI * radius * radius; printf("Area of a circle = %5.2f\n", area); } Input Output 42 Area of a circle = 5538.96 9 Area of a circle = 254.34 7 Area of a circle = 153.86 50 Area of a circle = 7850.00 2.Write a C program to check if a given Number is zero or Positive or Negative Using if...else statement. #include <stdio.h> int main() {     double number;     scanf("%lf", &number);  if (number <= 0.0)     {   ...