Header Ads Widget

Ticker

6/recent/ticker-posts

Practical 4 PPS

Write a C program to find that the accepted number is Negative, or Positive or Zero

#include <stdio.h>

int main()
{
    int no;
    printf("\n Enter any number : ");
    scanf("%d", &no);
    if (no == 0)
    {
        printf("\n Entered Number is Zero");
    }
    else if (no > 0)
    {
        printf("\n Entered Number is Positive");
    }
    else
    {
        printf("\n Entered Number is Negative");
    }
    return 0;
}

Write a program to read three numbers from keyboard and find out maximum out of these three. (nested if else) 

#include <stdio.h>

int main()
{
    int a, b, c;
    printf("\n Enter First Number  :");
    scanf("%d", &a);
    printf("\n Enter Second Number :");
    scanf("%d", &b);
    printf("\n Enter Third Number  :");
    scanf("%d", &c);
    if (a > b)
    {
        if (a > c)
        {
            printf("\n First Number %d is maximum", a);
        }
        else
        {
            printf("\n Third Number %d is maximum", c);
        }
    }
    else
    {
        if (b > c)
        {
            printf("\n Second Number %d is maximum", b);
        }
        else
        {
            printf("\n Third Number %d is maximum", c);
        }
    }
    return 0;
}

Write a C program to check whether the entered character is capital, small letter, digit or any special character

#include <stdio.h>

int main()
{
    char ch;
    printf("\nEnter Any Character :");
    scanf("%c", &ch);
    if (ch >= '0' && ch <= '9')
    {
        printf("\n Entered Character is Digit");
    }
    else if (ch >= 'A' && ch <= 'Z')
    {
        printf("\n Entered Character is Capital Letter");
    }
    else if (ch >= 'a' && ch <= 'z')
    {
        printf("\n Entered Character is Small Letter");
    }
    else
    {
        printf("\n Entered Character is Special Character");
    }
    return 0;
}

Post a Comment

0 Comments