Posts

RDBMS examples

Q.3). movie (mvno,mvname,releaseyear)          Actor (actno,actname)          Relationships between movie and actor is many to many with descriptive attribute rate of actor for movie.              Constraints:- primary key. SQL> select * from movie;  MVNO    MVNAME         RELEASEYEAR ----------  --------------------  -----------          1     dhoom                       2002          2     DDLJ                        1999          3    MBBS                        2000          4    om kare           ...

C program to swap the values of two variables by using call by references.

rite a ‘C’ program to swap the values of two variables by using call by references. #include<stdio.h> #include<conio.h> void main() { char name[5][10],temp[10]; int i,j; clrscr(); printf("\nENTER THE 5 NAMES"); for(i=0;i<5;i++) { scanf("%s",&name[i]); } for(i=0;i<5;i++) { for(j=i+1;j<5;j++) { if(strcmp(&name[i],&name[j])>0) { strcpy(temp,&name[i]); strcpy(&name[i],&name[j]); strcpy(&name[j],temp); } } } printf("\n SORTED NAMES ARE \n"); for(i=0;i<5;i++) { printf("%s\n",name[i]); } getch(); }

C program to swap the values of two variables by using call by reference using pointer.

Write a ‘C’ program to swap the values of two variables by using call by reference using pointer. #include<stdio.h> #include<conio.h> void swap(int *,int *); void main() { int a,b; clrscr(); printf("\nENTER THE VALUE FOR A & B"); scanf("%d%d",&a,&b); printf("\n\nVALUES BEFORE SWAPPING \n"); printf("%d\t%d",a,b); swap(&a,&b); getch(); } void swap(int *x,int *y) { int t; { t=*x; *x=*y; *y=t; } printf("\n\nVALUES AFTER SWAPPING \n"); printf("%d\t%d",*x,*y); }

C program to write a macro definition

Write a ‘C’ program to write a macro definition for the following. > To test whether a character is a lower case letter or not. > To check whether a character is alphabet or not. > To obtain the largest of two numbers. #include<stdio.h> #include<conio.h> #define LOWER(ch) islower(ch) #define ALPHA(ch) isalpha(ch) #define MAX(a,b) a>b?a:b void main() { int n,a,b; char c; clrscr(); do { printf("\n1.LOWER"); printf("\n2.ALPHABET"); printf("\n3.MAXIMUM"); printf("\n4.EXIT"); printf("\nENTER UR CHOICE"); scanf("%d",&n); switch(n) { case 1: printf("\nENTER THE CHARACTER"); c=getche(); if(LOWER(c)) { printf("\nCHARACTER IS IN LOWERCASE\n"); } else { printf("\nCHARACTER IS IN UPPERCASE"); } break; case 2: printf("\nENTER THE CHARACTER"); c=getche()...

C program to copy the contents of one file into another file.

Write a ‘C’ program to copy the contents of one file into another file. #include<stdio.h> #include<conio.h> void main() { FILE *fp,*fq; char ch; clrscr(); fp=fopen("a.c","r"); fq=fopen("b.c","w"); if(fp==NULL) { printf("FILE DOES NOT EXIST"); exit(0); } if(fq==NULL) { printf("FILE DOES NOT EXIST"); exit(0); } while(1) { ch=fgetc(fp); if(ch==EOF) break; fputc(ch,fq); } fclose(fp); fclose(fq); getch(); }

C program to accept a string from user and generate given pattern.

 Write a ‘C’ program to accept a string from user and generate following pattern.          (e.g. input is string “abcd”)           a           ab           abc           abcd           abc           ab           a         ------------------------------------------------------------------------------------------- Solution:- #include<stdio.h> #include<conio.h> void main() { int i,j,k,cnt=0; char name[10]; clrscr(); printf("enter the string"); scanf("%s",&name); cnt= strlen(name);         {   cnt++; } printf("\n"); for(i=0;i<=cnt-1;i++) { for(j=0;j<=i;j++) { printf("%c",name[j]); } printf("\n"); } for(k=i-1;k>=0;k--) { for(j=0;j<k;j++) { printf...

C program to convert given decimal number into binary number.

Write a ‘C’ program to convert given decimal number into binary number. #include<stdio.h> #include<conio.h> void main() { int a[10],i=0,n,j; clrscr(); printf("enter the no"); scanf("%d",&n); while(n>0) { a[i]=n%2; n=n/2; i++; } for(j=i-1;j>=0;j--) { printf("%d",a[j]); } getch(); }