Tuesday, July 31, 2012

Wap to Check that input is Consonant or Vowel.

, No comments

Source Code :

#include<stdio.h>
#include<conio.h>
   void main()
       {
       char in;
       ///input=alphabet
       printf("\n Enter An Alphabet :: ");
       scanf("%c",&in);

if(in=='a'||in=='A'||in=='e'||in=='E'||in=='i'||in=='I'|| in=='o'||in=='O'||in=='u'||in=='U')
          printf("\n %c is a Vowel",input);
          else
          printf("\n %c is a Consonant",input);
          getch();
       }

Result:

Enter An Alphabet :: A
A is a Vowel

Related Terms


what is c programming
in c programming
about c programming
about c programming language
c programming code
the c programming language
c programming language
c programming
programming
programming in c
computer programming
game programming
programming software
software programming

Thursday, July 19, 2012

How to reverse a numbers input by user

, No comments
Source Code:
#include<stdio.h>
#include<conio.h>
    void main()
       {
           long number,n1,n2,n3,n4,n5,n6,n7,n8,n9;
           
           clrscr();
           printf("\n Enter A Five Digit Number :: ");
           scanf("%ld",&number);
           n1=number%10;
           n2=number/10;
           n3=n2%10;


           n4=n2/10;
           n5=n4%10;
           n6=n4/10;
           n7=n6%10;
           n8=n6/10;
           n9=n8%10;

           
  printf("\nReverse Number is %ld%ld%ld%ld%ld",n1,n3,n5,n7,n9);
  printf("\n Log on to http://www.whatiLearn.info For More "); 
           getch();
       }





Input:
Enter A Five Digit Number :: 12365
Output:
Reverse Number is:: 56321
Log on to http://www.whatiLearn.info For More 



Wednesday, July 18, 2012

Check for a leap year

, , No comments
Algorithm to check leap year.

if year % 400 is 0
          then is_leap_year 
else if year %100 is 0 
         then not_leap_year 
else if year % 4 is 0 
        then is_leap_year
else not_leap_year 





Source Code:
#include<stdio.h>
#include<conio.h>
   void main()
    {
        int year;
        
        printf("\n Enter A Year :: ");
        scanf("%d",&year);


       if(year%400==0 || year%4==0 && year%100!=0 )
       printf("\n Leap Year");


       else
       printf("Not Leap Year");
  
       printf("\n Log on to http://www.whatiLearn.info For More ");  
           getch();

     } 

Input: 

Enter A Year  ::2000

Output:

Leap Year
Log on to http://www.whatiLearn.info For More

Entries RSS Comments RSS

Sample Text

Pages


Copyright © Lovely Codes
Powered by Blogger
Distributed By Free Blogger Templates | Design by N.Design Studio
Blogger Theme by Lasantha - PremiumBloggerTemplates.com