0% found this document useful (0 votes)
22 views17 pages

Computer Science Programmes

.WAP to do Swapping by Call By Value .WAP to do Swapping by Call by Reference .WAP to read a Character & Print Next .WAP to find weather a Character is Alphanumeric or Digit .To print * * * * * * * * * * .WAP to print * * * * * * * * * * .WAP to find cube of a number .WAP to use Array for Entering and print Marks .WAP to enter number and display sum, product and average of the number .WAP to search a specific element in a 1-d array .WAP to find a substring of a given string .WAP to delete duplicate elements from a vector. .WAP to count number of lowercase entered .WAP to find fibonacci series .WAP to find factorial of a number .WAP to find if it is lower case,upper case or digit

Uploaded by

PAUL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views17 pages

Computer Science Programmes

.WAP to do Swapping by Call By Value .WAP to do Swapping by Call by Reference .WAP to read a Character & Print Next .WAP to find weather a Character is Alphanumeric or Digit .To print * * * * * * * * * * .WAP to print * * * * * * * * * * .WAP to find cube of a number .WAP to use Array for Entering and print Marks .WAP to enter number and display sum, product and average of the number .WAP to search a specific element in a 1-d array .WAP to find a substring of a given string .WAP to delete duplicate elements from a vector. .WAP to count number of lowercase entered .WAP to find fibonacci series .WAP to find factorial of a number .WAP to find if it is lower case,upper case or digit

Uploaded by

PAUL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 17

WAP to do Swapping by Call By Value

#include<iostream.h> #include<conio.h> int main() {clrscr(); void swap(int, int); int a=7,b=4; cout<< !n"ri#inal value!n ; cout<< a= <<a<< !n ; cout<< b= <<b; swap(a, b); cout<< !n$alues a%ter swap!n ; cout<< a= <<a<< !n ; cout<< b= <<b; return &; ' void swap(int (, int )) {int temp=(; (=); )=temp; cout<< !n*wapped values are+!n ; cout<< a= <<(<< !n ; cout<< b= <<);'

WAP to do Swapping by Call by Reference

#include<iostream.h> #include<conio.h> int main() {clrscr(); void swap(int ,, int ,); int a=7,b=4; cout<< !n"ri#inal value!n ; cout<< a= <<a<< !n ; cout<< b= <<b; swap(a, b); cout<< !n$alues a%ter swap!n ; cout<< a= <<a<< !n ; cout<< b= <<b; #etch(); return &; ' void swap(int ,(, int ,)) {int temp=(; (=); )=temp; cout<< !n*wapped values are+!n ; cout<< a= <<(<< !n ; cout<< b= <<);'

WAP to read a Character & Print Next


#include<iostream.h>

#include<conio.h> #include<stdio.h> int main() {clrscr(); char a, b; cout<< !n-nter an) character!n ; a= #etchar(); b=a./; cout<< !n0e(t character is= ; putchar(b); #etch(); return &; '

WAP to find weather a Character is Alphanu eric or !igit


#include<iostream.h> #include<ct)pe.h>

#include<conio.h> void main() {clrscr(); char a; cin>>a; i%(isalnum(a)) {cout<< !n1lphanumeric!n ; i%(isalpha(a)) cout<< !n1lphabet!n ; else cout<< !n2i#it!n ; ' else cout<< !n"ther 3haracter!n ; #etch(); '

"o print
# # # # # #

#include<iostream.h> #include<conio.h> void main() {clrscr(); %or(int i=/;i<=4;i..) {cout<< !n ; %or(int 4=/;4<=i;4..) cout<< 5 ; ' #etch(); '

WAP to print # # # # # # # # #

#
#include<iostream.h> #include<conio.h> void main() {clrscr(); %or(int i=4;i>=/;i66) {cout<< !n ; %or(int 4=/;4<=i;4..) cout<< 5 ; ' #etch(); '

WAP to find cube of a nu ber


#include<iostream.h> #include<conio.h> void main() {

clrscr(); %loat cube(%loat); %loat a,cu; cout<< -nter an) number+ ; cin>>a; cu=cube(a); cout<< !n3ube o% <<a<< is <<cu; #etch(); ' %loat cube(%loat a) { %loat cu; cu=a5a5a; return(cu); '

WAP to use Array for $ntering and print %ar&s


#include<iostream.h> int main ( ) { const int si7e=8; int mar9s :si7e;;

int i; %or (i =&; i < =8; i..) { cout<< -nter mar9s ); cin>>mar9s:i;; ' cout<< !n %or (i = &; i < = 8; i ..) cout<< <ar9s: <<i<< ;= <<mar9s:i;<< !n ; return &; '

WAP to enter nu ber and display su ' product and a(erage of the nu ber
#include<iostream.h> int main ( ) {double price:8;,sum,av#,prod; sum=av#= &; prod=/; p

%or (i=&; i<8; i..) { cout<< -nter price <<i./<< = ; cin>>price:i;; sum .=sum:i;; prod5=prod:i;; ' av#=sum=8 cout<< !n*um o% prices is = <<sum<<endl; cout<< !n>roduct o% prices is = <<prod<<endl; cout<< !n1vera#e o% prices is = <<av#<<endl; return &; '

WAP to search a specific ele ent in a )*d array


#include<iostream.h> int main() { int 1:/&;,si7e,i,%la#=&,num,pos; cout<< -nter number o% elements )ou want to insert ; cin>>si7e; %or(i=&;i<si7e;i..)

{ cout<< -nter element <<i./<< + ; cin>>1:i;; ' cout<< -nter the number )ou want to search ; cin>>num; %or(i=&;i<si7e;i..) i%(1:i;==num) {%la#=/; pos=i; brea9; ' i% (%la#==&) cout<< !n?tem not %ound ; else cout<< !n?tem %ound at <<(pos./); return &; '

WAP to find a substring of a gi(en string


#include<iostream.h> int main() { char (:8&;, ):8&;; int i,4; cout<< -nter bi# strin# ; cin>>(;

cout<< -nter search strin# ; cin>>); %or( i=&; (:i;@=A!&A; i..) { %or( 4=&; ):4;@=A!&A; 4..) { i% ( (:i.4;@=):4;) brea9; ' i%():4;==A!&A) { cout<< Bound at <<i<<endl; brea9; ' ' return &; '

WAP to delete duplicate ele ents fro


#include<iostream.h> int main() { int i,4,9,num,ans=&; int vec:C&;; cout<< !n-nter si7e o% the arra)+ ; cin>>num; cout<< !n-nter elements into the arra)+ !n ; %or(i=&;i<num;i..)

a (ector+

cin>>vec:i;; cout<< !n"ri#nal vector!n ; %or(i=&;i<num;i..) cout<< !n <<vec:i;; {%or(i=&;i<num6/;..i) %or(4=/.i;4<num;..4) { i%(vec:i;==vec:4;) {num=num6/; %or(9=4;9<num;..9) vec:9;=vec:9./;; ans=/; 4=46/; ' 'i%(ans==&) cout<< !n$ector without duplication!n ; else { cout<< !nDhe arra) a%ter removin# duplicates is+ ; %or(i=&;i <num ;i..) cout<< !n <<vec:i;; 'return &;' '

WAP to count nu ber of lowercase entered


#include <iostream> int main() { int chcount=&; const char ent=A!nA; char ch; cout << -nter 3harecter+!n ; cin.#et(ch); while(ch@=ent) {

i%(ch>=AaA,,ch<=A7A) { chcount..; cout.put(ch); ' cin.#et(ch); ' cout << -nter the numbers o% charecter= <<chcount<< !nA; return &; ' '

WAP to find fibonacci series


#include<iostream> int main() { int n, c, %irst = &, second = /, ne(t; cout << -nter the number o% terms o% Bibonacci series )ou want << endl; cin >> n; cout << Birst << n << terms o% Bibonacci series are +6 << endl; %or ( c = & ; c < n ; c.. ) { i% ( c <= / ) ne(t = c; else

{ ne(t = %irst . second; %irst = second; second = ne(t; ' cout << ne(t << endl; '

return &; '

WAP to find factorial of a number #include<iostream> using namespace std; int main() { int num,factorial=1; cout<<" Enter Number o !ind "ts !actorial# "; cin>>num; for(int a=1;a<=num;a$$) { factorial=factorial%a;

& cout<<"!actorial of 'i(en Number is ="<<factorial<<endl; return ); &

*+, to find if it is lo-er case,upper case or digit include<iostream.h> #include<conio.h> void main() { char ch; cout<<"enter the character"<<endl; cin>>ch; if((ch>=65)&&(ch<=90)) cout<<"the Character is a Upper Case Alphabet"<<endl; if((ch>=97) &&(ch<=122)) cout<<" the character is a Lower Case Alphabet"<<endl; if((ch>=48) && (ch<=57)) cout<<" the entered char is a Numeric value"

getch(); }

You might also like