Online Examination System for all learner!!! coming soon..

Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

JAVA : Program to find sum of all integer greater than 100 and less than 200, that are divisible by 5

 Code:

class findsum
//for more program please visit www.programtubenotes.blogspot.in
{
    public static void main(String args[])
    {
        int a,sum=0;
        for(a=100;a<=200;a++)
        {
            if(a%5==0)
                sum=sum+a;
        }
        System.out.println("Sum="+sum);
    }
}

Output: 

Sum=3150

JAVA : Program to demonstrate concept of Polymorphism (Overriden).

 demonstrate concept of Polymorphism (Overriden).

Sourse Code:

class Funcover

{

public void calc(int x,int y)

{

int z;

z=x*y;

System.out.println("multiplication="+z);

}

}

class Override extends Funcover

{

public void calc(int x,int y)

{

int z;

z=x/y;

System.out.print("division="+z);

}

}

class Overrideex

{

public static void main(String arg[])

{

Funcover f1=new Funcover();

f1.calc(7,6);

Override f2=new Override();

f2.calc(14,2);

}

}

Output:

multiplication=42

division=7 

VB 6.0: Control text size of TextBox using Scroll Bar

Visual Basic program to control fontsize of text of text box using scroll bar 

Disign :

Code:

//for more program please visit www.programtubenotes.blogspot.in 
Private Sub Form_Load()
VScroll1.Min = 1
VScroll1.Max = 200
Text1.Text = "Program Tube"
End Sub

Private Sub VScroll1_Change()
Text1.FontSize = VScroll1.Value
End Sub

Output:

 

Related Videos:

C: Sudoku Solver

Sudoku Game in 'C'

Figure: Sudoku
   Here i have developed a program in C to solve Sudoku for 2x2 to 9x9 matrix! the code will ask for no of rows and columns at first, it means you have to add 2 by 2,or 3x3,or ...9x9, now give the inputs one by one and after entering each i/p press enter, after finishing giving i/ps,it will show the sudoku matrix, and you can verify, whether your sodoku is correct or incorrect. And if incorrect, which column or row has the wrong i/p, try out this new code. An example is shown with 3X3 matrix, you can try out with diff matrix even. Hoping to have Good Response.
Code:
//**source code in C**//
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
  
    int i,j,n,s;
int k,l;
int value[9][9];
    int total_row[9];
    int total_col[9];
    printf("'enter the inputs of a soduko,and check whether its correct or not'\n");
printf("\n input no of 'rows x column' \n");

    scanf("\n%d",&k);
    scanf("\t%d",&l);
  
    printf("values\n");
    for(i=0;i<k;i++)
    {
  
        total_row[i]=0;
        for(j=0;j<l;j++)
        {
            scanf("%d",&value[i][j]);
          
            total_row[i]=total_row[i]+value[i][j];
        }
    }
  
  
for(j=0;j<l;j++)
    {
        total_col[j]=0;
        for(i=0;i<k;i++)
        {
          
            total_col[j]=total_col[j]+value[i][j];


        }
    }


for(i=0;i<k;i++)
    {
        printf("\n");
        for(j=0;j<l;j++)
        {
            printf(" \t %d ",value[i][j]);
        }
    }



s=((k*(k+1))/2);
for(n=0;n<k;n++)
{
    if((total_col[n])!=s)
  
      
    printf("\n incorrect i/p's col_%d ",n+1 );
  
    else if((total_row[n])!=s)
  
    printf(" incorrect i/p's row_%d ",n+1);
    else if(total_row[n] && s && total_col[n])
  
    printf("\n correct i/p for both %d  row and col ",n+1);
  
    else if(total_row[n] && s )
  
    printf("\n correct i/p for %d  row  ",n+1);
    else if(s && total_col[n])
  
    printf("\n correct i/p for %d  col ",n+1);
  
  
    else
    {
    }
}
//fflush(stdin);
getch();
getch();
getch();
getch();
getch();
getch();
getch();
getch();
}

Output:



C++: Program to calculate age in years, months and days.

Input the date of birth of a person and find his age in terms of year, month and days. using class.

Age Calculator of a Person

Code:

//for more program please visit www.programtubenotes.blogspot.in 
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#define WELCOME "WELCOME TO AGE CALCULATOR"

using namespace std;


class Age
{
    private:
        int day,month,year;
    public:
        void getdata();   //input date
        friend void show(Age t, Age b, Age a);//calculate age
};
void Age::getdata()
{
    cin>>day>>month>>year;
}
void show(Age t, Age b, Age a)
{
    if(t.day<b.day)
    {
        t.month--;
        t.day+=30;
    }
    a.day=t.day-b.day;
    if(t.month<b.month)
    {
        t.year--;
        t.month+=12;
    }
    a.month=t.month-b.month;
    a.year=t.year-b.year;
    cout<<"\nYour Age is  "<<a.year<<" year "<<a.month<<" month "<<a.day<<" day ";
   
    cout<<"\n\n\nCreated By:- Mr. Maheswar Sahoo\nFor more application please contact:-maheswarsahoo47@gmail.com";
    cout<<"\nThank You...\n\n\n";
}
int main()
{
    system("COLOR 4C");  //for background color
    Age birth;
    Age today,age;
    cout<<"\t\t\t\t"<<WELCOME;
    cout<<"\n\n\nEnter date of today (dd mm yyyy) : ";
    today.getdata();
    system("COLOR 1C");   //change background color
    cout<<"\nEnter date of birth (dd mm yyyy) : ";
    birth.getdata();
    show(today,birth,age);
    return 0;
}



We suggest this video to watch:




Related word:
Class



Popular codes:

C Programming Online Test 1

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...