Fundamentals of Computer Programming - Old Questions

2. What is operator? List any six operators used in C-programming language. Write a program to find least number between any two numbers using ternary operator. [1+2+3]

6 marks | Asked in 2070

An operator is a symbol that operates on single or multiple data items. It is used in program to perform certain mathematical or logical manipulations.

E.g. In a simple expression 2+3, the symbol “+” is called an operator which operates on two data items 2 and 3.

C operators can be classified into following types:

  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Assignment Operators
  • Increment and Decrement Operators
  • Conditional Operators

Program to find least number between any two numbers using ternary operator:

#include <stdio.h>

#include<conio.h>

int main()

{

    int n1, n2,least; 

    printf("Enter two numbers: ");

    scanf("%d%d", &n1, &n2);

    least = n1<n2 ? n1:n2;

    printf("The least number is %d",least);

    getch();

    return 0;

}