Sep 18 2009

If & Else if

Category: C Programmingadmin @ 11:07 pm

/*represent the if,else if */
#include<stdio.h>
main()
{
      int age1,age2;
      printf("Enter your age:");
      scanf("%d",&age1);
      printf("Your age is %d\n",age1);
      age2=30;
      printf("My age is %d\n",age2);
 
      if (age1>age2)
      {
        printf("I'm younger Than You :D\n");
        printf("You are %d years elder than me",age1-age2);
      } 
      else if(age1==age2)
        printf("We are in same age"); 
 
      else
        printf("I'm elder Than You");
 
       fflush(stdin);
       getchar();
}

Tags: , , ,


Sep 15 2009

Temp Converter

Category: C Programmingadmin @ 4:50 am

/*Convert a Celsius temperature to Fahrenhit*/
#include<stdio.h>
main()
{
      float tmpc;
      float tmpf;
      printf("Enter Celsius temperature:");
      scanf("%f",&tmpc);
      tmpf=32+tmpc*9/5;
      printf("Farenhit temperature:%.2f\n",tmpf);
 
      fflush(stdin);
      getchar();
}

Tags: , ,