Thursday, November 30, 2017

Program to return maximum link value if all link values are unique, other wise returns maximum repeated link value

/*   Program Long Coding : IMGIT Online Paper Dt :29-11-2017
program return max link value if all link values are unique other wise returns maximum repeated link value
10 20 30 40 50  it has to return 50
10 20 20 20 30 20it has to return 20
 */
# include <stdio.h>
# include <stdlib.h>
# include <conio.h>

struct link
{
int data;
struct link*next;
};

struct link*first=NULL;
struct link*last=NULL;

addlink(int dat)
{
struct link*newlink;

newlink=(struct link*)malloc(sizeof(struct link));
newlink->data=dat;
newlink->next=first;
first=newlink;

/* init last link */
last=newlink;

}

displaylinks()
{
struct link*current;
current=first;
while(current!=NULL)
{
printf("\n%d",current->data);
current=current->next;
}
}
int getmax()
{
    struct link*current;
    int max;
    current=first;
    max=current->data;
while(current!=NULL)
{
    if(current->data>max)
            max=current->data;
                current=current->next;
}

return max;
}

int findrptlink()
{
    struct link*current,*curr;
    int ctr=0,max=0,rptval;
current=first;
while(current!=NULL)
{
    ctr=0;
    curr=first;
        while(curr!=NULL)
        {
    //printf("\t%d",curr->data);
    if(current->data==curr->data)
            ctr++;
        curr=curr->next;
        }

    if(max<ctr)
        {
            max=ctr;
            rptval=current->data;
            //printf("\n%d..%d",ctr,current->data);
        }
        current=current->next;
}

if(max==1)
printf("\n%d",getmax());
else
    printf("\n%d",rptval);

}
/* program return max link value if all link values are unique other wise returns maximum repeated link value */


int main()
{
//clrscr();
puts("Linked list program");
addlink(10);
addlink(10);
addlink(130);
addlink(30);
addlink(30);
addlink(10);

    //displaylinks();

//displaylinks();
findrptlink();



}

















Saturday, November 25, 2017

Decimal to binary conversion using recursion function in C

/* decimal  to binary conversion using recursion */
#include<stdio.h>
#include<conio.h>
long binary(long  n){
static long int   bin=0,base=1;
if(n>0)
{
printf("%d",n%2);
bin=bin+n%2*base;
base*=10;
binary(n/2);
}
return bin;
}
main(){
long int n=100;
clrscr();
printf("\nbinary no is %ld",binary(n));
}

Tuesday, November 21, 2017

Practice for 3rd CSE RGAN dt 22-11-17

UNBOLD THE ANSWERS
1)
main(){
printf("%d  %d   %d",sizeof(400L),sizeof(400)
,sizeof(400.0));
a)4 2 8     b)2  2 4      c)2 2 8     3)error

2)
char ch='xy';
val of ch is?
a)y         (b)x            c)none      d)NULL
3)
main()
{ int a=5,b;
b=(a++,a++,++a,7*++a);
}     a value is?
a)35       b)42        c)57       d)error

4)
main()
{
int a;
a=sizeof(!-1.5);
printf("%d",a);
}
a)2    b)4    c)0   d)error
----------------------------------
# define no 5
# define noo no*no
main() {
printf("\n%d",noo);
}
a)error     b)25     c)55     d)5
-----------------------------------------
main()
{
int x;
x=10,20,30;
printf("%d",x);
}
a)30   b)20    c)10   d)error;

11)
main()
{
int a=117;
printf("%x",a);
}
a)75     b)117   c)error   d)0

6)
main(){
enum    bykes{suzuki,honda=3,hero};
printf("%d",suzuki+hero);
}
a)4       b)2       c)6     d)error
7)
Main()
{
int a=3,b=7,c;
c=a==b==1;
printf("%d",c); 
}
a)1           b)0        c)3      d)7


8)
main(){
int a=2;
if(a==2);
a=~a++*2;
printf("%d",a);
}
a)-8   b)-5   c)error   d)

9)
main()
{
int a=5,b=6;
if(a++ == b-- && --a==++b)
printf("true");
else
printf("\nfalse");
}
a)true     b) error      c) false    d)truefalse



Wednesday, November 8, 2017

Popup a dialog-box when loading a page using js

<!DOCTYPE html>
<html>
  <head>
    <meta charset=utf-8 />
    <title>ColorBox demo</title>
    <link rel="stylesheet" href="http://www.jacklmoore.com/colorbox/example1/colorbox.css" />
  </head>
  <body>
    <h1>Hello, there!</h1>
    <h2>This is some content</h2>
    <p>The popup will open in five seconds</p>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="http://www.jacklmoore.com/colorbox/jquery.colorbox.js"></script>
    <script>
      function openColorBox(){
        $.colorbox({iframe:true, width:"80%", height:"80%", href: "http://risegroup.edu.in/rise-20171104.JPG"});
      }
  //delay of 1 sec
      setTimeout(openColorBox, 1000);
    </script>
  </body>
</html>