SOLUTION PROGRAMMING IN ANSI C: CHAPTER-4 – Assignment2Do

4 programming

SOLUTION PROGRAMMING IN ANSI C: CHAPTER-4

Post navigation

Write a program to read the string from the terminal and

Display the same in the following format:

Enter the string: WORDPROCESSING

Problem no. 4.2: Write a program to read the values of x and y and print the results of the following expression in one line:

Enter the value of x & y: 4 3

Enter the value of x & y: 7 7

Problem no. 4.3: Write a program to read the following numbers, round them off to the nearest integers and print out the results in integer form:

35.7 50.21 -23.73 -46.45

printf(“\nNEAREST INTEGER NUMBER OF %f IS= %d\n”,a,(int)p);

ENTER REAL NUMBER FOR GET NEAREST INTEGER NUMBER 35.7

NEAREST INTEGER NUMBER OF 35.7 IS= 36

ENTER REAL NUMBER FOR GET NEAREST INTEGER NUMBER 50.21

NEAREST INTEGER NUMBER OF 50.21 IS=50

ENTER REAL NUMBER FOR GET NEAREST INTEGER NUMBER -23.73

NEAREST INTEGER NUMBER OF -23.73 IS= -24

ENTER REAL NUMBER FOR GET NEAREST INTEGER NUMBER -46.45

NEAREST INTEGER NUMBER OF -46.45 IS= -46

Problem no. 4.4:write a program that read 4 floating values in the range, 0.0 to20.0, and prints a horizontal bar chart to represent these values using the character * as the fill character. For the purpose of the chart, the values may be rounded off to the nearest integer . For the example , the value 4.36 should be represented as follos,

printf(“Enter four float number:”);

printf(“The horizontal bar chard is:\n”);

Enter four float number: 4.85 4.36 3.12 5.47

The horizontal bar chard is:

Problem no.4.5: Write a program to demonstrate the process of multiplication. The program should ask the user to enter two two digit integer and print the product of integers as shown bellow.

printf(“Enter 2 two digits number:”);

Problem no.4.6: Write a program to read three integers from the keyboard using one scanf statement and output them on one line using:

(b)only one printf with conversion specifiers and

(c) only one printf without conversion specifiers.

printf(“Enter three integer value of x,y,&z:”);

Enter three integer value of x,y,&z: 45 27 89

Problem no.4.7: Write a program that prints the value 10.45678 in exponential format with the following specifications:

Problem no.4.8 Write a program to print the value 345.6789 in fixed-point format with the following specifications:

printf(“The two decimal place is: %.2f\n”,a);

printf(“The five decimal place is: %.5f\n”,a);

printf(“The zero decimal place is: %.0f”,a);

Leave a Reply

Your email address will not be published. Required fields are marked *