World Top Softwares
Login Please

Join the forum, it's quick and easy

World Top Softwares
Login Please
World Top Softwares
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Log in

I forgot my password

Latest topics
» Practically as cut-price as files
2nd lab of 2nd semister EmptyMon Aug 01, 2011 11:44 pm by Guest

» Netbook Brands
2nd lab of 2nd semister EmptyMon Aug 01, 2011 5:39 am by Guest

» backlinks checker backlink service
2nd lab of 2nd semister EmptySun Jul 31, 2011 8:56 am by Guest

» how to buy facebook fans f4
2nd lab of 2nd semister EmptySat Jul 30, 2011 2:34 pm by Guest

» Alle bijzondere dingen in de zaanstreek
2nd lab of 2nd semister EmptySat Jul 30, 2011 8:11 am by Guest

» HERE YOU CAN POST ALL WEBSITE LINKS...
2nd lab of 2nd semister EmptyWed Aug 26, 2009 2:16 pm by onesimpletech

» cool web site for all must check it
2nd lab of 2nd semister EmptyMon Jul 06, 2009 2:32 pm by Snopy Cobra

» poetry spirit
2nd lab of 2nd semister EmptyMon Jul 06, 2009 2:31 pm by Snopy Cobra

» best to learn VC++
2nd lab of 2nd semister EmptySun May 10, 2009 3:22 pm by Guest

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
Statistics
We have 30 registered users
The newest registered user is deigavr

Our users have posted a total of 191 messages in 126 subjects
Who is online?
In total there are 2 users online :: 0 Registered, 0 Hidden and 2 Guests

None

[ View the whole list ]


Most users ever online was 125 on Wed Apr 07, 2021 9:18 am
RSS feeds


Yahoo! 
MSN 
AOL 
Netvibes 
Bloglines 



2nd lab of 2nd semister

Go down

2nd lab of 2nd semister Empty 2nd lab of 2nd semister

Post by Snopy Cobra Wed Feb 11, 2009 5:52 am




Lab # 2





Objective





Basic Programming review on variables, switch statement, Iteration constructs, arrays,
strings.








Theory








Variables




“A variable is a space in the
computer’s memory set aside for a certain kind of data and given a name for
easy reference.”





Variables may be the most
fundamentals aspect of any computer language. Variables are used so that the
same space in memory can hold different values at different times. For
instance, suppose you are writing a program to calculate someone’s paycheck,
you will need to store at least the hourly rate and the hours worked. If you
want to do the calculation for more than one employee, you will need to use the
same program and the same spaces in memory to store similar data for additional
employees. A variable is a space in memory that plays the same role many times,
but may contain a different value each time.







Switch Statement A switch statement is a type of control statement that exists in most modern imperative programming languages (e.g., C, C++, C#, and Java). Its purpose is to allow the value of a variable or expression to control the flow of program execution. In some other programming languages, a statement that is syntactically different but conceptually the same as the switch statement is known as a case statement or a select statement.








For Loop







“A for loop is a programming language statement which allows code to be repeatedly executed. A for loop is classified as an iteration statement.”


The for loop is almost universally held to be the most commonly
used loop. This is extremely useful when you have to execute a given set of
instruction a limited number of times with little or no changes. This loop will
start with giving a variable a predefined value and then keep on executing the
body part of the loop as long as the given condition is true. Every time the
loop is executed, the variable gets a new value.

Arrays “A capability that enables the user to define a set of ordered data items known as an array.” An array is a data structure consisting of a group of elements that are accessed by indexing. In most programming languages each element has the same data type and the array occupies a contiguous area of storage. Arrays can be classified as fixed-sized arrays (sometimes known as static arrays) whose size cannot change once their storage has been allocated.


Strings




“A string is a contiguous sequence of symbols or values, such as a character string (a sequence of characters) or a binary digit string (a sequence of binary values).” Strings are the form of data used in programming languages for storing and manipulating text String is generally understood as a data type storing a sequence of data values, usually bytes, in which elements stand for characters. A variable declared to have a string data type usually causes storage to be allocated in memory that is capable of holding some predetermined number of symbols. Functions


Task





1.
Take a character letter as input. Check and display
whether the input value is a vowel or not.





2.
Calculate and display the number of days in a given
month using the Switch statement.





3.
Write and run a program that reads an angle (expressed
in degrees) and states in which quadrant the given angle lies. An angle A is
said to be in the





* first quadrant if it is in
the range 0 <= A < 90


* second quadrant if it is in
the range 90 <= A < 180


* third quadrant if it is in
the range 180 <= A < 270


* and fourth quadrant if it is
in the range 270 <= A < 360.





4.
Use nested for loop to calculate the factorial of n.





5.
Write a program that computes and prints the sum of
each column of a 2-D array.








6. Write
a program that asks for user's name and then writes it back with the first name
as entered, and the second name all in capital letters.

Enter your name: Sherlock Holmes Sherlock HOLMES


7. Write
a program that input a string, reverses the string using Function.





Snopy Cobra
Snopy Cobra
Admin
Admin

Number of posts : 99
Age : 34
Location : Bahria University Karachi
Reputation : 0
Registration date : 2008-07-31

https://telecompk.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum