The document contains solutions to programming problems from the book "C Programming: Chapter-4" by E. Balagurusamy. It includes problems on input/output operators like scanf() and printf(), reading and displaying data in various formats, rounding numbers, bar charts, multiplication tables, and formatting output. Each problem has the code snippet to solve it along with sample input/output. The solutions demonstrate proper use of scanf(), printf(), and formatting specifiers to handle different data types and formats.
let us c(by yashwantkanetkar) solution chapter 4 solution 5th edition
Note:- I am not an expert. I am Engineering student. So my answer may have error or mistake
Let us C (by yashvant Kanetkar) chapter 3 SolutionHazrat Bilal
All rights reserved. No part of this slide
may be reproduced, stored in a retrieval
system, or transmitted, in any form or by
any means, without the prior permission.
This PPT is all about INTRODUCTION TO C LANGUAGE in which all basic topics are covered and the information present in this is refered from a book called "Let Us C" by YASHAVANT KANETKAR i.e. This PPT is having all important points of first chapter of "Let Us C". If any doubt plz ask us in comment.
let us c(by yashwantkanetkar) solution chapter 4 solution 5th edition
Note:- I am not an expert. I am Engineering student. So my answer may have error or mistake
Let us C (by yashvant Kanetkar) chapter 3 SolutionHazrat Bilal
All rights reserved. No part of this slide
may be reproduced, stored in a retrieval
system, or transmitted, in any form or by
any means, without the prior permission.
This PPT is all about INTRODUCTION TO C LANGUAGE in which all basic topics are covered and the information present in this is refered from a book called "Let Us C" by YASHAVANT KANETKAR i.e. This PPT is having all important points of first chapter of "Let Us C". If any doubt plz ask us in comment.
Arithmetic Operator - Basic C Programming Solve
Problems…
1. (a) Write a program that read two integer and display sum.
(b) Write a program that read two floating point and display sum.
2. Write a program that subtracts two integer.
3. Write a program that read two integer and display product.
4. (a) Write a program that divide two integer.
(b) Write a program that divide two floating point
5. Write a program that read two integer and display reminder.
6. Write a program that read radius of a circle and display its area.
7. Write a program to demonstrate the working of increment and decrement operators.
SOLVED BY
Md. Masudur Rahman
Department of Textile Engineering
4th Batch
National Institute of Textile Engineering and Research (NITER)
masudbdasia@gmail.com
Operator : Operators in C program is special symbol or word which directs the compiler to perform arithmetical or logical works, i.e. the characters which is used in C for special purpose so this character is called operators.
Different types of operators :
* Arithmetic operator
* Unary operator
* Relational operator
* Logical operator
Arithmetic
Operators niterians.blogspot.com
Operator
Meaning
+
Addition or unary plus
-
Subtraction or unary minus
*
Multiplication
/
Division
%
Modulo division
++
Increment operator increases the integer value
by one.
--
Decrement operator decreases the integer
value by one.
* Assignment operator
* Conditional operator
* Arithmetic Operators List :
* Arithmetic expressions:
An arithmetic expression is a combination of variables, constants, and operators.
For example,
(1) (b) Write a program that read two floating point and display sum.
2) Write a program that subtracts two integer.
2) Write a program that subtracts two integer
3) Write a program that read two integer and display product.
(4) (a) Write a program that divide two integer.
(4) (b) Write a program that divide two floating point
(4) (b) Write a program that divide two floating point
5) Write a program that read two integer and display reminder.
(6) (a) Write a program that read radius of a circle and display its area.
(6) (b) Write a program that read radius of a circle and display its area
(6) (b) Write a program that read radius of a circle and display its area
(6) (c) Write a program that read radius of a circle and display its area
7) Write a program to demonstrate the working of increment and decrement operators.
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
Fundamental of C Programming Language
and
Basic Input/Output Function
contents
C Development Environment
C Program Structure
Basic Data Types
Input/Output function
Common Programming Error
In C Programming create a program that converts a number from decimal.docxtristans3
In C Programming create a program that converts a number from decimal to binary. You must use a stack to complete this assignment. • Void pop() • Void push(int data) • Int top() • Int isEmpty() You must create an implementation of a stack. You may use either an array or a linked list as the underlying structure. You will, at a minimum, need to implement the following stack functions: Your program should take decimal input from the user, and convert it to binary, and simply print it out.
Solution
normal program
#include<stdio.h>
int main(){
long int decimalNumber,remainder,quotient;
int binaryNumber[100],i=1,j;
printf(\"Enter any decimal number: \");
scanf(\"%ld\",&decimalNumber);
quotient = decimalNumber;
while(quotient!=0){
binaryNumber[i++]= quotient % 2;
quotient = quotient / 2;
}
printf(\"Equivalent binary value of decimal number %d: \",decimalNumber);
for(j = i -1 ;j> 0;j--)
printf(\"%d\",binaryNumber[j]);
return 0;
}
using stack
.
Ex.1 Write a program to print the following pattern
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Ex.2 Write a program to find bigger of three integers.
Ex.3 Write a program to calculate GCD between two numbers.
Ex.4 Write a program to find transpose of matrix.
Ex.5 Write a program which deletes an element from an array & display all other elements.
Ex.6 Write a program to calculate XA+YB where A & B are matrix & X=2, Y=3.
Ex.7 Write a program to calculate the total amount of money in the piggy bank, given that coins of Rs.10, Rs.5, Rs.2, RS.1.
& many more.....
Implementation Of GSM Based Fire Alarm and Protection SystemBUBT
Now we are going to build a very interesting project – a Fire Alarm System which will send SMS to a set of Mobile Numbers when fire occurs in a particular location. This fire alarm project make use of modern communication technologies.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
1. E. Balagurusamy C PROGRAMMING: CHAPTER-4
Managing Input & output Operators
4.6 STATES ERRORS,IF ANY,IN THE FOLLOWING
STATEMENTS.
[A] :scanf(“%c %f %d”,city,&price,&year);
=NO ERROR.
[B] :scanf(“%s %d”,city,amount);
= THERE WILL BE A & BEFORE AMOUNT.
[C] :scanf(“%f %d”,&amount,&year);
=NO ERROR.
[D] :scanf(n”%f”,root);
=n will remain into double quote.
[E] :scanf(“%c %d %ld”,*code,&count,root);
=* IS NOT ALLOWED BEFORE CODE AND &WILL STAY
BEFORE ROOT.
4.7 WHAT WILL BE THE VALUES STORED OF THE VARIABLES
YEAR AND CODE WHEN THE DATA 1988,X ?
[A] :scanf(“%d %c”,&year,&code);
=YEAR STORS 1988 AND CODE STORS X.
[B] :scanf(“%c %d”,&year,&code);
= YEAR STORS X AND CODE STORS 1988.
[C] :scnaf(“%d %c”,&code,&year);
2. =CODE STORS 1988 AND YEAR STORS X.
4.8 COUNT,PRICE,CITY HAVE VALUES:
COUNT=1275,
PRICE=235.74,
CITY=CAMBRIDGE.
WHAT WILL BE THE OUTPUT THE STATEMENT ?
[A] :printf(“%d %f”,count,price);
OUTPUT=1275 235.75.
[B] :printf(“%d %f”,price,count);
OUTPUT=36576 790980
[C] :printf(“%c”,city);
OUTPUT=CAMBRIDGE
4.9 SHOW THE WRONG OF THE OUTPUT STATEMENTS.
[A] :printf(“%d.7.2%f”,year,amount);
WRONG=7.2 SHOULD REMAIN AFTER THE %
[B] :printf(“%-s,%c”n,city,code);
WRONG=COMMA IS NOT ALLOWED AND n SHOULD STAY
INTO QUOTATION.
[C] :printf(“%f %d %s”,price,count,city);
=NO WRONG.
4.10 WHAT VALUES DOSE THE COMPUTER ASSIGN OF THIS
INPUT STATEMENTS?
Scanf(“%4d %*d”,&year,&code,&count);
IF DATA KYED IN 19883745
3. 0UTPUT=1988.
4.11 HOW CAN WE USE getcher() FUNCTION TO
MULTICHARACTER STRINGS?
= BY INCLUDING SINGLE QUOTATION OVER
MULTICHARACTER WE
CAN USE getchar() FUNCTION.
4.12 HOW CAN WE USE putchar() FUNCTION TO
MULTICHARACTER STRINGS?
= BY INCLUDING SINGLE QUOTATION OVER
MULTICHARACTER WE
CAN USE putchar() FUNCTION.
4.13 WHAT IS THE PURPOSE OF scanf() FUNCTION?
=IF WE WANT TO TAKE DATA AFTAR RUNNING THE
PROGRAMM THEN
WE USE scanf FUNCTION.
4.14 DESCRIBE THE PURPOSE OF COMMONLY USED
CONVERSION CHARACTERS IN A scanf() FUNCTION ?
=IT INDICATES WHAT TYPES OF DATA WE TAKE AS INPUT.
4.15 WHAT HAPPENS WHEN AN INPUT DATA ITEM CONTAIN ?
[A] MORE CHARACTERS THAN SPECIFIED FIELD WIDTH.
=VALUE WILL BE RIGHT-JUSTIFIED.
[B] FEWER CHARACTER THAN SPECIFIED FIELD WIDTH.
=VALUE WILL BE LEFT-JUSTEFIED.
4.16 WHAT IS THE PURPOSE OF printf() FUNCTION ?
=IT IS USED TO SHOW ANYTHIG ON OUTPUT.
4. 4.17 DESCRIBE THE PURPOSE OF COMMONLY USED
CONVERSION CHARACTERS IN A printf() FUNCTION ?
= IT INDICATES WHAT TYPES OF DATA WE WANT TO SHOW
ON
OUTPUT.
4.18 WHAT HAPPENS WHEN AN 0UTPUT DATA ITEM
CONTAIN ?
[A] MORE CHARACTERS THAN SPECIFIED FIELD WIDTH.
=VALUE WILL BE RIGHT-JUSTIFIED.
[B] FEWER CHARACTER THAN SPECIFIED FIELD WIDTH.
=VALUE WILL BE LEFT-JUSTEFIED.
Problem no. 4.1:Given the string“WORDPROCESSING”,
Write a program to read the string from the terminal and
Display the same in the following format:
(a)WORD PROCESSING
(b)WORD
PROCESSING
(c) W.P.
Solution:
#include<stdio.h>
#include<conio.h>
5. void main()
{
char s[10],d[11];
clrscr();
printf("Enter the string: ");
scanf("%4s%10s",s,d);
printf("(a)%s %sn",s,d);
printf("(b)%sn%sn",s,d);
printf("(c)%.1s.%.1s",s,d);
getch();
}
Output:
Enter the string: WORDPROCESSING
(a) WORDPROCESSING
(b) WORD
PROCESSING
(c) W.P.
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:
(a)(x+y)/(x-y) (b)(x+y)/2 (c)(x+y)*(x-y)
7. Output:
Enter the value of x & y: 4 3
(a)=7.00
(b)=3.50
(c)=12.00
Enter the value of x & y: 7 7
(a)= imagine
(b)=7.00
(c)=0.00
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
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int p,i;
float a;
8. clrscr();
printf("ENTER REAL NUMBER FOR GET NEAREST INTEGER
NUMBERn");
for(i=1;i<=4;i++)
{
scanf("%f",&a);
if(a>=0)
p=a+0.5;
else
p=a-0.5;
printf("nNEAREST INTEGER NUMBER OF %f IS=
%dn",a,(int)p);
}
getch();
}
Output:
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
9. 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,
* * * *
* * * * 4.36
* * * *
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
float a1,a2,a3,a4;
int x,y,z,t,i;
10. clrscr();
printf("Enter four float number:");
scanf("%f%f%f%f",&a1,&a2,&a3,&a4);
x=a1+0.5;y=a2+0.5;z=a3+0.5;t=a4+0.5;
printf("The horizontal bar chard is:n");
for(i=0;i<x;i++)
printf("* ");
printf("%.2fn",a1);
for(i=0;i<y;i++)
printf("* ");
printf("%.2fn",a2);
for(i=0;i<z;i++)
printf("* ");
printf("%.2fn",a3);
for(i=0;i<t;i++)
printf("* ");
printf("%.2fn",a4);
getch();
}
Output:
Enter four float number: 4.85 4.36 3.12 5.47
The horizontal bar chard is:
11. * * * * * 4.85
* * * * 4.36
* * * 3.12
* * * * * 5.47
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.
45
X 37
7x45 is 315
3x45is 135
Add them 1665
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,p;
clrscr();
printf("Enter 2 two digits number:");
scanf("%d%d",&a,&b);
printf(" t%4dntx%3dn",a,b);
13. Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z;
clrscr();
printf("Enter three integer value of x,y,&z:");
scanf("%d%d%d",&x,&y,&z);
printf("(a) X=%d,",x);
printf("Y=%d,",y);
printf("Z=%dn",z);
printf("(b) X=%3d, Y=%2d, Z=%2dn",x,y,z);
printf("(c) X= %d, Y=%d, Z=
%d",x,y,z);
getch();
}
Output:
Enter three integer value of x,y,&z: 45 27 89
(a) X=45, Y=27, Z=89
(b) X=45, Y=27, Z=89
(c) X=45, Y=27, Z=89
14. Problem no.4.7: Write a program that prints the value 10.45678 in
exponential format with the following specifications:
(a)correct to two decimal place,
(b)correct to four decimal place and
(c)correct to eight decimal place.
Solution:
#include <stdio.h>
#include<conio.h>
int main(void)
{
float a=10.45678,x,y,z;
clrscr();
16. (b)correct to four decimal place and
(c)correct to zero decimal place.
Solution:
#include <stdio.h>
#include<conio.h>
void main()
{
float a=345.6789;
clrscr();
printf("The two decimal place is: %.2fn",a);
printf("The five decimal place is: %.5fn",a);
printf("The zero decimal place is: %.0f",a);
getch();
}
Output:
The two decimal place is: 345.67
The five decimal place is: 345.67889
The two decimal place is: 345
17. Problem no.4.9: Write a program to read the name ANIL KUMAR
GUPTA in three parts using the scanf statement and to display the
same in the following format using the printf statement.
(a) ANIL K. GUPTA
(b) A. K. GUPTA
(c) GUPTA A. K.
Solution:
#include<stdio.h>
#include<conio.h>
void main()
18. {
char s[6],d[6],c[6];
clrscr();
printf("Enter the string:");
scanf("%5s%5s%5s",s,d,c);
printf("(a) %s %.1s. %sn",s,d,c);
printf("(b) %.1s.%.1s.%sn",s,d,c);
printf("(c) %.1s.%.1s.n",c,s,d);
getch();
}
Output:
Enter the string: ANIL KUMAR GUPTA
(a) ANIL K. GUPTA
( b) A. K. GUPTA
(d) GUPTA A. K.
19. Problem no.4.10: Write a program to read and disply the following table
of data
Name Code Price
Fan 67831 1234.50
Motor 450 5786.70
The name and code must be left-justified and price must be
right-justified .
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int code1,code2;
float price1,price2;
char name1[10],name2[10];
clrscr();
printf("Enter first name ,code and price :");
scanf("%s%d%f",name1,&code1,&price1);
printf("Enter second name ,code and price :");
scanf("%s%d%f",name2,&code2,&price2);
printf("NametCodetPricen");
printf("%-st%-dt%.2fn",name1,code1,price1);
20. printf("%-st%-dt%.2fn",name2,code2,price2);
getch();
}
Output:
Enter first name ,code and price : Fan 67831 1234.50
Enter second name ,code and price : Motor 450 5786.70
Name Code Price
Fan 67831 1234.50
Motor 450 5786.70
Reference:
http://hstuadmission.blogspot.com/2010/12/solution-programming-in-
ansi-c-chapter.html