Download - Elementary Programs in C Part2
-
8/14/2019 Elementary Programs in C Part2
1/8
GURUTOOLFree Self Help Tutorial for AMIE Preparation
Designed by Michael Sony
AMIE, ME
-
8/14/2019 Elementary Programs in C Part2
2/8
Foreword
It is a well known fact that passing AMIE is a Herculean task. The reason for thesame is multi fold. An AMIE student gets just notes and they have to themselves learn every
thing. AMIE students are working, hence no much time to study In the absence of class room training no continuous motivation. C being the toughest aspect for AMIE students as most diploma students
are scared about the same.
Due to these things I have thought of giving free discussions on various subjectsof AMIE. Section A & Section B (Electrical only).I intend to teach the subjects onSaturday and Sundays. Being an AMIE passed candidate I have thought ofhelping my fellow brethren with it. I can be contacted on
Michael SonyH.no 50/A, St.PedroRibander Goa403006Tel:09881079529Email:[email protected]
My Best wishes for those who seek knowledge..
Michael Sony
-
8/14/2019 Elementary Programs in C Part2
3/8
How to refer this Tutorial
This Assignments is designed for Computer and Informatics to
take care of C needs of AMIE students. Hence the no prerequisite
for these tutorials.
I intend to give you a compact and programming oriented approach
to C with hands on experience with some programs. Conceptually
it will meet the needs of students as a whole, but in addition to it, I
recommend to solve minimum five consecutive questions to get
the feel of programs asked.
A sequential reading is recommended for the first reading andsubsequently selective reading is recommended. But free of cost
contact program is recommended to understand these concepts. I
can be contacted for free of cost contact programs with prior
appointments.
-
8/14/2019 Elementary Programs in C Part2
4/8
EXERCISE B
Elementary Programs using Printf and scanf
-
8/14/2019 Elementary Programs in C Part2
5/8
-
8/14/2019 Elementary Programs in C Part2
6/8
/* the leading space before the %c ignores space characters in theinput */
scanf(" %c", &letter );
printf("Please enter a float variable ");scanf("%f", &money );
printf("\nThe variables you entered were\n");printf("value of sum = %d\n", sum );printf("value of letter = %c\n", letter );printf("value of money = %f\n", money );
}
TEST YOUR SKILLS
1. Use a printf statement to print out the value of the integer variable sum
2. Use a printf statement to print out the text string "Welcome", followed by a newline.
3. Use a printf statement to print out the character variable letter
4. Use a printf statement to print out the float variable discount
5. Use a printf statement to print out the float variable dump using two decimal places
6. Use a scanf statement to read a decimal value from the keyboard, into the integer
variable sum
7. Use a scanf statement to read a float variable into the variable discount_rate
8. Use a scanf statement to read a single character from the keyboard into the variable
operator. Skip leading blanks, tabs and newline characters.
Answers: Practise Exercise 3: printf() and scanf()
1. Use a printf statement to print out the value of the integer variable sum
printf("%d", sum);
2. Use a printf statement to print out the text string "Welcome", followed by a newline.
printf("Welcome\n");
3. Use a printf statement to print out the character variable letter
-
8/14/2019 Elementary Programs in C Part2
7/8
printf("%c", letter);
4. Use a printf statement to print out the float variable discount
printf("%f", discount);
5. Use a printf statement to print out the float variable dump using two decimal places
printf("%.2f", dump);
6. Use a scanf statement to read a decimal value from the keyboard, into the integer
variable sum
scanf("%d", &sum);
7. Use a scanf statement to read a float variable into the variable discount_rate
scanf("%f", &discount_rate);
8. Use a scanf statement to read a single character from the keyboard into the variable
operator. Skip leading blanks, tabs and newline characters.
scanf(" %c", &operator);
-
8/14/2019 Elementary Programs in C Part2
8/8
GURUTOOLFree Self Help Tutorial for AMIE Preparation
Michael Sony
H.no 50/A
St.Pedro RibanderGoa- 403006
Tel:-09881079529