Download presentation
Presentation is loading. Please wait.
Published byMicah Hindle Modified over 10 years ago
1
Programming In C++ Spring Semester 2013 Practice 1-3 Lectures Programming In C++, Lecture 3 By Umer Rana
2
Practice-1 n Write a program to print you name, Class & group. Programming In C++, Lecture 3 By Umer Rana
3
Practice-1 # include Void main () { printf (“My name is Ali \n”); printf (“My Class is BSCS \n”); printf (“My Group is B \n”); getche(); } Programming In C++, Lecture 3 By Umer Rana
4
Practice-2 n Write a program to show sum of two integer number 10 & 20. Programming In C++, Lecture 3 By Umer Rana
5
Practice-2 # include Void main () { int num1=10,num2=20,sum; sum=num1+num2; printf(“Sum of integers is %d”,sum); getche(); } Programming In C++, Lecture 3 By Umer Rana
6
Practice-3 n Write a program that will demonstrate the use of escape sequences Output NameRollNoMarks Amir78425 Tahir22389 Programming In C++, Lecture 3 By Umer Rana
7
Practice-3 # include Void main () { printf(“Name \t\t Roll No\t\t Marks\n”); printf(“Amir \t\t 78 \t\t 425\n”); printf(“Tahir \t\t 22 \t\t 389\n”); getche(); } Programming In C++, Lecture 3 By Umer Rana
8
Practice-4 n Write a program that displays the ASCII code of the character typed by user. Programming In C++, Lecture 3 By Umer Rana
9
Practice-4 # include Void main () { char ch; ch=getche(); printf(“\n The ASCII code for %C is %d”,ch,ch); getche(); } Programming In C++, Lecture 3 By Umer Rana
10
Practice-5 n Write a program to print digits from 1 to 10 Programming In C++, Lecture 3 By Umer Rana
11
Practice-5 # include Void main () { int count; for(count=1; count<=10;count++) printf(“%d\n”,count); getche(); } Programming In C++, Lecture 3 By Umer Rana # include Void main () { int count=1; while(count<=10) { printf(“%d\n”,count); count=count+1; } getche(); }
12
Practice-6 n Write a program that will print asterisks (*) according to the pattern shown in: ******* ****** ***** **** *** ** * Programming In C++, Lecture 3 By Umer Rana
13
Practice-6 # include Void main () { int inner, outer; for(outer=7; outer=>1;outer--) { inner=1; while(inner<+outer) { printf(“*”); inner++ } printf(“\n”); } getche(); } Programming In C++, Lecture 3 By Umer Rana
14
Practice-6 # include Void main () { int inner, outer; for(outer=7; outer=>1;outer--) { inner=1; while(inner<+outer) { printf(“*”); inner++ } printf(“\n”); } getche(); } Programming In C++, Lecture 3 By Umer Rana
15
Practice-7 n Write a program that will print asterisks (*) according to the pattern shown in: –Re-write by replacing the inner while loop with »For loop »do- while loop –Re-write by replacing the outer for loop with »While loop »do- while loop Programming In C++, Lecture 3 By Umer Rana
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.