C program to ASCII code for digit and backspace.

Q48. Write a C program to

  • print ASCII code for a given digit.
  • print ASCII code for backspace.

(Hint: Store escape sequence for backspace in an integer variable).

Ans(i).

#include<stdio.h>  //for standard input and output

#include<conio.h>  //for clrscr()

 

//Main Function

void main()

{

int num;

clrscr();  //for clear screen

 

printf(“\n Enter a digit you want to print the ASCII value of: “); Read More …

Write a program to print quotient and remainder.

 Q46. Write a program to read two numbers and print their quotient and remainder.

Ans.

#include<stdio.h>  //for standard input and output

#include<conio.h>  //for clrscr()

 

//Main Function

void main()

{

int dividend,divisor,remainder,quotient;

clrscr();  //for clear screen Read More …

C program to convert inches into yards, feet and inches.

Q45. Write a program to convert given inches into its equivalent yards, feet and inches.

(1 yard = 36 inches, 1 foot = 12 inches)

Ans.

#include<stdio.h>  //for standard input and output

#include<conio.h>  //for clrscr()

 

//Main Function

void main()

{

float inches,feet,yard;

clrscr();  //for clear screen Read More …

C program to print combinations from three digits.

Q44. Write a C program to accept three digits (that is, 0-9) and print all possible combinations from these digits. (For example, if the three digits are 1, 2 and 3 then all possible combinations are 123, 132, 231, 213, 312 and 321).

Ans.

#include<stdio.h>  //for standard input and output

#include<conio.h>  //for clrscr();

 

//Main Function

void main()

{

int a[3],i,n=0,swap; Read More …

C program to find area of a triangle.

Q42. Write a C program to find area of a triangle.

Ans.

#include<stdio.h>  //for standard input and output

#include<conio.h>  //for clrscr()

 

//Main() function

void main()

{

float height,base,area;

clrscr();  //for clear screen

printf(“\n Enter the height and base of the triangle: “);

scanf(“%f %f”,&height,&base);

area=(height*base)/0.5;

printf(“\n The area of triangle is: %f”,area);

getch();  //To hold the output screen

}

//End of main()

Output:

 

Enter the height and base of the triangle: 5  9.6

The area of triangle is: 96.000000

C program for electricity board charges.

Q40. An electricity board charges according to following rates:
For the first 100 units – 40 P per unit  (P-Paise)

For the next 200 units – 50 P per unit

Beyond 300 units – 60 P per unit.

All users are charged meter charge also which is R50/-.

Write a program to read the names of users and number of units consumed, and print out the charges with names.

Ans.

#include<stdio.h>  //for standard input output

#include<conio.h>  //for clrscr();

 

//A class called customer to hold all the information related to customer

struct customer

{

char name[20] Read More …

C program that converts heights to feet and inches.

Q39. Write a short C program that asks for your height in centimeters and then converts your heights to feet and inches. (1 foot = 12 inches, 1 inch = 2.54 cm).

Ans.

#include<stdio.h>

#include<conio.h>   //for clrscr();

void main()

{

float cm, foot, inch;

clrscr();

printf(“\n Enter your height in cm: “);

scanf(“%f”,&cm);

inch=cm/2.54;

foot=inch/12; Read More …