SlideShare une entreprise Scribd logo
1  sur  8
ASSIGNMENT ICP
Submitted by: Nadeem Ahmed
Submitted to: Pro. Syed NASIR MEHDI
ROLLNO: SP19-MCS-016
1.Write a program thataccepts a characterfrom the user and display
its ASCII Value.
#include<iostream>
usingnamespace std;
intmain()
{
char c;
cout << "Entera character : ";
cin >> c;
cout << "ASCIIvalue of " << c <<" is: " << (int)c;
return0;
}
OUTPUT:
2.Write aprogram in C++ that inputs name, age from the user and thendisplays
these values onthe
Screen?
#include <iostream>
usingnamespace std;
#define MAX_LENGTH100
intmain()
{
char name[MAX_LENGTH]={0};
intage;
cout<<"Enter name of the person:";
cin.getline(name,MAX_LENGTH);
cout<<"Enter age:";
cin>>age;
cout<<"Name:"<<name<<endl;
cout<<"Age:"<<age<<endl;
return0;
}
OUTPUT:
3. Write a program that reads a four digit number from user,then the
program separatesdigits of the
number e.g.4567 to displayed as:
4
5
6
7
#include <iostream>
usingnamespace std;
intmain()
{
intnum;
cout << "Entera four-digitnumber:";
cin >> num;
cout <<num /1000<< endl;
num=num % 1000;
cout <<num /100<<endl;
num=num % 100;
cout<<num /10<<endl;
num=num % 10;
cout<<num <<endl;
return0;
}
OUTPUT:
4. Write aprogram that take temperature inFahrenheitfromuser and showthe
equivalent temperature
in Celsius.
FORMULA:
[c = (f - 32) * 5/9; ]
ConvertFahrenheittoCelsiusinC++
#include<iostream>
usingnamespace std;
int main()
{
floatcel,far;
cout<<"Enter temp.inFahrenheit:";
cin>>far;
cel = (far- 32) * 5/9;
cout<<"Temp.inCelsius:"<<cel;
return0;
}
OUTPUT:
5. Write a program in C++ which would swap the values of two variables using the
third variable.
#include <iostream>
usingnamespace std;
intmain()
{
inta = 5, b = 10, temp;
cout << "Before swapping."<<endl;
cout << "a = " << a << ", b = " << b << endl;
temp= a;
a = b;
b = temp;
cout << "nAfterswapping."<<endl;
cout << "a = " << a << ", b = " << b << endl;
return0;
}
OUTPUT:
6. Write a program in C++ which would swap the values of two variables without
using the third variable.
#include<iostream>
usingnamespace std;
intmain()
{
inta,b;
cout<<"Enter the firstno=:";
cin>>a;
cout<<"nnEnterthe secondno=:";
cin>>b;
cout<<"na"<<" is ="<<a<<"nb"<<" is="<<b<<endl;
a=a+b;
b=a-b;
a=a-b;
cout<<"afterswap number";
cout<<"nna="<<a<<"nb="<<b;
return0;
}
OUTPUT:
7.Check the output of the following piece of code on compiler and explain why is
it so:
ANS= in this program swap the value using of two number .
#include<iostream>
usingnamespace std;
intmain()
{
char c = 'a';
intn = 'a';
cout << "c = " << c << endl;
cout << "n = " << n << endl;
return0;
}
OUTPUT:

Contenu connexe

Tendances

Assignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.zAssignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.z
Syed Umair
 
Chapter24 operator-overloading
Chapter24 operator-overloadingChapter24 operator-overloading
Chapter24 operator-overloading
Deepak Singh
 
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
AAKASH KUMAR
 

Tendances (20)

Practical no 4
Practical no 4Practical no 4
Practical no 4
 
Inc decsourcefile
Inc decsourcefileInc decsourcefile
Inc decsourcefile
 
14 Lec11 2003
14 Lec11 200314 Lec11 2003
14 Lec11 2003
 
Assignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.zAssignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.z
 
C test
C testC test
C test
 
Chapter24 operator-overloading
Chapter24 operator-overloadingChapter24 operator-overloading
Chapter24 operator-overloading
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
Implement ERC20 on TestRPC
Implement ERC20 on TestRPCImplement ERC20 on TestRPC
Implement ERC20 on TestRPC
 
Concept of c
Concept of cConcept of c
Concept of c
 
Loops (1)
Loops (1)Loops (1)
Loops (1)
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
vbscript-reference book
vbscript-reference bookvbscript-reference book
vbscript-reference book
 
Include
IncludeInclude
Include
 
Number
NumberNumber
Number
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
 
Permute
PermutePermute
Permute
 
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.comMcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
 
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
C++20 features
C++20 features C++20 features
C++20 features
 

Similaire à Assignment#1

Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
Prabhu D
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
Ankit Dixit
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
Dendi Riadi
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
EPORI
 

Similaire à Assignment#1 (20)

C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
Oop1
Oop1Oop1
Oop1
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 
C++basics
C++basicsC++basics
C++basics
 
C++basics
C++basicsC++basics
C++basics
 
c++basiccs.ppt
c++basiccs.pptc++basiccs.ppt
c++basiccs.ppt
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 

Plus de NA000000

Plus de NA000000 (17)

Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.
 
JAVA Naming Conventions By NADEEM AHMED FROM DEPALPUR
JAVA Naming Conventions By NADEEM AHMED FROM DEPALPURJAVA Naming Conventions By NADEEM AHMED FROM DEPALPUR
JAVA Naming Conventions By NADEEM AHMED FROM DEPALPUR
 
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPURLine Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
 
Critical Path Method In Software Engineering By NADEEM AHMED
Critical Path Method In Software Engineering By NADEEM AHMED Critical Path Method In Software Engineering By NADEEM AHMED
Critical Path Method In Software Engineering By NADEEM AHMED
 
COCOMO Modal In Software Engineering By NADEEM AHMED
COCOMO Modal In Software Engineering By NADEEM AHMED COCOMO Modal In Software Engineering By NADEEM AHMED
COCOMO Modal In Software Engineering By NADEEM AHMED
 
LEGACY SYSTEM In Software Engineering By NADEEM AHMED
LEGACY SYSTEM In Software Engineering By NADEEM AHMED LEGACY SYSTEM In Software Engineering By NADEEM AHMED
LEGACY SYSTEM In Software Engineering By NADEEM AHMED
 
Modal Driven Architecture In Software Engineering By NADEEM AHMED
Modal Driven Architecture In Software Engineering By NADEEM AHMED Modal Driven Architecture In Software Engineering By NADEEM AHMED
Modal Driven Architecture In Software Engineering By NADEEM AHMED
 
Software Testing By NADEEM AHMED FROM DEPALPUR
Software Testing By NADEEM AHMED FROM DEPALPURSoftware Testing By NADEEM AHMED FROM DEPALPUR
Software Testing By NADEEM AHMED FROM DEPALPUR
 
Software Inspection By NADEEM AHMED FROM DEPALPUR
Software Inspection By NADEEM AHMED FROM DEPALPURSoftware Inspection By NADEEM AHMED FROM DEPALPUR
Software Inspection By NADEEM AHMED FROM DEPALPUR
 
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPURCleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
 
UML Diagrams By NADEEM AHMED FROM DEPALPUR
UML Diagrams By NADEEM AHMED FROM DEPALPURUML Diagrams By NADEEM AHMED FROM DEPALPUR
UML Diagrams By NADEEM AHMED FROM DEPALPUR
 
Biometrics
BiometricsBiometrics
Biometrics
 
Computer Networks By NADEEM AHMED
Computer Networks By NADEEM AHMED Computer Networks By NADEEM AHMED
Computer Networks By NADEEM AHMED
 
Cloud computing by NADEEM AHMED
Cloud computing by NADEEM AHMEDCloud computing by NADEEM AHMED
Cloud computing by NADEEM AHMED
 
Iot proposal by nadeem ahmed
Iot proposal by nadeem ahmedIot proposal by nadeem ahmed
Iot proposal by nadeem ahmed
 
Biomatric
BiomatricBiomatric
Biomatric
 
Project proposal oop
Project proposal oopProject proposal oop
Project proposal oop
 

Dernier

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Dernier (20)

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

Assignment#1

  • 1. ASSIGNMENT ICP Submitted by: Nadeem Ahmed Submitted to: Pro. Syed NASIR MEHDI ROLLNO: SP19-MCS-016
  • 2. 1.Write a program thataccepts a characterfrom the user and display its ASCII Value. #include<iostream> usingnamespace std; intmain() { char c; cout << "Entera character : "; cin >> c; cout << "ASCIIvalue of " << c <<" is: " << (int)c; return0; } OUTPUT:
  • 3. 2.Write aprogram in C++ that inputs name, age from the user and thendisplays these values onthe Screen? #include <iostream> usingnamespace std; #define MAX_LENGTH100 intmain() { char name[MAX_LENGTH]={0}; intage; cout<<"Enter name of the person:"; cin.getline(name,MAX_LENGTH); cout<<"Enter age:"; cin>>age; cout<<"Name:"<<name<<endl; cout<<"Age:"<<age<<endl; return0; } OUTPUT:
  • 4. 3. Write a program that reads a four digit number from user,then the program separatesdigits of the number e.g.4567 to displayed as: 4 5 6 7 #include <iostream> usingnamespace std; intmain() { intnum; cout << "Entera four-digitnumber:"; cin >> num; cout <<num /1000<< endl; num=num % 1000; cout <<num /100<<endl; num=num % 100; cout<<num /10<<endl; num=num % 10; cout<<num <<endl; return0; } OUTPUT:
  • 5. 4. Write aprogram that take temperature inFahrenheitfromuser and showthe equivalent temperature in Celsius. FORMULA: [c = (f - 32) * 5/9; ] ConvertFahrenheittoCelsiusinC++ #include<iostream> usingnamespace std; int main() { floatcel,far; cout<<"Enter temp.inFahrenheit:"; cin>>far; cel = (far- 32) * 5/9; cout<<"Temp.inCelsius:"<<cel; return0; } OUTPUT:
  • 6. 5. Write a program in C++ which would swap the values of two variables using the third variable. #include <iostream> usingnamespace std; intmain() { inta = 5, b = 10, temp; cout << "Before swapping."<<endl; cout << "a = " << a << ", b = " << b << endl; temp= a; a = b; b = temp; cout << "nAfterswapping."<<endl; cout << "a = " << a << ", b = " << b << endl; return0; } OUTPUT:
  • 7. 6. Write a program in C++ which would swap the values of two variables without using the third variable. #include<iostream> usingnamespace std; intmain() { inta,b; cout<<"Enter the firstno=:"; cin>>a; cout<<"nnEnterthe secondno=:"; cin>>b; cout<<"na"<<" is ="<<a<<"nb"<<" is="<<b<<endl; a=a+b; b=a-b; a=a-b; cout<<"afterswap number"; cout<<"nna="<<a<<"nb="<<b; return0; } OUTPUT:
  • 8. 7.Check the output of the following piece of code on compiler and explain why is it so: ANS= in this program swap the value using of two number . #include<iostream> usingnamespace std; intmain() { char c = 'a'; intn = 'a'; cout << "c = " << c << endl; cout << "n = " << n << endl; return0; } OUTPUT: