Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Showing posts with label c. Show all posts
Showing posts with label c. Show all posts

Monday, 16 February 2015

Introduction
In this article I will explain how to check the character you entered is Vowel or Consonant using If-else Ladder in C.
A,E,I,O,U is known as Vowel and other alphabets are called Consonants.

#include<conio.h>
#include<stdio.h>
main()
{
       char ch;
      printf("Enter  any character between a to z : ");
      scanf("  %c",&ch);

                      if(ch=='a')
                            {
                            printf("%c  is vowel”,ch);
                            }
                      else if(ch=='e')
                            {
                            printf("%c  is vowel”,ch);
                            }
                      else if(ch=='i')
                            {
                            printf("%c  is vowel”,ch);
                            }
                      else if(ch=='o')
                            {
                            printf("%c  is vowel”,ch);
                            }
                        else if(ch=='u')
                            {
                            printf("%c  is vowel”,ch);
                            }                                
                    else
                           {
                            printf("%c  is consonant”,ch);
                           }
                    getch();
                    }
                   
 Run the program using Ctrl+F9
                   
Output:

First Run
 Enter any character between a to z : u
 u is vowel 
Second Run
 Enter any number between a to z : p

 p is consonant

Thursday, 12 February 2015

Introduction: 

Now in this article i will explain how to find greater between two numbers using conditional operator in C Language. Conditional operator is also known as ternary operator and its symbol is?
 The syntax for conditional operator is: condition? expression1:expression2;

Now in this article we will learn how to find greatest of three numbers using nested if else statement in c language.

Implementation: Let's create a program to understand better.
#include<conio.h>
#include<stdio.h>
main()
{

Monday, 9 February 2015

Introduction: 
This is very common question asked by Interviewer to fresher to check their basics.
 In this article I will explain swapping using a temporary variable or third variable.

Program example: Let's understand by an program

#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,temp;
  clrscr();
 printf("Enter the value of a= ");

 scanf("%d",&a);
 printf("\nEnter the value of b= ");
 scanf("%d",&b);
 printf("\nValue of a before swapping= %d",a);
 printf("\nValue of b before swapping= %d",b);
 temp=a;
 a=b;
 b=temp;
 printf("\nValue of a after swapping= %d",a);
 printf("\nValue of b after swapping= %d",b);
 getch();
 }

Run the program using ctrl+F9


Output:
Enter the value of a=11
Enter the value of b=22

Value of a before swapping=11
Value of b before swapping=22
Value of a after swapping=22

Value of b after swapping=11