Pages

Sunday, 28 May 2017

Setting Combo-box Value and Display Data with VB.Net

I was working on a Brokerage Calculation project where I need to load a table’s data into combo box as in the form of value member and display member because a combo-box store two value ID which not shown at drop down list but reside in combo-box .
We need to Set/Get data through value because it’s mostly primary key and  display mode for display 
field. Take a look on following code:

Dim con As New OleDbConnection(getconstr)
Dim da As New OleDbDataAdapter(sql, con)

Friday, 26 May 2017

What are merits and demerits of array in C?

Q : What are merits and demerits of array in C?

Why we need an array.

We need array when there is a need to process more than data with similar type. For example 
  • Taking marks of 10 student needs of ten integer 
  • Taking name of more than one character 
  • Structure record and many more

Criteria mentioned above can also be achieved through variable , but variables have following drawback which lead to use array instead of Variable.
  • Each variable must has unique name which increase complexity when a large number of variables need to make. 
  • Each variable load in memory at random order. So if you want to process all variable then you need to process each variable individually because allocation of space is not continuous.

For understand the above point you need to imagine a real life example.

Two close friend group decided to watch a movie and they follow two different approaches as follows


  • Friends in Group one purchase ticket individually without any coordination between them for seating arrangement 
  • Friend in group two book seats continuously i.e. seats no 1 to 10.
So Group two can make better communication than group one. In same way array works.

Advantage

  • Continuous memory allocation.
  • Process a collection of similar data type.
  • Can be used to make data structure like stack,tree,queue etc.
  • Easy to visit each element using index.

Disadvantage

  • Static memory allocation 
  • Due to static memory allocation number of element cannot be increase nor decrease at run time.
  • The elements of array are stored in consecutive memory locations. So insertions and deletions are very difficult and time consuming.

Write a C program to find size of structure without using sizeof operator.

Q  : Write a C program to find size of structure without using sizeof operator.

#include<stdio.h>
#include<conio.h>
struct stu
{
     int roll;
     char name[20];
     float marks[3];
};

Write a C program to find the square root of a given quadratic equation.

Q1 : Write a C program to find the square root of a given quadratic equation.
#include <math.h>

int main()
{
    double a, b, c, determinant, root1,root2, realPart, imaginaryPart;

    printf("Enter coefficients a, b and c: ");
    scanf("%lf %lf %lf",&a, &b, &c);

    determinant = b*b-4*a*c;

Wednesday, 24 May 2017

Write a C program to print given number of terms of a Fibonacci series.

Q 1 :  Write a C program to print given number of terms of a Fibonacci series.

Solution : 

#include<stdio.h>
void main()
{
    int a,b,c;
   c=1;
   a=0;

Write a C program to read a line and print it reverse using recursive function.

Q : Write a C program to read a line and print it reverse using recursive function.

Solution : 


#include<stdio.h>
#include<string.h>
#include<process.h>
void print(int len,char str[])
{
int n=len;
if(n==-1)
exit(1);

Sunday, 7 May 2017

Call by value Call by reference



Call by value

The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.

Wednesday, 3 May 2017

Customized web page print using Java Script




Printing a webpage is another important aspect of web development. If you skip this section then when your user will be print a page then it will print as it is, which not good for all case because we add a lot of formatting images on webpage. So all the things on the page will get printed that will be worse.

Customizing web page output is good practice to make a webpage. Because what we see on web page we don’t need to take output on paper same format so customization is mandatory.


Following example will print table as with custom header.


Roll Name City
101 Sona Vns
102 Amit Alld
103 Sumi Alld
104 Rakesh Vns
105 Jyoti alld