Mar

23

#include<stdio.h>
#include<stdlib.h>
void main(){
int *ptr1;
int n,i,j,flg;
printf(“How many numbers you want to enter: “);
scanf(“%d”,&n);
ptr1=(int*) malloc(n*sizeof(int));
printf(“Enter %d numbers:\n”,n);
for(i=0;i<n;i++){
scanf(“%d”,(ptr1+i));
}
// to find the prime numbers
for(i=0;i<n;i++){
//*(ptr1+i);
flg=0;
for(j=2;j<*(ptr1+i);j++){
if(*(ptr1+i)%j==0){
flg=1;
break;
}
}
if(flg==0)
printf(“%d is a Prime Number\n”,*(ptr1+i));
}
free(ptr1);
}

Comments Off on Prime numbers using dynamic memory allocation in 1-D Array prog-5

Mar

22

#include<stdio.h>
#include<alloc.h>
void main(){
int *ptr;
int n,i,grt,smt;
printf(“How many numbers you want to enter: “);
scanf(“%d”,&n);
ptr=(int*) malloc(n*sizeof(int));
printf(“Enter %d numbers: \n”,n);
for(i=0;i<n;i++){
scanf(“%d”,(ptr+i));
}
grt=*ptr;
smt=*ptr;
for(i=0;i<n;i++){
if(*(ptr+i)>grt)
grt=*(ptr+i);
if(*(ptr+i)<smt)
smt=*(ptr+i);
}
printf(“Greatest Number among entered %d numbers is: %d\n”,n,grt);
printf(“Smallest Number among entered %d numbers is: %d\n”,n,smt);
printf(“Diff between Smallest and Greatest Number is: %d\n”,(grt-smt));
}

Mar

22

#include<stdio.h>
void main(){
int *ptr;
int n,i;
printf(“How many numbers you want to enter: “);
scanf(“%d”,&n);
ptr=(int*) malloc(n*sizeof(int));
printf(“Enter %d numbers: \n”,n);
for(i=0;i<n;i++){
scanf(“%d”,(ptr+i));
}
printf(“Entered %d numbers are: \n”,n);
for(i=0;i<n;i++){
printf(“%d\n”,*(ptr+i));
}
}

Mar

22

#include<stdio.h>
void main(){
int *ptr;
ptr=(int*) malloc(sizeof(int));
printf(“sizeof(int)= %d\n”,sizeof(int));
printf(“ptr= %u\n”,ptr);
//*ptr=30;
printf(“Enter a Number: “);
scanf(“%d”,ptr);
printf(“*ptr= %d\n”,*ptr);
}

Mar

22

#include<stdio.h>
#include<alloc.h>
int *fact(int *p){
int f=1;
int j;
for(j=1;j<=*p;j++){
f=f*j;
}
return(&f);
}
void main(){
int *ptr;
int n,i,*ff;
printf(“How many numbers you want to enter: “);
scanf(“%d”,&n);
ptr=(int*) malloc(n*sizeof(int));
printf(“Enter %d numbers: \n”,n);
for(i=0;i<n;i++){
scanf(“%d”,(ptr+i));
}
for(i=0;i<n;i++){
ff=fact(ptr+i);
printf(“Factorail of %d is: %d\n”,*(ptr+i),*ff);
}
}

Apr

08

JSP SAMPLE CODES DOWNLOAD

 

Nov

03

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code=”MyAppEvent1.class” width=”400″ height=”400″>
</applet>
*/
public class MyAppEvent1 extends Applet implements MouseListener{
public void init(){
addMouseListener(this);
}
public void mouseExited(MouseEvent e){
System.out.println(“mouseExited”);
}
public void mouseEntered(MouseEvent e){
System.out.println(“mouseEntered”);
}
public void mouseReleased(MouseEvent e){
System.out.println(“mouseReleased”);
}
public void mousePressed(MouseEvent e){
System.out.println(“mousePressed”);
}
public void mouseClicked(MouseEvent e){
System.out.println(“mouseClicked”);
}
}

 

//—————————————————————————————-

 

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code=”MyAppEvent2.class” width=”400″ height=”400″>
</applet>
*/
public class MyAppEvent2 extends Applet implements MouseListener{
public void init(){
addMouseListener(this);
}
String msg=””;
public void mouseExited(MouseEvent e){
msg=”MouseExited”;
repaint();
}
public void mouseEntered(MouseEvent e){
msg=”MouseEntered”;
repaint();
}
public void mouseReleased(MouseEvent e){
msg=”MouseReleased”;
repaint();
}
public void mousePressed(MouseEvent e){
msg=”MousePressed”;
repaint();
}
public void mouseClicked(MouseEvent e){
msg=”MouseClicked”;
repaint();
}
public void paint(Graphics g){
g.drawString(msg,100,100);
}
}

 

//———————————————————————————-

 

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code=”MyAppEvent3.class” width=”400″ height=”400″>
</applet>
*/
public class MyAppEvent3 extends Applet implements MouseListener{
public void init(){
addMouseListener(this);
}
String msg=””;
public void mouseExited(MouseEvent e){
msg=”MouseExited”;
repaint();
}
public void mouseEntered(MouseEvent e){
msg=”MouseEntered”;
repaint();
}
public void mouseReleased(MouseEvent e){
msg=”MouseReleased”;
repaint();
}
public void mousePressed(MouseEvent e){
msg=”MousePressed”;
repaint();
}
int x=40,y=40;
public void mouseClicked(MouseEvent e){
x=e.getX();
y=e.getY();
msg=”MouseClicked”;
repaint();
}
public void paint(Graphics g){
showStatus(x+”,”+y);
g.drawString(msg,x,y);
}
}

 

Nov

03

import java.applet.*;
import java.awt.*;
/*
<applet code=”App6.class” width=”550″ height=”350″>
</applet>
*/
public class App6 extends Applet{
public void init(){
setBackground(Color.yellow);
setForeground(new Color(88,200,0));
}
int x=20;
int flag=0;
public void paint(Graphics g){
if(x==20)
flag=0;
if(x>=500)
flag=1;
if(flag==0)
x=x+5;
if(flag==1)
x=x-5;
g.fillOval(x,20,40,40);
try{
Thread.sleep(200);
}catch(InterruptedException e){
}
repaint();
}
}

 

//——————————————————————–

 

import java.applet.*;
import java.awt.*;
/*
<applet code=”App5.class” width=”350″ height=”350″>
</applet>
*/
public class App5 extends Applet{
public void init(){
setBackground(Color.yellow);
setForeground(new Color(88,200,0));
}
public void paint(Graphics g){
g.setColor(Color.green);
g.fillOval(100,100,70,70);
try{
Thread.sleep(500);
}catch(InterruptedException e){
}
g.setColor(Color.yellow);
g.fillOval(100,100,70,70);
try{
Thread.sleep(500);
}catch(InterruptedException e){
}
repaint();
}
}

 

//————————————————————————

 

import java.applet.*;
import java.awt.*;
/*
<applet code=”App4.class” width=”350″ height=”350″>
</applet>
*/
public class App4 extends Applet{
public void init(){
setBackground(Color.yellow);
setForeground(new Color(88,200,0));
}
int flg=0;
int w=20,h=20,x=100,y=100;
public void paint(Graphics g){
g.fillOval(x,y,h,w);
if(h==100)
flg=1;
if(h==20)
flg=0;
if(flg==0){
h=h+5;
w=w+5;
x=x-1;
y=y-1;
}
if(flg==1){
h=h-5;
w=w-5;
x=x+1;
y=y+1;
}
try{
Thread.sleep(500);
}catch(InterruptedException e){
}
repaint();
}
}

 

//——————————————————————–

 

import java.applet.*;
import java.awt.*;
/*
<applet code=”App3.class” width=”350″ height=”350″>
</applet>
*/
public class App3 extends Applet{
public void init(){
setBackground(Color.yellow);
setForeground(new Color(88,200,0));
}
int w=20,h=20,x=100,y=100;
public void paint(Graphics g){
g.fillOval(x,y,h,w);
h=h+5;
w=w+5;
x=x-1;
y=y-1;
try{
Thread.sleep(500);
}catch(InterruptedException e){
}
repaint();
}
}

 

 

Oct

29

import java.applet.*;
import java.awt.*;
/*
<applet code=”App2.class” width=”250″ height=”250″>
</applet>
*/
public class App2 extends Applet{
public void init(){
setBackground(Color.yellow);
setForeground(new Color(88,200,0));
}
public void paint(Graphics g){
g.setFont(new Font(“Comic sans ms”,Font.BOLD,30));
g.drawString(“HELLLO”,40,40);
g.setFont(new Font(“Verdana”,Font.BOLD,30));
g.drawString(“HELLLO”,40,80);
g.drawLine(20,120,150,120);
g.drawOval(20,130,150,120);
g.fillOval(60,170,20,20);
g.fillOval(120,170,20,20);
g.drawLine(90,180,90,210);
g.fillOval(100,220,70,20);
}
}

Oct

29

import java.applet.*;
import java.awt.*;
/*


*/
public class App1 extends Applet{
public void init(){
System.out.println(“void init()”);
}
public void start(){
System.out.println(“void start()”);
}
public void stop(){
System.out.println(“void stop()”);
}
public void destroy(){
System.out.println(“void destroy()”);
}
public void paint(Graphics g){
System.out.println(“void paint(Graphics g)”);
}
}

Sep

26

Program to create user defined java package Click to download

 

Sep

19

Basics to Inheritance Java Programs CLICK TO DOWNLOAD

Apr

04

      1. Write a ‘C’ program to find the smallest and biggest value in a single dimensional array using array and pointer concepts.
      2. write a C program using pointer to sort the given list of numbers in ascending order.