Practical 1 - Solution PDF
Practical 1 - Solution PDF
Practical 1 - Solution PDF
Practical List – 1
Sem - I
(Knowledge Required: Constants, Variable & Data Types, Operators, I/O Operations)
Ans:
2. Two numbers are input through the keyboard into two Locations C and D. Write a
program to interchange (swap) the contents of C and D with and without using third
variable.
Ans:
CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY
CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY
F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17
3. In a town, the percentage of men is 52.The percentage of total literacy is 48. If total
percentage of literate men is 35 of the total population, write a program to find the
total number of illiterate men and women if the population of the town is 80,000.
Ans:
4. A cashier has currency notes of denominations 10, 50 and 100. If the amount to be
withdrawn is input through the keyboard in hundreds, find the total number of
currency notes of each denomination the cashier will have to give to the withdrawer.
Ans:
CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY
CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY
F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17
5. Write a program to calculate area of two circle. (πr2). Use Preprocessor directive
named macro expansion for the symbol π (Symbolic Constant) without argument and
with argument. Use typedef to rename the float datatype.
Ans:
Ans:
7. The quadratic equation is given by ax2 + bx + c = 0 and the roots of the quadratic
−𝒃+√𝒃𝟐 −𝟒𝒂𝒄 −𝒃−√𝒃𝟐 −𝟒𝒂𝒄
equation are x1 and x2 and they are given by 𝒙𝟏 = and 𝒙𝟐 =
𝟐𝒂 𝟐𝒂
Write a program to find out Roots of a Quadratic Equations. Use pow() & sqrt ()
function of < maths.h> header file.
CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY
CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY
F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17
CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY
CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY
F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17
8. Write a program to input a character using getchar () and print the character using
putchar () and check the character category. Also convert uppercase alphabet to
lower case and vice versa. (Use Character Test Functions : isalnum(), isalpha(),
isdigit(), islower(), isprint(), ispunct(), isspace(), isupper()) and (toupper() &
tolower()) of <ctype.h> header file.