1 / 15

Programming In C++

Programming In C++. Spring Semester 2013 Practice 1-3 Lectures. Practice-1. Write a program to print you name, Class &amp; group. Practice-1. # include &lt; stdio.h &gt; # include &lt; cosio.h &gt; Void main () { printf (“My name is Ali <br>”); printf (“My Class is BSCS <br>”);

lynton
Download Presentation

Programming In C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming In C++ Spring Semester 2013 Practice 1-3 Lectures Programming In C++, Lecture 3 By UmerRana

  2. Practice-1 • Write a program to print you name, Class & group. Programming In C++, Lecture 3 By UmerRana

  3. Practice-1 # include <stdio.h> # include <cosio.h> 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 UmerRana

  4. Practice-2 • Write a program to show sum of two integer number 10 & 20. Programming In C++, Lecture 3 By UmerRana

  5. Practice-2 # include <stdio.h> # include <cosio.h> 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 UmerRana

  6. Practice-3 • Write a program that will demonstrate the use of escape sequences Output Name RollNo Marks Amir 78 425 Tahir 22 389 Programming In C++, Lecture 3 By UmerRana

  7. Practice-3 # include <stdio.h> # include <cosio.h> 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 UmerRana

  8. Practice-4 • Write a program that displays the ASCII code of the character typed by user. Programming In C++, Lecture 3 By UmerRana

  9. Practice-4 # include <stdio.h> # include <cosio.h> Void main () { char ch; ch=getche(); printf(“\n The ASCII code for %C is %d”,ch ,ch); getche(); } Programming In C++, Lecture 3 By UmerRana

  10. Practice-5 • Write a program to print digits from 1 to 10 Programming In C++, Lecture 3 By UmerRana

  11. Practice-5 # include <stdio.h> # include <cosio.h> Void main () { int count=1; while(count<=10) {printf(“%d\n”,count); count=count+1; } getche(); } # include <stdio.h> # include <cosio.h> Void main () { int count; for(count=1; count<=10;count++) printf(“%d\n”,count); getche(); } Programming In C++, Lecture 3 By UmerRana

  12. Practice-6 • Write a program that will print asterisks (*) according to the pattern shown in: ******* ****** ***** **** *** ** * Programming In C++, Lecture 3 By UmerRana

  13. Practice-6 # include <stdio.h> # include <cosio.h> 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 UmerRana

  14. Practice-6 # include <stdio.h> # include <cosio.h> 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 UmerRana

  15. Practice-7 • 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 UmerRana

More Related