You are on page 1of 24

Q. Write a program to enter and display 2-D array.

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr();

int i,j,num[4][4];

for(i=0;i<3;i++)

{ for(j=0;j<3;j++)

{ cout<<"Enter Element ("<<i+1<<","<<j+1<<")=>";

cin>>num[i][j];

} }

for(i=0;i<3;i++)

{ for(j=0;j<3;j++)

{ cout<<num[i][j]<<" ";

cout<<"\n";

getch();

}
Q. Write a program to encrypt and decrypt a string.
#include<iostream.h>

#include<conio.h>

#include<stdio.h>

void main()

clrscr();

char str[50];

cout<<"Enter A String=>";

gets(str);

for(int i=0;str[i]!='\0';i++)

{ str[i]=str[i]+3;

cout<<"\nEncrypted String=>"<<str;

for(int j=0;str[j]!='\0';j++)

{ str[j]=str[j]-3;

cout<<"\nDecrypted String=>"<<str;

getch();

Q. Write a program to search an object and display it’s location.


#include<iostream.h>

#include<conio.h>

void lsearch(int num[],int size,int n);

void main()

{ clrscr();

int num[5],size,n;

cout<<"Length Of String=>";

cin>>size;

for(int i=0;i<size;i++)

{ cin>>num[i];

cout<<"Number To Be Searched In String=>";

cin>>n;

lsearch(num,size,n);

getch();

void lsearch(int num[],int size,int n)

{ int flag=0;

for(int i=0;i<size;i++)

{ if(num[i]==n)

{ flag=1;

break;

}
if(flag==0)

cout<<"Not Found";

else

cout<<"Found At Location"<<" "<<i+1;

Q. Write a program to reverse a string.


#include<iostream.h>

#include<conio.h>
#include<string.h>

#include<stdio.h>

void main()

clrscr();

char str[50];

int l,i;

cout<<"Enter a String=>";

gets(str);

l=strlen(str);

cout<<l;

for(i=l-1;i>=0;i--)

{ cout<<str[i];

getch();

Q. Write a program to find simple interest using function.


#include<iostream.h>

#include<conio.h>

void simple(int p1,int r1,int t1);


void main()

{ clrscr();

int p,r,t;

cout<<"Enter Principle Amount=";

cin>>p;

cout<<"Enter Rate Of Interest=";

cin>>r;

cout<<"Enter Time Period=";

cin>>t;

simple(p,r,t);

getch();

void simple(int p1,int r1,int t1)

{ int si=(p1*r1*t1)/100;

cout<<"Simple Interest="<<si;

Q. Write a program to check whether a string is a palindrome or not.


#include<iostream.h>

#include<conio.h>

#include<stdio.h>

#include<string.h>
void main()

clrscr();

char str[20];

int l,flag=0;

cout<<"Enter a String= ";

gets(str);

l=strlen(str);

for(int i=0,j=l-1;str[i]!='\0',j>=0;i++,j--)

{ if(str[i]!=str[j])

{ flag=1;

break;

}}

if(flag==1)

cout<<"Not a palindrome";

else

cout<<"It is a palindrome";

getch(); }

Q. Write a program to SWAP integers.

#include<iostream.h>

#include<conio.h>

void swap(int a,int b);

void main()
{ clrscr();

int x,y;

cout<<"Enter Two Integers=>";

cin>>x>>y;

cout<<"Before Swapping x="<<x<<",y="<<y;

swap(x,y);

getch();

void swap(int a,int b)

{ int temp;

temp=a;

a=b;

b=temp;

cout<<"\nAfter Swapping x="<<a<<",y="<<b;

Q. Write a program to find the number of vowels in a string.

#include<iostream.h>

#include<conio.h>

#include<string.h>

#include<stdio.h>

void main()
{

clrscr();

char str[50];

int v=0;

cout<<"Enter a String=>";

gets(str);

for(int i=0;str[i]!='\0';i++)

{ switch(str[i])

{ case 'A':

case 'a':

case 'E':

case 'e':

case 'I':

case 'i':

case 'O':

case 'o':

case 'U':

case 'u':v++;

cout<<"Number Of Vowels="<<v;

getch();

}
Q. Write a program to add 2 arrays using structure.
#include<iostream.h>

#include<conio.h>

#include<stdio.h>
#include<string.h>

struct call

{ int a[2][2];

int b[2][2];

int c[2][2];

}ob;

void main()

{ clrscr();

cout<<"Enter string 1: ";

{ for(int i=0;i<2;i++)

{ for(int j=0;j<2;j++)

{ cin>>ob.a[i][j];

}}}

cout<<"Enter string 2: ";

{ for(int i=0;i<2;i++)

{ for(int j=0;j<2;j++)

{ cin>>ob.b[i][j];

}}}

{ for(int i=0;i<2;i++)

{ for(int j=0;j<2;j++)

{ ob.c[i][j]=ob.a[i][j]+ob.b[i][j];

}}}

cout<<"\n\nSum: ";

{ for(int i=0;i<2;i++)

{ for(int j=0;j<2;j++)

{ cout<<" "<<ob.c[i][j];

}}}
getch();

Q. Write a program for EXPORT using functions and structures.


#include<iostream.h>

#include<conio.h>

#include<string.h>

#include<stdio.h>

#include<process.h>
#include<dos.h>

void gtdata();

void display();

void search();

void searchno();

void searchname();

void edit();

void pass();

void bill();

int count=0,q=0;

struct map

int sn;

char name[20];

int price;

int quan;

ob[3];

void main()

clrscr();

pass();

clrscr();
cout<<"\n\n\n\n\n";

cout<<" ##########################"<<"\n";

delay(250);

cout<<" # #"<<"\n";

delay(250);

cout<<" # #"<<"\n";

delay(250);

cout<<" # S";

delay(200);

cout<<"E";

delay(200);

cout<<"A";

delay(200);

cout<<"H";

delay(200);

cout<<"A";

delay(200);

cout<<"W";

delay(200);

cout<<"K";

delay(200);

cout<<" #"<<"\n";

delay(250);

cout<<" # #"<<"\n";

delay(250);

cout<<" # E";
delay(200);

cout<<"X";

delay(200);

cout<<"P";

delay(200);

cout<<"O";

delay(200);

cout<<"R";

delay(200);

cout<<"T";

delay(200);

cout<<"S";

delay(200);

cout<<" Ltd.";

delay(200);

cout<<" #"<<"\n";

delay(250);

cout<<" # #"<<"\n";

delay(250);

cout<<" # #"<<"\n";

delay(250);

cout<<" ##########################"<<"\n";

delay(250);

cout<<" ";

delay(800);
int ch=0;

do

clrscr();

cout<<"\n"<<"WELCOME to Export Section";

delay(250);

cout<<"\n\n1.Add Product";

cout<<"\n2.Display Project";

cout<<"\n3.Search Record";

cout<<"\n4.Edit Record";

cout<<"\n5.Print Bill";

cout<<"\n6.<EXIT>";

cout<<"\n\nEnter choice: ";

cin>>ch;

switch(ch)

case 1:gtdata();

break;

case 2:display();

break;

case 3:search();

break;

case 4:edit();

break;
case 5:bill();

break;

case 6:exit(0);

while(ch<=4);

void gtdata()

clrscr();

for(int i=0;i<3;i++)

count++;

ob[i].sn=count;

cout<<"\nItem "<<count;

cout<<"\nEnter product name= ";

gets(ob[i].name);

cout<<"Enter price= ";

cin>>ob[i].price;

cout<<"Enter quantity= ";

cin>>ob[i].quan;

getch();

}
void display()

clrscr();

int c=0;

c++;

for(int i=0;i<3;i++)

cout<<"\n\nItem "<<c++;

cout<<"\n\nProduct Name: "<<ob[i].name;

cout<<"\nPrice: "<<ob[i].price;

cout<<"\nQuatity: "<<ob[i].quan;

cout<<"\nBarcode: ";

cout<<" | ||| ||";

cout<<"\n || | |||";

getch();

void search()

clrscr();

int z=0;

cout<<"\n1.Search by item number";

cout<<"\n2.Search by item name"<<"\n\n";

cin>>z;
switch(z)

case 1:searchno();

break;

case 2:searchname();

getch();

void searchname()

clrscr();

int i,flag;

char ch[20];

cout<<"\nEnter product name to be searched: ";

gets(ch);

for(i=0;i<3;i++)

{ //function for searching by name

if(strcmpi(ob[i].name,ch)==0)

{ flag=1;

break;

if(flag==1)

{cout<<"\nName saved by record: "<<ob[i].name;


cout<<"\nPrice saved by record: "<<ob[i].price;

cout<<"\nQuantity saved by record: "<<ob[i].quan;

else

{cout<<"\nRecord does not exist ";

getch();}

void searchno()

clrscr();

int y,i,flag;

cout<<"\nEnter product number to be searched: ";

cin>>y;

for(i=0;i<3;i++) //function for searching by number

if(ob[i].sn==y)

flag=1;

break;

if(flag==1)

cout<<"\nNumber exists by: "<<ob[i].sn;

cout<<"\n\nName saved by record: "<<ob[i].name;


cout<<"\nPrice saved by record: "<<ob[i].price;

cout<<"\nQuantity saved by record: "<<ob[i].quan;

else

cout<<"Record does not exist ";

getch();

void pass()

char p[10];

cout<<"\n\n Enter password to access files: "; //for password

gets(p);

if(strcmpi(p,"Abhishek")==0)

cout<<"\n\n\n\n\t\t\t Access Granted ";

cout<<".";

delay(350);

cout<<".";

delay(450);

cout<<".";

delay(550);

else
{

cout<<"\n\n\m\m\t\t\t Access Denied ";

cout<<".";

delay(350);

cout<<".";

delay(450);

cout<<".";

delay(550);

exit(0);

void edit()

clrscr();

int flag=0;

char name1[20];

cout<<"Enter product to be edited: ";

gets(name1);

for(int i=0;i<3;i++)

if(strcmpi(ob[i].name,name1)==0)

cout<<"\nRecord found ";

cout<<"\n\nSaved as name: "<<ob[i].name;

cout<<"\nPrice: "<<ob[i].price;
cout<<"\nQuantity: "<<ob[i].quan;

getch();

flag=1;

cout<<"\n\nEnter updated details ";

cout<<"\n\nEnter product name= ";

gets(ob[i].name);

cout<<"Enter price= ";

cin>>ob[i].price;

cout<<"Enter quantity= ";

cin>>ob[i].quan;

if(flag==0)

cout<<"\nRecord not found ";}

getch();

void bill()

int sum=0;

clrscr();

cout<<"##################################################################
#####";

cout<<"\n Seahawk Exports Ltd.";


cout<<"\n################################################################
#######";

cout<<"\n\n";

for(int i=0;i<3;i++)

cout<<"\n\nProduct Name: "<<ob[i].name;

cout<<"\nPrice: "<<ob[i].price;

cout<<"\nQuatity: "<<ob[i].quan;

sum=sum+(ob[i].quan*ob[i].price);

cout<<"\n\nTotal amount to be paid: "<<sum;

cout<<"\nBill generated";

cout<<"\n T&C apply";

getch();

You might also like