0% found this document useful (0 votes)
7 views15 pages

Programming Lab Manual for CS Students

Uploaded by

animakhalidgsr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views15 pages

Programming Lab Manual for CS Students

Uploaded by

animakhalidgsr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Name : Amna khalid

Class : Bscs

Course code: CSI-302

COURSE TITLE: FUNDAMENTAL OF PROGRAMMING

Semester: 2

Roll No: 190

Submitted By : Amna Khalid

Submitted To : Mam Seher

Lab Manual

Department Of Computer Scinece


(QUESTION NO 1)
Program no 1:Write a program that reads 10 positive numbers form
keyboard and determine and display the sum and average of the
numbers.
Solution:
Step no 1: visual presentation:

Step no 2: open dev c++ and create new project file.

Create
new file
option
Save file option

Step no 3 : First we display 10 number using for loop.

Step no 4: Apply the formula to getting sum.


Step no 5: Apply the average formula and display the value of sum
and average.

Output of the whole program:

F11 is a
shortcut key to
compile and
run program
(QUESTION NO 2)
Program no 2: write a program that read the four digit
numbers ,separates the number into indiviuals digits and print them
seperated by three space. Thus given number 4233, the program
should print:
4 2 3 3
Step no 1: first we get number from the user

Step no 2: total divide the number from the 1000 Add three space .

Actual number is get by:

This process repeated four times.


Output of the following program:

(QUESTION NO 3)
Print the following series using for loop:
Program no 1:
a. Print numbers from 1to 100 with increment of 1
Output of the following program:

b. Print numbers 100 to 1 with decrement of 1

C Output following program:

c. Print number from 20 to 2 in step of -2


Like this 20 18 16 14 12 10 8 6 4 2
Using decrement operator in this program

C Output following program :

d. Print sequence of number: 2,5,8,11,14,17,20


Hint (These series difference of three numbers)

C Output following program:


e. Print sequence of numbers : 99 88 77 66 55 44 33 22 11 0

C Output following program :

(Question no 4)
Program no 4: write a program to swap two intergers numbers
without and with using third variable .
a)Without using third variable

Method no 1:

1. x=x+y,
2. Y=x-y
3. X=x-y

 X=15 ,y=10
 Y=5 ,x=15
 X=10 ,y=5

C Output following program:

b) swapping using third integers:


C Output following program:

Question no 5
a. Print following shapes using simple printf statements:
*
**
***
****
*****
C Output following program:

b.
* * * * *
* * * *
* * *
* *
*
C Output following program:

c.
* * * * *
* * * *
* * *
* *
*
C Output following program:

D.
*****
* *
* *
* *
*****
Output following program:
C

The End

You might also like