Thursday 7 May 2020

Program to show subtraction of 2 array into third array

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],b[5],c[5],i;
clrscr();
printf(“enter value for array a ”);
for(i=0;i<5;i++)
scanf(“%d”,&a[i]);
printf(“enter value for array b ”);
for(i=0;i<5;i++)
scanf(“%d”,&b[i]);
for(i=0;i<5;i++)
c[i]=a[i]-b[i];
printf(“subtraction”);
for(i=0;i<5;i++)
printf(“ %d ”,c[i]);
getch();
}

A Metropolitan Hotel has 5 floors and 10 rooms in each floor. The names of the visitors are entered in a Double Dimensional Array (DDA) as M[5][10].The Hotel Manager wants to know from the "Enquiry" about the position of a visitor (i.e. floor number and room number) as soon as he enters the name of the visitor. Write a program in Java to perform the above task.

import java.util.Scanner;
public class ATS
{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
String M[][] = new String[5][10];
int i = 0, j = 0;
for (i = 0; i < 5; i++)
{
System.out.println("Enter floor " + (i + 1)+ " guest details:");
for (j = 0; j < 10; j++)
{
System.out.print("Guest in room " +(j + 1) + ": ");
M[i][j] = in.nextLine();
}
}
boolean found = false;
System.out.print("\nEnter guest name to search: ");
String guest = in.nextLine();
for (i = 0; i < 5; i++)
{
for (j = 0; j < 10; j++)
{
if (M[i][j].equals(guest))
{
found = true;
break;
}
}
if (found)
break;
}
if (found)
System.out.println(guest + " is in room number "+ (j + 1) + " on floor number " + (i + 1));
else
System.out.println(guest +" is not staying at this hotel");
}
}

Write a program implementing linked list as a class. Also Perform some required operations like inserting, deleting nodes & display the contents of entire linked list.

#include <iostream.h>
class linklist
{
struct node
{
int data;
node * link;
}*p;
public:
linklist( );
void append( int num );
void addatbeg( int num );
void addafter( int c, int num );
void del( int num );
void display( );
int count( );
~linklist( );
};
linklist::linklist( )
{
p = NULL;
}
void linklist::append( int num )
{
node * q,
* t;
if( p == NULL )
{
p = new node;
p->data = num;
p->link = NULL;
}
else
{
q = p;
while( q->link != NULL )
q = q->link;
t = new node;
t->data = num;
t->link = NULL;
q->link = t;
}
}
void linklist::addatbeg( int num )
{
node * q;
q = new node;
q->data = num;
q->link = p;
p = q;
}
void linklist::addafter( int c, int num )
{
node * q,* t;
int i;
for( i = 0, q = p; i < c; i++ )
{
q = q->link;
if( q = NULL )
{
cout << endl << "There are less than " << c << "element";
return;
}
}
t = new node;
t->data = num;
t->link = q->link;
q->link = t;
}
void linklist::del( int num )
{
node * q,* r;
q = p;
if( q->data == num )
{
p = q->link;
delete q;
return;
}
r = q;
while( q != NULL )
{
if( q->data == num )
{
r->link = q->link;
delete q;
return;
}
r = q;
q = q->link;
}
cout << endl << "Element" << num << "not found";
}
void linklist::display( )
{
node * q;
cout << endl;
for( q = p; q->link != NULL; q = q->link )
{
cout << endl << q->data;
}
int linklist::count( )
{
node * q;
int c = 0;
for( q = p; q != NULL; q = q->link )
c++;
return ( c );
}
linklist::~linklist( )
{
node * q;
if( p == NULL )
return;
while( p != NULL )
{
q = p->link;
delete p;
p = q;
}
}
void main( )
{
linklist ll;
cout << endl << "No. of elements in linked list= " << ll.count( );
ll.append( 11 );
ll.append( 22 );
ll.append( 33 );
ll.append( 44 );
ll.append( 55 );
ll.addatbeg( 100 );
ll.addatbeg( 200 );
ll.addatbeg( 300 );
ll.addafter( 3, 333 );
ll.addafter( 6, 444 );
ll.display( );
cout << endl << "No. of element in linked list =" << ll.count( );
ll.del( 300 );
ll.del( 66 );
ll.del( 0 );
ll.display( );
cout << endl << "No. of element in linked list =" << ll.count( );
}

Tuesday 5 May 2020

Object Oriented Programming Features in Hindi

Features of C++



•Reusability- The code written in C++ for one program canbe used in another program of C++.

•Bottom-Up Approach- C++ may define functions and program data first and then integrate them together for use.

•Object Oriented Programming- C++ Provides mechanism to combine both data and the function of that data into a single unit, called object.

•Portability- Same C++ code can be compiled in almost any type of computer and operating system without any changes.

•Brevity- Code written in C++ is very short in comparison with other languages.

•Modular Programming- An application’s body in C++ can be made up of several source code files (called modules) that are compiled separately and then linked together.

•C Compatibility- Any code of C can easily be included in a C++ program without hardly making any change.

•Speed-The resulting code from a C++ compilation is very efficient, due indeed to its duality as high-level and low-level language and to the reduced size of the language itself.







Object Oriented Programming Features


-Emphasis on objects instead of problem solution

-Program developed around objects and classes.

-There are 4 basic features of object oriented programming:

1.Encapsulation
2.Abstraction
3.Inheritance
4.Polymorphism






Monday 4 May 2020

Program to find sum of two matrices

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][2],b[3][2],c[3][2],i,j;
clrscr();
printf(“Enter value for 1 matrix: ”);
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf(“%d”,&a[i][j]);
}
printf(“Enter value for 2 matrix: ”);
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf(“%d”,&b[i][j]);
}
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
c[i][j]=a[i][j]+b[i][j];
}
printf(“Sum of matrix is\n”);
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
printf(“%d\t”,c[i][j]);
}
printf(“\n”);
}
getch();
}

Write a program to accept the year of graduation from school as an integer value from the user. Using the binary search technique on the sorted array of integers given below, output the message "Record exists" if the value input is located in the array. If not, output the message "Record does not exist".

public class ATS
{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
int n[] = {1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010};
System.out.print("Enter graduation year to search: ");
int year = in.nextInt();
int l = 0, h = n.length - 1, idx = -1;
while (l <= h)
{
int m = (l + h) / 2;
if (n[m] == year)
{
idx = m;
break;
}
else if (n[m] < year)
{
l = m + 1;
}
else
{
h = m - 1;
}
}
if (idx == -1)
System.out.println("Record does not exist");
else
System.out.println("Record exists");
}
}

Write program to implement a queue class with required operations/ functions.

#include <iostream.h>
#define MAX 10
class queue
{
private:
int arr[ MAX ];
int front,
rear;
public:
queue( )
{
front = -1;
rear = -1;
}
void addq(int it)
{
int item=it;
if( rear == MAX - 1 )
{
cout << endl << "Queue is full";
return;
}
rear++;
arr[ rear ] = item;
if( front == -1 )
front = 0;
}
int delq( )
{
int data;
if( front == -1 )
{
cout << endl << "Queue is empty";
return NULL;
}
data = arr[ front ];
if( front == rear )
front = rear = -1;
else
front++;
return data;
}
};
void main( )
{

queue a;
a.addq( 11 );
a.addq( 12 );
a.addq( 13 );
a.addq( 14 );
a.addq( 15 );
a.addq( 16 );
a.addq( 17 );
a.addq( 18 );
a.addq( 19 );
a.addq( 20 );
a.addq( 21 );
int i = a.delq( );
cout << endl << "Item deleted=" << i;
i = a.delq( );
cout << endl << "Item deleted=" << i;
i = a.delq( );
cout << endl << "Item deleted=" << i;
}

Sunday 3 May 2020

Program to display a matrix.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][2],b[3][2],i,j;
clrscr();
printf(“enter value for for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf(“%d”,&a[i][j]);
}
printf(“enter value for b matrix: ”);
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf(“%d”,&b[i][j]);
}
printf(“\na matrix is\n\n”);
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
  {
printf(“ %d ”,a[i][j]);
}
printf(“\n”);
}
printf(“\nb matrix is\n\n”);
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
printf(“ %d ”,b[i][j]);
}
printf(“\n”);
}
getch();
}

The annual examination result of 50 students in a class is tabulated in a Single Dimensional Array (SDA) is as follows:

Write a program to read the data, calculate and display the following:
(a) Average marks obtained by each student.
(b) Print the roll number and the average marks of the students whose average is above.
80.
(c) Print the roll number and the average marks of the students whose average is below
40.


import java.util.Scanner;
public class ATS
{
public static void main(String[]args)
{
final int TOTAL_STUDENTS = 50;
Scanner in = new Scanner(System.in);
int rollNo[] = new int[TOTAL_STUDENTS];
int sA[] = new int[TOTAL_STUDENTS];
int sB[] = new int[TOTAL_STUDENTS];
int sC[] = new int[TOTAL_STUDENTS];
double avg[] = new double[TOTAL_STUDENTS];
for (int i = 0; i < TOTAL_STUDENTS; i++)
{
System.out.println("Enter student " + (i+1) + " details:");
System.out.print("Roll No: ");
rollNo[i] = in.nextInt();
System.out.print("Subject A Marks: ");
sA[i] = in.nextInt();
System.out.print("Subject B Marks: ");
sB[i] = in.nextInt();
System.out.print("Subject C Marks: ");
sC[i] = in.nextInt();
avg[i] = (sA[i] + sB[i] + sC[i]) / 3.0;
}
System.out.println("\nRoll No\tAverage Marks");
for (int i = 0; i < TOTAL_STUDENTS; i++)
{
System.out.println(rollNo[i] + "\t" + avg[i]);
}
System.out.println("\nStudents with Average above 80:");
for (int i = 0; i < TOTAL_STUDENTS; i++)
{
if (avg[i] > 80)
System.out.println(rollNo[i] + "\t" + avg[i]);
}
System.out.println("\nStudents with Average below 40:");
for (int i = 0; i < TOTAL_STUDENTS; i++)
{
if (avg[i] < 40)
System.out.println(rollNo[i] + "\t" + avg[i]);
}
}

Write a program showing implementation of stack class having the functionality of push, pop operations.

#include<iostream.h>
#define MAX 10
class stack
{
private:
int arr[ MAX ], top;
public:
stack( )
{
top = -1;
}
void push( int item )
{
if( top == MAX - 1 )
{
cout << endl << "Stack is full";
return;
}
top++;
arr[ top ] = item;
}
int pop( )
{
if( top == -1 )
{
cout << endl << "Stack is empty";
return NULL;
}
int data = arr[ top ];
top--;
return data;
}
};
void main( )
{
stack s;
s.push( 11 );
s.push( 12 );
s.push( 13 );
s.push( 14 );
s.push( 15 );
s.push( 16 );
s.push( 17 );
s.push( 18 );
s.push( 19 );
s.push( 20 );
s.push( 21 );
int i = s.pop( );
cout << endl << "Item popped=" << i;
i = s.pop( );
cout << endl << "Item popped=" << i;
i = s.pop( );
cout << endl << "Item popped=" << i;
i = s.pop( );
cout << endl << "Item popped=" << i;
}

Friday 1 May 2020

WAP to find the maximum in an array

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],max,i;
clrscr();
printf(“enter element for the array: ”);
for(i=0;i<5;i++)
scanf(“%d”,&a[i]);
max=a[0];
for(i=1;i<5;i++)
{
if(max<a[i])
max=a[i];
}
printf(“maximum no= %d”,max);
getch();
}

Write a program to accept 10 different decimal numbers (double data type) in a Single Dimensional Array (say, A). Truncate the fractional part of each number of the array A and store their integer part in another array (say, B).

import java.util.Scanner;
public class ATS
{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
double a[] = new double[10];
int b[] = new int[10];
System.out.println("Enter 10 decimal numbers");
for (int i = 0; i < a.length; i++)
{
a[i] = in.nextDouble();
b[i] = (int)a[i];
}
System.out.println("Truncated numbers");
for (int i = 0; i < b.length; i++)
{
System.out.print(b[i] + ", ");
}
}
}

Write a Program for reading and writing data to and from the file using command line arguments.

#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
int number[9] = {11,22,33,44,55,66,77,88,99};
if(argc!=3)
{
cout<<"argc="<<argc<<"\n";
cout<<"Error in arguments\n";
exit(1);
}
ofstream fout1, fout2;
fout1.open(argv[1]);
if(fout1.fail())
{
cout<<"Could not open the file:"
<<argv[1]<<"\n";
exit(1);
}
fout2.open(argv[2]);
if(fout2.fail())
{
cout<<"Could not open the file:"
<<argv[2]<<"\n";
exit(1);
}
for(int i=0; i<9; i++)
{
if(number[i] % 2 == 0)
fout2<<number[i]<<" ";
else
fout1<<number[i]<<" ";
}
fout1.close();
fout2.close();
ifstream fin;
char ch;
for(i=1; i<argc; i++)
{
fin.open(argv[i]);
cout<<"Contents of "<<argv[i]<<"\n";
do
{
fin.get(ch);
cout<<ch;
}while(fin);
cout<<"\n\n";
fin.close();
}
return 0;
}

How to Learn Hindi Typing in 5 Minutes



How to Learn Hindi Typing in 5 Minutes :
5 मिनिट में हिंदी टाइपिंग करना सीखे :
दोस्तों आज और अब मै आपको हिंदी टाइपिंग सीखने का आसान तरीका बताऊंगा , अब आप इस आर्टिकल को पढने के बाद फटाफट हिंदी टाइपिंग सीख पायेंगे| पहले गूगल की साईट पर ही यह व्यवस्था थी जिससे हम आसानी से हिंदी टाइपिंग कर  सकते थे, पर अब गूगल ने यह टूल वहां हटा लिया है| लेकिन आप फ़िक्र न करे हम आपकी समस्या को समझते है और आपको बातायेंगे कई आप 5 मिनिट में हिंदी टाइपिंग कैसे करें|
गूगल हिंदी इनपुट टूल ( Google Hindi Input Tool) एक ऐसा सॉफ्टवेर है जिससे हम आसानी से हिंदी टाइपिंग कर सकते है| आप निचे लिखे हुए steps को करते जाये और गूगल हिंदी इनपुट टूल ( Google Hindi Input Tool) को डाउनलोड (Download) करले|
स्टेप-१ : सबसे पहले नीचे दिए लिंक से सॉफ्टवेर को डाउनलोड करे|
(step-1) : Download the software from given Link ,





स्टेप-२ : अब इस सोफ्टवेयर को अनज़िप (unzip / extract) करले |
(step-2) : Extract the Download software ,

स्टेप-3 : अब  इस पहले सॉफ्टवेर को इन्स्टाल करले |
(Step-3): Now Install First Software

स्टेप ४: अब  इस दूसरे सॉफ्टवेर को इन्स्टाल करले |
(Step-4): Now Install Second Software


स्टेप -5 : अब आपको एक न्य icon , taskbaar में मिलेगा , उसे खोल ले |
(Step-5): Now you will find the icon in task bar.


स्टेप- ६: इसमें हिंदी गूगल इनपुट टूल को सेलेक्ट करे|
(Step-6): Now Select th Hindi Input Tools.\


स्टेप-७: अब आप किसी भी सॉफ्टवेर में हिंदी में टाइप कर सकते है|
(Step-7): Now you can type anything in the MS word or any other software of typing.


आपको यदि पोस्ट से फायदा हुआ हो या अच्छी लगी हो तो कमेंट्स जरूर करे|
धन्यवाद|

इनमे आपने सिखा कि: हिंदी टाइपिंग सीखने के लिए अब आसान तरीका, हिंदी टाइपिंग सीखने कई ट्रिक, हिंदी टाइपिंग कैसे सीखी जाती है, हिंदी में टाइपिंग कैसे करे , हिंदी टाइपिंग जल्दी कैसे सीखे