Presentation is loading. Please wait.

Presentation is loading. Please wait.

Appendix Lab Manual for Programming Skills 1. Symbols used in Writing Programs { opening curly bracket } closing curly bracket # hash sign or number sign.

Similar presentations


Presentation on theme: "Appendix Lab Manual for Programming Skills 1. Symbols used in Writing Programs { opening curly bracket } closing curly bracket # hash sign or number sign."— Presentation transcript:

1 Appendix Lab Manual for Programming Skills 1

2 Symbols used in Writing Programs { opening curly bracket } closing curly bracket # hash sign or number sign (shift+3) ( ) small brackets “aaaa ”double quotes ‘ aaaa ‘ single quotes, comma ; semicolon void main( ) main function // is used for making comment in one line /* is used for making comment in block form */ 2

3 Unit: 1 Objective: To understand the concept of comments, input,output Statements and data types. //PROGRAM-1 to demonstrate cout... COMMENTS // is used for making comment in program #include //PREPROCESSOR void main( ) // FUNCTION WITH RETURN TYPE VOID {//Beginning cout<<"WELCOME TO VC++ World "< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_3.jpg", "name": "Unit: 1 Objective: To understand the concept of comments, input,output Statements and data types.", "description": "//PROGRAM-1 to demonstrate cout... COMMENTS // is used for making comment in program #include //PREPROCESSOR void main( ) // FUNCTION WITH RETURN TYPE VOID {//Beginning cout<< WELCOME TO VC++ World <

4 Unit: 1 Program Explanation #include Include directive tells the compiler Where to find information about input and output that are used in Your program cout (see-out) used for output to the monitor “<<“ is the insertion operator ‘\n’ causes a new line to be started on the monitor 4

5 Unit: 1 //PROGRAM-2 to demonstrate cin cout (int, float,char)... #include void main( ) { int a; float b; char c; cout<<"ENTER AN INTEGER VALUE"<>a; cout<<"ENTER A FLOAT VALUE"<>b; cout<<"ENTER A CHARACTER OR Alphabet"<>c; cout<<"INTEGER= "< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_5.jpg", "name": "Unit: 1 //PROGRAM-2 to demonstrate cin cout (int, float,char)...", "description": "#include void main( ) { int a; float b; char c; cout<< ENTER AN INTEGER VALUE <>a; cout<< ENTER A FLOAT VALUE <>b; cout<< ENTER A CHARACTER OR Alphabet <>c; cout<< INTEGER= <

6 Unit: 1 Program Explanation cin >> a; cin (see-in) used for input from the keyboard “>>” extracts data from the keyboard Think of cin as a name for the keyboard “>>” points from the keyboard to a variable where the data is stored 6

7 Unit: 1 //PROGRAM-3 to find Sum and Average of two numbers. #include void main( ) { folat a,b; float sum,avg; cout<<"ENTER TWO NUMBERS"<>a>>b; sum = a + b; avg = sum/2; cout<<"SUM = "< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_7.jpg", "name": "Unit: 1 //PROGRAM-3 to find Sum and Average of two numbers.", "description": "#include void main( ) { folat a,b; float sum,avg; cout<< ENTER TWO NUMBERS <>a>>b; sum = a + b; avg = sum/2; cout<< SUM = <

8 Unit: 1 //PROGRAM-4 to find Sum and Average of three numbers. #include void main( ) { folat a,b,c; float sum,avg; cout<<"ENTER THREE NUMBERS"<>a>>b>>c; sum = a + b + c; avg = sum/3; cout<<"SUM = "< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_8.jpg", "name": "Unit: 1 //PROGRAM-4 to find Sum and Average of three numbers.", "description": "#include void main( ) { folat a,b,c; float sum,avg; cout<< ENTER THREE NUMBERS <>a>>b>>c; sum = a + b + c; avg = sum/3; cout<< SUM = <

9 Uint: 1 Check Your Programming skills: Write a C++ program to find the difference between two Numbers? Write a C++ program to find the product of three numbers? Convert feet to inches given 1 feet= 12 inches? 9

10 Unit: 2 Objectives: To implement the concept of operators // PROGRAM-5 to find area of a circle. #include void main( ) { float r,area; const float pi=3.147; cout<<"ENTER RADIUS OF CIRCLE"<>r; area = pi*r*r; cout<<"AREA OF CIRCLE = "< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_10.jpg", "name": "Unit: 2 Objectives: To implement the concept of operators // PROGRAM-5 to find area of a circle.", "description": "#include void main( ) { float r,area; const float pi=3.147; cout<< ENTER RADIUS OF CIRCLE <>r; area = pi*r*r; cout<< AREA OF CIRCLE = <

11 Unit: 2 //Program -6 to display Pay slip of an employee #include void main () { double GSal,NSal,ded,basic,da; const double Housing=1000.00, TA=500.00; cout<<"Enter Basic Salary\n"; cin>>basic; cout<<"Enter Deduction Amount\n"; cin>>ded; da=basic*0.2; GSal=basic+da+Housing+TA; NSal=GSal-ded; 11

12 Unit: 2 ….. cout<<"\t\t\t\tBasic:\t"< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_12.jpg", "name": "Unit: 2 …..", "description": "cout<< \t\t\t\tBasic:\t <

13 Unit: 2 Check Your Programming skills Write a C++ program to find the area of Square? Write a C++ program to find the volume of Square? Convert centigrade to Fahrenheit given F=((C/5)*9) + 32? Write a C++ program to create an invoice of item? 13

14 Unit: 3 Objectives:To understand the concepts of conditional statements Or control structure.( if – else ) //Program -7 to find Number is MAX or MIN #include void main() { int a,b; cout<<"Enter two numbers\n"; cin>>a>>b; if(a>b) cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_14.jpg", "name": "Unit: 3 Objectives:To understand the concepts of conditional statements Or control structure.( if – else ) //Program -7 to find Number is MAX or MIN #include void main() { int a,b; cout<< Enter two numbers\n ; cin>>a>>b; if(a>b) cout<>a>>b; if(a>b) cout<

15 Unit: 3 //Program -8 to find number is ODD OR EVEN #include void main() { int num; cout<<"Enter a number\n"; cin>>num; if(num%2==0) cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_15.jpg", "name": "Unit: 3 //Program -8 to find number is ODD OR EVEN #include void main() { int num; cout<< Enter a number\n ; cin>>num; if(num%2==0) cout<>num; if(num%2==0) cout<

16 Unit: 3 //Program -9 to find the Grade of students #include void main() { int mark; char grade; cout<<"Enter mark"; cin >> mark; if(mark >= 90 && mark <= 100 ) grade='A'; if(mark >= 80 && mark <= 89 ) grade='B'; 16

17 Unit: 3 …… if(mark >= 70 && mark <= 79 ) grade='C'; if(mark >= 60 && mark <= 69 ) grade='D'; if(mark < 60 ) grade='F'; cout<<"Mark"<<"\t"<<"Grade"< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_17.jpg", "name": "Unit: 3 …… if(mark >= 70 && mark <= 79 ) grade= C ; if(mark >= 60 && mark <= 69 ) grade= D ; if(mark < 60 ) grade= F ; cout<< Mark << \t << Grade <= 70 && mark <= 79 ) grade= C ; if(mark >= 60 && mark <= 69 ) grade= D ; if(mark < 60 ) grade= F ; cout<< Mark << \t << Grade <

18 Unit: 3 Check Your Programming Skills: Write a C++ program to find the largest among three numbers by using if-else? Write a C++ program to find whether the given number is Prime number or not by using if-else? Write a C++ program to find whether the given number is divisible of 5 or not by using if-else? 18

19 Unit: 4 Objectives:To understand the concepts of conditional statements Or control structure.( Switch – Case ) //Program-10 to check the day of week by using SWITCH-CASE #include void main() { int x; cout<<"Enter number"<>x; switch(x) { case 1: cout<<"Saturday"< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_19.jpg", "name": "Unit: 4 Objectives:To understand the concepts of conditional statements Or control structure.( Switch – Case ) //Program-10 to check the day of week by using SWITCH-CASE #include void main() { int x; cout<< Enter number <>x; switch(x) { case 1: cout<< Saturday <>x; switch(x) { case 1: cout<< Saturday <

20 Unit: 4 …… case 2: cout<<"Sunday"< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_20.jpg", "name": "Unit: 4 …… case 2: cout<< Sunday <

21 Unit: 4 …… case 6: cout<<"Thursday"< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_21.jpg", "name": "Unit: 4 …… case 6: cout<< Thursday <

22 Unit: 4 // Program- 11 Menu driven program ( +, *, -, %) using switch case statement #include void main() { int n1, n2; char op; cout > n1; cout > n2; cout > op; switch (op) { case '*‘:cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_22.jpg", "name": "Unit: 4 // Program- 11 Menu driven program ( +, *, -, %) using switch case statement #include void main() { int n1, n2; char op; cout > n1; cout > n2; cout > op; switch (op) { case *‘:cout< n1; cout > n2; cout > op; switch (op) { case *‘:cout<

23 Unit: 4 ….. case '/‘:cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_23.jpg", "name": "Unit: 4 …..", "description": "case /‘:cout<

24 Unit: 4 Check Your Programming Skills: Write a C++ program to find month of years by using a switch case statement? Write a menu driven program to calculate different currency Conversions? 24

25 Unit: 5 Objectives:To understand the concepts of conditional statements Or control structure.( Loops: FOR, WHILE, DO WHILE ) // Program-12 to print natural numbers from 1 to 30 using FOR loop #include void main() { int i; for (i=0;i<=30;i++) { cout<<" "<<"i="; cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_25.jpg", "name": "Unit: 5 Objectives:To understand the concepts of conditional statements Or control structure.( Loops: FOR, WHILE, DO WHILE ) // Program-12 to print natural numbers from 1 to 30 using FOR loop #include void main() { int i; for (i=0;i<=30;i++) { cout<< << i= ; cout<

26 Unit: 5 // Program-13 to print natural numbers from 1 to 30 using WHILE loop #include void main() { int a=1; while(a<=30) { cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_26.jpg", "name": "Unit: 5 // Program-13 to print natural numbers from 1 to 30 using WHILE loop #include void main() { int a=1; while(a<=30) { cout<

27 Unit: 5 // Program-14 to print natural numbers from 1 to 30 using DO WHILE loop #include void main() { int a=1; do { cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_27.jpg", "name": "Unit: 5 // Program-14 to print natural numbers from 1 to 30 using DO WHILE loop #include void main() { int a=1; do { cout<

28 Unit: 5 //Program -15 to display first 10 Odd numbers using FOR loop #include void main() { int i; for (i=1;i<=20;i=i+2) cout<<" i="< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_28.jpg", "name": "Unit: 5 //Program -15 to display first 10 Odd numbers using FOR loop #include void main() { int i; for (i=1;i<=20;i=i+2) cout<< i= <

29 Unit: 5 //Program-17 to display first 10 Odd numbers using WHILE loop #include void main() { int a=1; while(a<=20) { cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_29.jpg", "name": "Unit: 5 //Program-17 to display first 10 Odd numbers using WHILE loop #include void main() { int a=1; while(a<=20) { cout<

30 Unit: 5 //Program-18 to display first 10 Odd numbers using DO WHILE loop #include void main() { int a=1; do { cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_30.jpg", "name": "Unit: 5 //Program-18 to display first 10 Odd numbers using DO WHILE loop #include void main() { int a=1; do { cout<

31 Unit: 5 //Program-19 to find the Factorial of Number using do while loop #include void main() { int n,i=1,fact=1; cout<<" enter the number "; cin>>n; if(n>=0) { do { fact=fact*i; i++; } 31

32 Unit: 5 ….. while(i<=n); cout<<"fact="< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_32.jpg", "name": "Unit: 5 ….. while(i<=n); cout<< fact= <

33 Unit: 5 Check Your Programming Skills: Write a C++ program to display first 10 even numbers using For loop? Write a C++ program to display first 10 even numbers using WHILE loop? Write a C++ program to display first 10 even numbers using DO WHILE loop? Write a C++ program to find the Factorial of Number using For loop? Write a C++ program to print all prime numbers between two limits by using do while loop? 33

34 Unit: 6 Objectives:To understand the concepts of nested loops // Program-20 Program to display stars in a triangle shape #include void main() { int i,j,k,n,m; cout<<"Enter a number"; cin>>n; m=n; for(i=0;i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_34.jpg", "name": "Unit: 6 Objectives:To understand the concepts of nested loops // Program-20 Program to display stars in a triangle shape #include void main() { int i,j,k,n,m; cout<< Enter a number ; cin>>n; m=n; for(i=0;i>n; m=n; for(i=0;i

35 Unit: 6 ….. for(k=0;k { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_35.jpg", "name": "Unit: 6 ….. for(k=0;k

36 Unit: 6 Check Your Programming Skills: Write a C++ program to display different types of triangles * * * * ** * * * ** * Write a C++ program to display following patterns? ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 36

37 Unit: 7 Objectives:To understand the concept of arrays // Program-21 program to store 5 numbers in an array then print them #include void main() { int a[5],i; for(i=0;i<5;i++) { cout<<"enter any Number :"<>a[i]; } 37

38 Unit: 7 ….. cout<<"The Elements are as below : "< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_38.jpg", "name": "Unit: 7 ….. cout<< The Elements are as below : <

39 Unit: 7 // Program-23 program using arrays for checking Maximum number and Minimum number among elements #include void main() { int a[8],i,max,min; cout<<"Enter 8 number:"<>a[i]; max=min=a[0]; 39

40 Unit: 7 ….. for(i=0;i<8;i++) { if (a[i]>max) max=a[i]; if (a[i] { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_40.jpg", "name": "Unit: 7 …..", "description": "for(i=0;i<8;i++) { if (a[i]>max) max=a[i]; if (a[i]

41 Unit: 7 Check Your Programming Skills: Write a C++ program to store 5 numbers in an array then print them in reverse order? Write a C++ program to display following patterns? 41

42 Unit: 8 Objectives:To implement the concept of function. // Program-24 to Add two numbers using function #include int add(int x, int y); void main() { int a, b; cout<<" Enter value of a "; cin>>a; cout<<" Enter value of b "; cin>>b; add(a,b); } 42

43 Unit: 8 ….. int add(int x, int y) { int res; res = x+y; cout<<" Sum = "< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_43.jpg", "name": "Unit: 8 …..", "description": "int add(int x, int y) { int res; res = x+y; cout<< Sum = <

44 Unit: 8 // Program-25 to find the factorial of a number by using function #include int fact(int); void main() { int x,f; cout<<"enter the number"; cin>>x; f=fact(x); cout<<"The factorial"< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4034037/slides/slide_44.jpg", "name": "Unit: 8 // Program-25 to find the factorial of a number by using function #include int fact(int); void main() { int x,f; cout<< enter the number ; cin>>x; f=fact(x); cout<< The factorial <>x; f=fact(x); cout<< The factorial <

45 Unit: 8 …. int fact(int a) { int i,f=1; for(i=1;i<=a;i++) f=f*i; return f; } 45

46 Unit: 8 Check Your Programming Skills: Write a C++ program to calculate difference of two numbers by using functions? Write a C++ program to calculate the Multiplication of two numbers by using functions? Write a C++ program to calculate the square of any integer by using functions? Write a C++ program to calculate the square root of any integer by using functions? 46


Download ppt "Appendix Lab Manual for Programming Skills 1. Symbols used in Writing Programs { opening curly bracket } closing curly bracket # hash sign or number sign."

Similar presentations


Ads by Google