Sie sind auf Seite 1von 12

A

One Day
Workshop
on
“HOW TO SOLVE IT BY COMPUTER???”
C Programming approach….

Ms.Varsha T. Lokare
Asst. Professor
Department of Computer Science & Engg.
RIT
How to Think like Programmer?
Patience

Consistency

Optimistic

Understand Syntax
TIPS TO BUILD PROGRAMMING LOGIC

 Keep Moving ON…. Try to solve many Problems,


Practice 2 or 3 times only
 Face New Problems Everyday
 Check Code by Others
 Take help from Stackoverflow Community
 Work on Projects
STEPS TO SOLVE PROBLEM STATEMENTS
1. Understand problem description, thoroughly

2. If you really understood the problem, then you


can create some tests for problem, that is:
◦ what are some valid inputs?
◦ what are some invalid inputs?
◦ what are some tricky inputs?
2. write steps, in English, to attain a solution to the
problem
◦ you should have if-condition, a loop, etc. in English
◦ do it on a paper or whiteboard
3. verify that
◦ solution covers all cases, example, all if conditions must
have else conditions
◦ solution passes the above defined valid/invalid/tricky
tests
4. write programming code
Programming Languages
 To communicate with system
Visualization Tool
http://www.pythontutor.com/visualize.html#mode
=edit
Problem Statement1
Leap years are an interesting way of putting together
lost time over the previous 4 years. These are those
years when February has 29 days. One of your
friends Raj was born on 29th of February. He
wishes to know how many times till date he lived
through his actual birthday (29th February). Take his
birth year and present year as inputs and print the
number of times he has experienced 29th of
February. Note if present year is a leap year, do
include its 29th of February as well. You may also
display an error as “Birth Year is incorrect” if the
birth year entered is not a leap year.
Problem Statement 2
Minimum difference between any two primes from
the given range
Given two integers L and R, the task is to find the
minimum difference between any two prime
numbers in the range [L, R].
Examples:
Input: L = 21, R = 50
Output: 2
(29, 31) and (41, 43) are the only valid pairs
that give the minimum difference.
Problem Statement 3

 Write a C program that accepts 4 real numbers


from the keyboard and prints out the difference
(using 4-decimal places) of the maximum and
minimum values of these numbers. Test data and
expected output: Enter four numbers: -1.5 2 7.5
11.2
 Difference is 12.7000

Das könnte Ihnen auch gefallen