Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (1 vote)
44 views3 pages

Data Structure and Algorithm Lab: Roll #

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.

Uploaded by

Ateeb Akmal
Copyright
© Attribution Non-Commercial (BY-NC)
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 (1 vote)
44 views3 pages

Data Structure and Algorithm Lab: Roll #

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.

Uploaded by

Ateeb Akmal
Copyright
© Attribution Non-Commercial (BY-NC)
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
You are on page 1/ 3

Department of Electrical Engineering

Roll # 11053122-073

Data Structure and Algorithm Lab


Subject Code:

(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; }

You might also like