C Programming Language
  • Home
  • C Fundamentals
    • C Character Set
    • Tokens>
      • Keywords
      • Identifiers
      • Constants>
        • Definition and Its types
        • Numeric Constants>
          • Integer Constants
          • Real Constants
        • Character Constants
        • String Constants
        • Backslash Character
      • Operators>
        • Definition and Its types
        • Arithmetic
        • Relational
        • Logical
        • Increment
        • Decrement
        • Assignment
        • Arithmetic Assignment
        • Conditional
        • Bitwise
        • Special Operators
        • Hierarchy
    • Data Types>
      • Primary (Or) Basic
      • User-Defined
      • Derived
    • Variable>
      • Definition
      • Declaration
      • Initialization
  • Control Structures
    • Decision-Control>
      • If Statement>
        • Simple-if Statement
        • if-else Statement
        • Nested-if Statement
        • if-else ladder Statement
      • Switch Statement
    • Loop Control>
      • For
      • While
      • Do-While
  • Arrays
    • Introduction
    • Single-Dimensional>
      • Definition
      • Declaration
      • Initialization
    • Two-Dimensional>
      • Definition
      • Declaration
      • Initialization
    • Multi-Dimensional>
      • Definition
      • Declaration
      • Initialization
  • Functions
    • Definition
    • Standard Library Character Functions
    • Standard Library String Functions
    • Storage Classes>
      • Definition
      • Automatic
      • Register
      • Static
      • External
  • Pointers
  • Files
    • Concepts
    • Data Files and its Categories
    • Standard Files and its Categories
  • University Questions
    • April 2001 To 2005
    • April 2006 To 2010
    • April 2011 To 2015
    • November 2001 To 2005
    • November 2006 To 2010
    • November 2011 To 2015

Write a C program to check wheather the given number is Postive or Negative?

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

main()
{
        int n;
        clrscr();

        printf("Enter the value for n: ");
        scanf("%d",&n);

        if (n>0)
                printf("n is Positive.");
        else
                printf("n is Negative.");

        getch();
 }

Output:

Enter the value for n: 10
Positive

Enter the value for n: -10
Negative


Write a C program to find the biggest among two numbers?

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

main()
{
        int a,b;
        clrscr();

        printf("Enter the values for a and b: ");
        scanf("%d" %d",&a,&b);

        if (a>b)
                printf("a is biggest.");
        else
                printf("b is biggest.");

        getch();
 }

Output:

Enter the value for a: -10
Enter the value for b: 5
b is biggest.

Enter the value for a: 5
Enter the value for b:-10
a is biggest.


Write a C program to find the smallest among two numbers?

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

main()
{
        int a,b;
        clrscr();

        printf("Enter the values for a and b: ");
        scanf("%d" %d",&a,&b);

        if (a<b)
                printf("a is smallest.");
        else
                printf("b is smallest.");

        getch();
 }

Output:

Enter the value for a: -10
Enter the value for b: 5
a is smallest.

Enter the value for a: 5
Enter the value for b:-10
b is smallest.


Powered by Create your own unique website with customizable templates.