COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Slides:



Advertisements
Similar presentations
Introduction to Programming Lecture 39. Copy Constructor.
Advertisements

Character String Manipulation. Overview Character string functions sscanf() function sprintf() function.
 2000 Prentice Hall, Inc. All rights reserved Fundamentals of Strings and Characters String declarations –Declare as a character array or a variable.
Sort the given string, without using string handling functions.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Fundamentals of Strings and Characters Characters.
Exercise 7 Strings. An array of characters Used to store text Another way to initialize: char A[ ]=“blabla”;
Course Title Object Oriented Programming with C++ Course instructor ADEEL ANJUM Chapter No: 05 ARRAY 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER) 1.
Chapter: 01 C++ Revision Tour
Sha Tin Methodist College F.4 Computer Studies Pascal Programming.
String functions+ string I.Mona Alshehri. String Functions: Header file:#include Function: Int strlen(char s[n]) Description Calculates the length of.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Characters and Strings Functions.
LESSON 2 Basic of C++.
Lecture #15 ARRAYS By Shahid Naseem (Lecturer). 2 ARRAYS DEFINITION An array is a sequence of objects of same data type. The objects in an array are also.
C++ CODES PART#04 1 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT.
String in C++. 2 Using Strings in C++ Programs String library or provides functions to: - manipulate strings - compare strings - search strings ASCII.
Ex-1 #include <stdio.h> struct sample { int a=0; char b='A';
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
Code -> Build -> Run
LESSON 2 Basic of C++.
INC 161 , CPE 100 Computer Programming
Pointers & Arrays 1-d arrays & pointers 2-d arrays & pointers.
Fundamentals of Characters and Strings
DEPARTMENT OF COMPUTER SCIENCE & APPLICATION
Decisions Chapter 4.
LESSON 3 IO, Variables and Operators
Operator Overloading.
Lecture-5 Arrays.
Introduction to C++.
Algorithms and Data Structures
Enum ,Char Functions& Math Library Functions I.Mona Alshehri
Visit for more Learning Resources
Intro to Programming Week # 4 Switch Statement Lecture # 7
JUMP STATEMENT C++ has the four statements that perform an unconditional branch. They are, 1. return 2. goto 3. break 4. continue In addition to four statements.
Arrays in C.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CHƯƠNG II CÁC HÀM NHẬP XUẤT
Tejalal Choudhary “C Programming from Scratch” Pointers
Visit for more Learning Resources
Buy book Online -
ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Ambiguity Resolution in Inheritance
KỸ THUẬT LẬP TRÌNH GV: Phạm Thị Xuân Diệu
توابع ورودي-خروجي.
Pointers.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CSE1320 Strings Dr. Sajib Datta
Templaets It is a new concept which enables us to define “generic class “ and “generic function” to provide the “ generic programming” We are familiar.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Sequential input and output Operations in file
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
String in C++.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Chapter 2 Array and String Visit to more Learning Resources.
UNIT - 3 Noornilo Nafees.
Strings #include <stdio.h>
ENGR.SABA MUGHAL FROM COMPUTER SYSTEM DEPARTMENT
Computer Security Password Policy.
CS-161 Computer Programming Lecture 15 & 16: Arrays II
CPP Programming Language
ENGR.SABA MUGHAL FROM COMPUTER SYSTEM DEPARTMENT
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Characters and Strings Functions
Library in c++ ( as cmath , iostream , …… etc.)
Course Outcomes of Programming In C (PIC) (17212, C203):
Characters and Strings
Data Structure(s) A way of storing and organizing data in a computer so that it can be used efficiently. e.g. Arrays Linked Lists stacks Queues Trees.
Programming Fundamental-1
Visit for more Learning Resources
Presentation transcript:

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT C++ CODES PART#12 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT SWAPING THE NAME #include<constream.h> #include <string.h> char name[100]; void getname(); void swapname(); void main() { COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. clrscr(); getname(); swapname(); getch(); } void getname() { COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. cout<<"Enter your name: "; cin>>name; } void swapname() { for(int i=strlen(name); i>=0; i--) cout<<name[i]; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Copying the string and finding length of the string #include<constream.h> #include<string.h> void main() { clrscr(); char a[]="SABA"; char s2[]="MUGHAL"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. cout<<a<<endl<<s2<<endl; cout<<strlen(a)<<'\t'<<strcpy(s2,a); getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT USING gotoxy #include<iostream.h> #include<conio.h> void main() { clrscr(); char a[100]="ENGR.SABA MUGHAL"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. gotoxy(36,12); cout<<a; getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

SIMPLE STRING VARIABLE #include<constream.h> void main(){ clrscr(); const int max=80; char a[max]; cout<<"enter a string:"; cin>>a; cout<<"you entered:"<<a<<endl; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYING THE STRING WITH EASY METHOD #include<constream.h> #include<string.h> void main() { clrscr(); char str1[]="ASSALAMUALAIKUM\n" "GOOD BYE"; const int max=80; // size of str2 buffer COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. char str2[max]; strcpy(str2,str1); cout<<str2<<endl; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Using stdio.h and gets() #include<constream.h> #include<stdio.h> #include<string.h> void main(){ clrscr(); int a,b; char c[20],ch[20]; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. gets(c); gets(ch); cout<<strcpy(c,ch); getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Find ASCII integer values of your name #include<constream.h> #include<stdio.h> #include<string.h> void main(){clrscr(); char c[20];int b,a; cout<<"enter any name"<<endl; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. gets(c); b=strlen(c); for(a=0;a<b;a++) { cout<<endl<<c[a]<<"="<<int(c[a]);} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT NICE WORDINGS…. "Khush mizaji hamesha khoobsurti ki kami ko poora kr deti hai, Laykin Khoobsurti khush mizaji ki kami ko poora nahi kr sakti " COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT