C PROGRAMMING
MULTIPLE CHOICE QUESTION
OLD QUESTION BANK
SAMPLE QUESTION 2080 AND SOLUTION
  1. WAP  to read two numbers from the user and determine the larger number using a conditional operator.
#include <stdio.h>  
   
int main() {  
    int a, b, largest;
    printf("Please Enter Two Different Values\n");  
    scanf("%d %d", &a, &b);  
    
    if(a == b)
    {
        printf("Both are Equal\n");
    }
    else { 
        largest = (a > b) ? a : b;
        printf("%d is Largest\n", largest);
    }
    return 0;  
}

2. C program to find area of circle

#include <stdio.h>
#define PI 3.14159
int main() {
  float radius, area;
  printf("Enter the radius of the circle: ");
  scanf("%f", &radius);

  area = PI * radius * radius;

  printf("The area of the circle is: %f", area);

  return 0;
}

3. C program to calculate Simple Interest

# include <conio.h>
# include <stdio.h>

int main(){

    //Simple interset program
    int principal, rate, time, interest;

    printf("Enter the principal: ");
    scanf("%d", &principal);

    printf("Enter the rate: ");
    scanf("%d", &rate);

    printf("Enter the time: ");
    scanf("%d", &time);

    interest = principal * rate * time / 100;
    printf("The Simple interest is %d", interest);

    return 0;

}

4. WAP to calculate the number of memory bytes required for an int,float,double and char type variable 

#include <stdio.h>

int main() {
  int integerType;
  char charType;
  float floatType;
  double doubleType;

  printf("Size of int is: %ld", sizeof(integerType));

  printf("\nSize of char is: %ld", sizeof(charType));

  printf("\nSize of float is: %ld", sizeof(floatType));

  printf("\nSize of double is: %ld", sizeof(doubleType));

  return 0;
}

5. WAP to read a string with multiple words(i.e. With space ) using scanf function and display.

#include <stdio.h>
int main() {
  char name[30];
  printf("Enter name: ");
  scanf("%[^\n]", name);

  printf("Name is: %s\n", name);
  return 0;
}

6. Write a program that uses functions:

  1. scanf()  // use[A-Z] inside scanf
  2. printf()
  3. getchar()
  4. putchar()
  5. gets()
  6. puts()
#include <stdio.h>

int main() {
  int a;
  char c;
  char ch[20];
  printf("Enter the value of a = ");
  scanf("%d", &a);
  printf("\nThe value of a = %d", a);
  c = getchar();
  putchar(c);
  printf("Enter the text: ");
  gets(ch);
  puts(ch);
  scanf("%[A-Z]s,ch");
  puts(ch);
}

7. Write a program that will convert temperature in Centigrade into Fahrenheit.