SlideShare a Scribd company logo
1 of 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:

More Related Content

What's hot

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.zSyed Umair
 
Chapter24 operator-overloading
Chapter24 operator-overloadingChapter24 operator-overloading
Chapter24 operator-overloadingDeepak Singh
 
Implement ERC20 on TestRPC
Implement ERC20 on TestRPCImplement ERC20 on TestRPC
Implement ERC20 on TestRPCKC Tam
 
vbscript-reference book
vbscript-reference bookvbscript-reference book
vbscript-reference bookAnand Dhana
 
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.comkashif kashif
 
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 CSAAKASH KUMAR
 

What's hot (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
 

Similar to Assignment#1

Similar to 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
 

More from NA000000

Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.NA000000
 
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 DEPALPURNA000000
 
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 DEPALPURNA000000
 
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 NA000000
 
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 NA000000
 
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 NA000000
 
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 NA000000
 
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 DEPALPURNA000000
 
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 DEPALPURNA000000
 
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 DEPALPURNA000000
 
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 DEPALPURNA000000
 
Biometrics
BiometricsBiometrics
BiometricsNA000000
 
Computer Networks By NADEEM AHMED
Computer Networks By NADEEM AHMED Computer Networks By NADEEM AHMED
Computer Networks By NADEEM AHMED NA000000
 
Cloud computing by NADEEM AHMED
Cloud computing by NADEEM AHMEDCloud computing by NADEEM AHMED
Cloud computing by NADEEM AHMEDNA000000
 
Iot proposal by nadeem ahmed
Iot proposal by nadeem ahmedIot proposal by nadeem ahmed
Iot proposal by nadeem ahmedNA000000
 
Project proposal oop
Project proposal oopProject proposal oop
Project proposal oopNA000000
 

More from 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
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 

Recently uploaded (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 

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: