Projects 1 (6 May 2001)
This page is for checking your knowledge of C++. Basically I'll put up a few problems which you have to solve using C++ programming. After a few days I'll put up the answers so that you can check up on them. The project section will appear in regular intervals throughout my site.
This section has been added by request. I hope it helps you in learning C++ and developing your skills.
So, we'll start with a couple of simple program.
First Program :
Write a program in C++ to check whether a given year is a leap year. The conditions are : First get the year from the user. A year is a leap year if it is divisible by 4 and not by 100 (divisible means when you divide by that number the remainder should be zero). If a year is divisible by 400 then the display should be that the year is a century leap year. Otherwise the year is not a leap year.
Second Program :
Make use of the switch...case syntax to create a simple calculator. You have to get the value of two numbers. Then you have to ask the user what he wants to do - add, subtract, multiply or divide. If the user types 'a' then addition should be performed. If the user types 's' then subtraction should be performed and so on. The result of the operation performed should be displayed.
If you have any questions or doubts regarding the above programs then don't hesitate to email me at : ssbell2000@yahoo.com
Check out the solution for the above program : Solution to Section 1
or go to the next section on : Functions
or go back to Contents
Copyright © 2002 Sethu Subramanian All rights reserved.