C program to 5, 10, 9.

Q31. Write a C program that generates the following output:

        5

        10

        9

Assign value 5 to a variable using =. Multiply it with 2 to generate 10 and subtract 1 to generate 9.

Ans.

#include<stdio.h>

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

void main()

{

int value;

value=5;

clrscr();   //for clear screen

printf(“\n %d”,value); Read More …

C program that display data in table format.

Q10. Write a C program to generate the following table:

        1992                       17421

        1993                       29210

        1994                       100523

        1995                       106802

        1996                       127000

Use a single cout statement for output.

(Hint : Make use of \n and \t)

Ans.

#include<stdio.h>

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

void main()

{

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

C program for gallons that converts in cubic feet.

Q29.  Assuming that there are 7.481 gallons in a cubic foot, write a C program that asks the user to enter the number of gallons, and then displays the equivalent in cubic feet.

Ans.

#include<stdio.h>

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

void main()

{

float gallon, cbft;

clrscr();  //for clear screen

printf(“\n Enter the number of gallons: “);

Read More …

C program that displays z, Mohan, 1977.

Q28. Write a C program that displays on screen

  1. the character ‘z’
  2. the name ‘Mohan’
  3. the number 1977

Using

  • single cout statement
  • multiple cout statements.

Ans(i).

#include<stdio.h>

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

void main()

{

clrscr();    //for clear screen

printf(“\n z \n Mohan \n 1977”);

}

 

Output

z

Mohan

1977

 

Ans(ii).

#include<stdio.h>

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

void main()

{

clrscr();  // for clear screen

printf(“\n z”);

printf(“\n Mohan”);

printf(“\n 1977”);

}

Output

 

z

Mohan

1977

C program that reads temperature in Celsius and displays in Fahrenheit.

Q27. Write a C program that reads temperature in Celsius and displays it in Fahrenheit.

Ans.

#include<stdio.h>

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

void main()

{

float Celsius, Fahrenheit;

clrscr();    //for clear screen

printf(“\n Enter a temperature in Celsius: “);

scanf(“%f”,&Celsius); Read More …

C program to read values of w, x, y and z and display the value of P, where P= w+x / y-z.

Q26. Write a C program to read values of w, x, y and z and display the value of P, where

P= w+x / y-z

Ans.

#include<stdio.h>

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

void main()

{

int w,x,y,z,P;

clrscr();          //for clear screen

printf(“\n Enter the value of w: “); Read More …

C program that inputs a student’s marks in three subjects.

Q4. Write a C program that inputs a student’s marks in three subjects (out of 100) and prints the percentage marks.

Ans.

#include<stdio.h>

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

int main()

{

float sub1,sub2,sub3,marks,perc;

clrscr();   //for clear screen

printf(“Enter marks obtained in 3 subjects:”);

scanf(“%f %f %f”,&sub1,&sub2,&sub3);

marks=sub1+sub2+sub3; Read More …

C++ program that generates output as 5 10 9.

Q33. Write a program that generates the following output:

        5

        10

        9

Assign value 5 to a variable using =. Multiply it with 2 to generate 10 and subtract 1 to generate 9.

Ans.

#include<iostream.h>

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

void main()

{

int value;

value=5;

clrscr();   //for clear screen

cout<<“\n “<<value; Read More …