Breaking News

Programs in C (in Turbo C) - Snippets-2

Programs in C

(in Turbo C)

Snippets-2

Programs in C (in Turbo C) - Snippets-2


Program 8: Program to get a number from user in float and print the SQUARE OF NUMBER

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

main()
{
 float num;
 clrscr();
 printf("Enter the number: \t");
 scanf("%f",&num);
 printf("\n\nThe SQUARE of %f is \t%f",num,num*num);
 getch();
}




Program 9: Program to Perform Arithmetic Operation on Integer Quantities

#include <stdio.h>
#include<conio.h>
main()
{
 int num1,num2;
 clrscr();

 printf("Enter the first number num1 : ");
 scanf("%d",&num1);
 printf("Enter the second number num2 : ");
 scanf("%d",&num2);
 printf("\n\nThe Sum is num1 + num2 \t\t\t %d",num1+num2);
 printf("\n\nThe Subtraction is num1 - num2\t%d",num1-num2);
 printf("\n\nThe Multiplication is num1 * num2 \t %d",num1*num2);
 printf("\n\nThe Division is num1 / num2 \t\t %d",num1/num2);
 getch();
}


Program 10: Program to Perform Arithmetic Operation on One Integer And One Float Quantities


#include <stdio.h>
#include<conio.h>
main()
{
 int num1;
 float num2;

 clrscr();

 printf("Enter an Integer number num1 : ");
 scanf("%d", &num1);
 printf("\nEnter a float number num2 : ");
 scanf("%f", &num2);
 printf("\n num1 + num2 = %10f",num1+num2);
 printf("\n num1 - num2 = %10f",num1-num2);
 printf("\n num1 * num2 = %10f",num1*num2);
 printf("\n num1 / num2 = %10f",num1/num2);
 getch();
}



Program 11: Write a program in C, which can take an integer number Inch and then convert then find out its equivalent in Meters, and in Centimeters.

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

main()
{
 float inch,mts,cms;
 clrscr();
 printf("Enter the Input In INCHES :\t");
 scanf("%f",&inch);
 cms = inch * 2.54;
 mts = cms / 100;
 printf("\n%f Inches is equal to %f centimeters",inch,cms);
 printf("\n%f Inches is equal to %f meters",inch,mts);
 getch();
}



Program 12: Program To Print ASCII equivalent of Given Character

#include <stdio.h>
#include <ctype.h>

main()
{
 char ch;
 clrscr();
 printf("Enter the character :");
 scanf("%c",&ch);
 printf("\n\n\nThe ASCII equvilant of %c%d",ch,toascii(ch));
 getch();
}