The document contains code for 3 C++ programs: 1) A program to exchange the values of two variables, 2) A program to display the first 10 natural numbers, and 3) A program to find the largest number among three user-input numbers. The programs were prepared by Muhammad Ateeb Akmal for the Data Structure and Algorithm Lab course under instructor Engr. Arslan Arif.
The document contains code for 3 C++ programs: 1) A program to exchange the values of two variables, 2) A program to display the first 10 natural numbers, and 3) A program to find the largest number among three user-input numbers. The programs were prepared by Muhammad Ateeb Akmal for the Data Structure and Algorithm Lab course under instructor Engr. Arslan Arif.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
The document contains code for 3 C++ programs: 1) A program to exchange the values of two variables, 2) A program to display the first 10 natural numbers, and 3) A program to find the largest number among three user-input numbers. The programs were prepared by Muhammad Ateeb Akmal for the Data Structure and Algorithm Lab course under instructor Engr. Arslan Arif.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
(EE-286) Instructor: Engr. Arslan Arif Prepared by: Muhammad Ateeb Akmal Section:B
Program to exchange value of two variables:
#include<iostream.h> #include<conio.h> int main() { int a,b,c; cout<<"Enter a value of a="; cin>>a; cout<<"Enter value of b="; cin>>b; c=a; a=b; b=c; cout<<"Value of a after exchange a=" <<a<<endl; cout<<"Value of b after exchange b=" <<b; getch(); }
Program to show first 10 natural numbers:
#include<iostream.h> #include<conio.h> int main() { int a; for(a=1;a<=10;a++) cout<<a<<endl; getch(); }
Program to check the largest number:
#include<iostream.h> #include<conio.h> main() { int a,b,c,d; clrscr(); cout<<"enter first number = "; cin>>a; cout<<endl<<"enter second number = "; cin>>b; cout<<endl<<"enter third number = "; cin>>c; if(a>b) if(a>c) cout<<endl<<"largest num among three is = "<<a; else cout<<endl<<"largest num among three is = "<<c; else if(b>c) cout<<endl<<"largest num among three is = "<<b; else cout<<endl<<"largest num among three is = "<<c; getch(); return 0; }