Wednesday, April 1, 2015

C program to accept n number from user store these numbers into an array and sort the numbers of an array.

Write a C program to accept ‘n’ number from user, store these numbers into an array and sort the numbers of an array.

#include<stdio.h>
#include<conio.h>
void main()
{
  int n,a[20],i,j,temp;
  clrscr();
  printf("\n ENTER HOW MANY NO U WANT");
  scanf("%d",&n);
  printf("enter the elements\n");
  for(i=0;i<n;i++)
  {
   scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
      if(a[i]<a[j])
      {
  temp=a[i];
  a[i]=a[j];
  a[j]=temp;
      }
    }
   }
   printf("\nSORTED ARRAY ELEMENTS \n");
   for(i=0;i<n;i++)
   {
     printf("%d\t",a[i]);
   }
   getch();
  }

C program to accept customer details

Write a ‘C’ program to accept customer details such as: Account_no, Name, Balance in account, Assume Maximum 20 customers in the bank.
Write a function to print the account no and name of each customer with
balance below Rs.100.

Solution:-

#include<stdio.h>
#include<conio.h>
struct customer
{
int accno;
char cname[20];
int bal;
};
void disp(struct customer * , int);
void main()
{
struct customer c[20];
int i,n;
clrscr();
printf("\nHOW MANY CUSTOMER U WANT");
scanf("%d",&n);
printf("\nENTER THE ACCNO,CNAME,BAL");
for(i=0;i<n;i++)
{
scanf("%d%s%d",&c[i].accno,&c[i].cname,&c[i].bal);
}
disp(&c[0],n);

getch();
  }
  void disp(struct customer *d,int n)
  {
    int i;
    for(i=0;i<n;i++)
    {
if(d[i].bal<100)
{
printf("\n%d\t%s",d[i].accno,d[i].cname);
}
    }
 }

C program menu drive example

Write a menu driven program in ‘C’ that shows the working of a library.
The menu option should be
- Add book information.
- Display book information.
- List all books of given author.
- List the count of books in the library.
- Exit.
(Using Structure Array)

#include
#include
struct book
{
int bno;
char bname[20],author[20];
};
void main()
{
struct book b[10];
int i,n,m;
char t[10];
clrscr();
do
{
printf("\n1.ADD BOOK INFORMATION");
printf("\n2.DISPLAY BOOK INFORMATION");
printf("\n3.LIST ALL BOOKS OF GIVEN AUTHOR");
printf("\n4.TOTAL NO OF BOOKS IN LIBRARY");
printf("\n5.EXIT");
printf("\nENTER UR CHOICE");
scanf("%d",&m);
switch(m)
{
case 1:
printf("\nHOW MANY BOOKS WANT");
scanf("%d",&n);

printf("\nENTER THE BNO,BNAME & AUTHOR");
for(i=0;i {
scanf("%d%s%s",&b[i].bno,&b[i].bname,&b[i].author);
}
break;
case 2:
printf("\nBOOK DETAILS \n");
for(i=0;i {
printf("\n%d\t%s\t%s",b[i].bno,b[i].bname,b[i].author);
}
break;
case 3:
printf("\nENTER THE AUTHOR NAME");
scanf("%s",&t);
printf("\n BOOK LIST");
for(i=0;i {
if(strcmp(&b[i].author,&t)==0)
{
printf("\n BOOK NAME");
printf("\n%s",b[i].bname);
}
}
break;
case 4:
printf("\n%d",n);
break;
case 5:
exit(0);
}
}
while(m!=5);
getch();
}

Friday, March 6, 2015

Visual basic program to create calculator with extra two button for factorial and check even/odd.

Design window  :-
Take button on form and one textbox on form and make it place as shown below and then in code window of each button do following coding.


Dim operand1 As Double
Dim operand2 As Double
Dim operator As String

Private Sub Command1_Click()
Text1.Text = Text1.Text + "1"
End Sub

Private Sub Command2_Click()
Text1.Text = Text1.Text + "2"
End Sub

Private Sub Command3_Click()
Text1.Text = Text1.Text + "3"
End Sub

Private Sub Command4_Click()
Text1.Text = Text1.Text + "4"
End Sub

Private Sub Command5_Click()
Text1.Text = Text1.Text + "5"
End Sub

Private Sub Command6_Click()
Text1.Text = Text1.Text + "6"
End Sub

Private Sub Command7_Click()
Text1.Text = Text1.Text + "7"
End Sub

Private Sub Command8_Click()
Text1.Text = Text1.Text + "8"
End Sub

Private Sub Command9_Click()
Text1.Text = Text1.Text + "9"
End Sub

Private Sub Command10_Click()
Text1.Text = Text1.Text + "0"
End Sub

Private Sub Command11_Click()
Text1.Text = Text1.Text + "."
End Sub

Private Sub Command12_Click()
Text1.Text = ""
End Sub

Private Sub Command13_Click()
operand1 = Val(Text1.Text)
operator = "+"
Text1.Text = ""
End Sub

Private Sub Command14_Click()
operand1 = Val(Text1.Text)
operator = "-"
Text1.Text = ""
End Sub

Private Sub Command15_Click()
operand1 = Val(Text1.Text)
operator = "*"
Text1.Text = ""
End Sub

Private Sub Command16_Click()
operand1 = Val(Text1.Text)
operator = "/"
Text1.Text = ""
End Sub

Private Sub Command17_Click()
Dim n As Integer
Dim fact As Integer
fact = 1
n = Val(Text1.Text)
For i = 1 To n
fact = fact * i
Next
MsgBox "Factorial of " & n & " is = " & fact
Text1.Text = ""
End Sub

Private Sub Command18_Click()
Text1.Text = Text1.Text * -1
End Sub

Private Sub Command19_Click()
Dim n As Integer
n = Val(Text1.Text)
If n Mod 2 = 0 Then
MsgBox "Number is EVEN"
Else
MsgBox "Number is ODD"
End If
Text1.Text = ""
End Sub

Private Sub Command20_Click()
Dim result As Double
operand2 = Val(Text1.Text)
If operator = "-" Then result = operand1 - operand2
If operator = "*" Then result = operand1 * operand2
If operator = "+" Then result = operand1 + operand2
If operator = "/" And operand2 <> "0" Then result = operand1 / operand2
Text1.Text = result
End Sub
=============================================================
OUTPUT



Saturday, February 28, 2015

Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading

Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<float.h>
class bubble
{
public:void array(int ans);
       void array(float ans);
};
void bubble:: array(int ans)
       {
       cout<<"\n"<<ans;
       }
void bubble::array(float ans)
       {
       cout<<"\n"<<ans;
       }
int main()
{
bubble bb;
int i,j,n,a[20],temp=0;
float b[20];
clrscr();
cout<<"\n Enter how many integer number you want to enter:-";
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
n=n-1;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
n++;
cout<<"\n Integer array after sorting:-";
for(i=0;i<n;i++)
bb.array(a[i]);
cout<<"\n Enter how many float number you want to enter:-";
cin>>n;
for(i=0;i<n;i++)
cin>>b[i];
n=n-1;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(b[j]>b[j+1])
{
float(temp)=b[j];
b[j]=b[j+1];
b[j+1]=float(temp);
}
}
}
n++;
cout<<"\n Float array after sorting:-";
for(i=0;i<n;i++)
bb.array(b[i]);
getch();

return 0;
}

==================================================
OUTPUT

Enter how many integer number you want to enter:-5                             
9                                                                              
8                                                                              
7                                                                              
4
1                                                                              
                                                                               
Integer array after sorting:-                                                  
1                                                                              
4                                                                              
7                                                                              
8                                                                              
9  
                                                                           
Enter how many float number you want to enter:-4                               
6.3                                                                            
5.2                                                                            
4.2                                                                            
1.3                                                                            
                                                                               
Float array after sorting:-
1.3
4.2
5.2
6.3

Write a C++ program to Design a class which contain static data member and member function show()

Design a class which contain static data member and member function show() which display number of times display operation is performed irrespective of the object responsible for display using static data
member.

#include<conio.h>
#include<iostream.h>
class number
{
public:static int cnt;
public:static void show()
       {
       cnt++;
       cout<<"\n Number of times display operation is performed:-"<<cnt;
       }
};
int number::cnt;
int main()
{
number n1,n2,n3,n4;
clrscr();
n1.show();
n2.show();
n3.show();
n4.show();
getch();
return 0;
}


==================================================
OUTPUT

Number of times display operation is performed:-1
Number of times display operation is performed:-2
Number of times display operation is performed:-3
Number of times display operation is performed:-4

Write a c++ program using class to calculate cube and square of a given number using inline function.

Write a c++ program using class to calculate cube and square of a given number using inline function.

#include<iostream.h>
#include<conio.h>
class calc
{
int no;
public:inline void number()
       {
       int square,cube;
       cout<<"Enter the number";
       cin>>no;
       square=no*no;
       cube=no*no*no;
       cout<<"Square of a given number is:-"<<square;
       cout<<"\n Cube of a given number is:-"<<cube;
       }
       };
int main()
{
calc c;
clrscr();
c.number();
getch();
return 0;
}

======================================================
OUTPUT:-
Enter the number5
Square of a given number is:-25
Cube of a given number is:-125

What is Next JS?

 What is Next JS? Next.js is a powerful React framework developed by Vercel that simplifies building modern web applications. Its key featur...