Está en la página 1de 8

CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY

CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY


F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17

Practical List – 1
Sem - I

Subject Code & Name: CE141 - Computer Concepts and Programming


INSTRUCTIONS:
1. Write in a single sided file pages that should be same throughout this semester.
2. Write a heading with BLACK ink and others with BLUE ink only.
3. Write Aim, Program, Errors (syntax, logical), Input and Output.

(Knowledge Required: Constants, Variable & Data Types, Operators, I/O Operations)

1. Write a Program to display the following and explain escape sequences:


"Bitty Butler bought some butter,
but she found the butter bitter,
So she bought another butter,
to make the bitter butter better."
\t %f //This was tongue twister. \n

Ans:

 Explain Escape Sequence \n and \t and use it to solve this program.


 Also explain them that if they have to print escape sequence \n then they will have
to write \\n inside the printf statement. Similarly for \t.
 Also if they have to print %f then they will have to use %%f.

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

Explain them in both the ways.

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:

Symbolic Constant without argument:


 Use #define PI 3.14
 Use typedef float circle;
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

Symbolic Constant with argument:

6. Write a program to do following:


(a) Input an amount and convert it into rupees and paisa. (For Ex. 25.67 Rs = 25
Rs and 67 Paisa).(Implicit type Conversion)
(b) Input No of female and No of male and calculate the ratio of females to males
in a town. No of female and No of male are in int and ratio is in float. (For
CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY
CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY
F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17
Ex. No_of_Female = 10 & No_of_Male = 7 then ratio = 1.43).(Explicit type
Conversion)

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.

También podría gustarte