Wednesday 30 January 2008

C question bank with detial solutions








(1)What will be output of following c program?

#include
void main(){
char far *p=(char far *)0x55550005;
char far *q=(char far *)0x53332225;
*p=25;
(*p)++;
printf(

Wednesday 23 January 2008

Necessary fundamental knowledge before actual start of C Programming Language.

Basic knowledge(1)List the five c compiler?Ans: Note:- 8086 is 16 bit microprocessor while 80386 is 32 bit microprocessor.(2) Describe turbo c compiler?Ans: Turbo c compiler is one of the most popular c compiler.It is based on DOS operating system.It uses 8086 microprocessor which is 16 bit microprocessor. It has 20 address busesand 16 data bus. It’s word length is two byte.(3) What is

Syntax of function in c

Function is block of program. When any program is very long then we try to cut the program in different parts( or blocks) so that whole program is more understandable and easier to debug (error checking).This part of program is called function. It is also useful when set of program uses many times in the program then instead of writing whole program in many time we only call the function.There

How to make user defined function as library function in c

Step:1

Function in c with no parameter and not returning any value ?

Example:void world1(); //function declarationvoid world2(); //function declarationchar c='*';int i,j;void main(){char *msg="I KNOWN FUNCTION";clrscr();world1(); //function callprintf("%c%22s%7c",c,msg,c);world2(); //function callgetch();}void world1() //function definition{int a=-1;for(i=0;i<15;i++){a++;for(j=0;j<30;j++){if(j>=(15-a) && j<(15+a)){printf(" ");}else{printf("%c",c);}}

Function in c has parameter but not returning any value

void swap(int,int);void main(){int a=10,b=15;clrscr();printf("Befor swap a=%d ,b=%d",a,b);swap(a,b);printf("\nAfter swap a=%d ,b=%d",a,b);getch();}void swap(int a,int b){int c;c=a;a=b;b=c;}Output:Before swap a=10,b=15After swap a=10,b=20Explanation: a and b are auto variable (default storage class is auto) .Here its scope is only within main function.After the main function both a and b will

Function in c with parameter and returning a value.

void main(){int a=1,b=5,c;clrscr();c=operation(a,b);printf("%d",c);getch();}int operation(int a,int b){int c;c=++a * ++a * b++;return c;}Output: 45Note. Any function can return only one value at a time. If return type is int then there is not necessity of function declaration.

What is main function in c?








Every c program starts with a main function and end with null statement.

Properties of main function:

1. Any c program can have only one main function.

2. main function is called by operating system.

3. main is not keyword of c. So any variable name can be main.

4. Programmer can also call the main function.

5. Default return type of main function is int and

Tuesday 22 January 2008

To be a good programmer is very necessary to understand the memory structure.









Memory organization

(1) What is memory cell?
Answer:




Entire RAM has divided in number of equal part, which is known as memory cell.Capacity of each cell is to store

Thursday 10 January 2008

MCQ of c programming (23 set question)









MCQ of c programming 1
Q. 1 . TurboC 3.0 is based on
a . DOS
b . UNIX
c . Windows
d . none
Q. 2 . Find the output.
void main()
{
int a=4,b=5;

C programming MCQ









(1)What will be output of following c program?

#include
void main(){
printf("%d",sizeof(3.8));
}

Output: 8

Explanation:

3.8f is float constant, 3.8 is double

Theoritical questions of function of c programming

Function:
Function is block of program. When any program is very long then we try to cut the program in different parts( or blocks) so that whole program is more understandable and easier to debug (error checking).This part of program is called function. It is also useful when set of program uses many times in the program then instead of writing whole program in many time we only call the

Theoritical questions of c programming

Necessary fundamental knowledge before actual start of C Programming Language.(1)List the five c compiler?Ans:Name Work on O.S Name of microprocessor1. Turbo c M.S DOS 80862. Ansic c LINUX/UNIX 803863. Borland c WINDOW 803864. Microsoft c M.S DOS 80865. Visual c++ WINDOW 80386Note:- 8086 is 16 bit microprocessor while 80386 is 32 bit microprocessor.(2) Describe turbo c compiler?Ans:Turbo c

Memory related question of c programming

(1) What will output:
void main()
{
int a=5,b=6,c=7;
printf(“%d,%d,%d”);
}
Ans:
Output: 7 6 5
Explanation:
Default sotrage class int a=5 is auto.Since it automatic variable it will create in the stack area.
It will store in the stack as

Stack always follows LIFO datastructure.
In the printf statement name of variable is not written explicitly.So default output will content of
Stack which

c++ question with solution and explanation

C,C++ Questions
1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived
object,. calling of that virtual method will result in which method being called?
a. Base method
b. Derived method..
Ans. b
2. For the following C program
#define AREA(x)(3.14*x*x)
main()
{float r1=6.25,r2=2.5,a;
a=AREA(r1);
printf("\n

placement question of c programming

Off Campus Written Test conducted in 3 at BangaloreThe test comprises of 2 sections: 1. Technical ( C ) & Technical Subject- 60 mins, 60 questions 2. Logical Reasoning.. - 30 mins,17 questions....
==> Questions in C were mostly from "pointers in c" and "test ur C skills" by Yeshwant Kanetkar... C questions based on command line arguments, data structure ( BST, tree traversals). All the questions

TCS C programming Questions




TCS
C frequently asked placement interview questions



What does static variable mean?

What is a pointer?

What is a structure?

What are the differences between structures and
arrays?

In header files whether functions are declared or
defined?

What are the differences between malloc() and
calloc()?

What are macros?

What are its advantages and disadvantages?

Difference between

Monday 7 January 2008

Write the c program to switch the 256 color graphics mode



Write
the c program to switch the 256 color graphics mode



#include#includevoid main(){   int x,y,b;   union REGS i,o;   i.h.ah=0;   i.h.al=0x13;   int86(0x10,&i,&o);   getch();}



Write a c program to create a directory in current working directory?

#include
#includevoid main(){   union REGS i,o;   i.h.ah=0x39;   i.x.dx="ravan";   int86(0x21,&i,&o);   
   

Project in c

Write a c program to create a simple paint brush deginer ?Ans:#include#include#include#include void main(){int x,y,b,px,py,c,p,s,cl;int d=0,m;union REGS i,o;initgraph(&d,&m,"c:\\tc\\bgi");i.x.ax=1;int86(0x33,&i,&o);i.x.ax=8;i.x.cx=20;i.x.dx=450;int86(0x33,&i,&o);printf("Brush style insert number from 0 to 5 : ");scanf("%d",&p);printf("Brush size insert

Sunday 6 January 2008

How to create dos command in c?



(1) Create a dos command: type by c program.



Answer:




Step 1: Write following code.




#include

void main(int count,char * argv[])

{

int i;

FILE *ptr;

char *str;

char ch;

if(count==1)

{

printf("The syntax of the command is incorrect.\n");

}

for(i=1;i
{

ptr=fopen(argv[i],"r");

if(ptr==NULL)

{

printf("The system cannot find the file specified.");

if(

Create dir command in c


C program or code to create DOS command DIR

Step 1: Write following code.






#include 



#include 



int main(int count,char *argv[]){



struct find_t q ;



    int a;





    if(count==1)



        argv[1]="*.*";





    a = _dos_findfirst(argv[1],1,&q);



  

if(a==0){



   
     while (!a){



   
         printf(" 
%s\n", q.name);



   
         a =

Pointer question with solution

(q)What will output :
void main()
{
int * p,b;
b=sizeof(p);
printf(“%d”,b);
}
Output: 2 or 4
Explanation:
Since in this question it has not written p is which type pointer. So it’s output will depends upon which memory model has selected. Default memory model is small.
More detail click here
(q)What will be output ?
void main()
{
int huge *a=(int huge *)0x59990005;
int huge *b=(int huge *)

Saturday 5 January 2008

string question with solution in c programming language









(1) Without using any semicolon (;) in program write a c program which output is: HELLO WORLD? Answer: void main() { if(printf("HELLO WORLD")) { } } (2)What will

How to create virus in c?




Create simple virus by c programming language.(Only for study)





Write c program which shutdown the window operating system?



Answer:





Step 1: Write the following program in TURBO C.





#include

#include



int main (void){



    system("shutdown -s");



    return 0;

}





Step 2: Save the above file. Let file name is close.c



Step 3: Only compile the above

Precedence and Associativity table of operators in c programming language



Precedence and Associativity
table of operators in c programming language 











Category



Operator



Name



Associativity





1







( )

[ ]

.

->



Function call
or brace

Array
subscription

Member access(struct
and union)

Pointer
member access(struct and union)



Left to
right





2



Unary



!

~

+

-

++

operator in c programming

Arithmetic Assignment Logical/relational Bitwise

constant in c programming

Floating point constants.
Character constants.
String constants.

creating own library function in c

Creating own library function in c programming

list of library function in c programming

ANSI standard library in c programming
list of header file in c programming

Brian Kernighan, Dennis Ritchie: The C Programming Language

Brian Kernighan, Dennis Ritchie: The C Programming Language

porject in c and c++

Make your project in c and c++ programming

Online test of c programming



                 



                TEST YOUR C SKILLS



1. Practice set 1

2. Practice set 2

3. Practice set 3

Free download ebooks of c programming


Download c programming ebook  from following links

Free download c programming ebook pdf
Download ebooks of c
Download c ebook pdf

c programming storage classes

auto
register
static
extern
typedef

list of C compiler preprocessors

list of C programming preprocessors

Bitwise operations in c programming

Bitwise operations in c

pointer in c programming

Definition of a pointer.
Pointers to strings.
Pointers to arrays.
Void pointers.
Pointers to pointers.
Pointers to functions.

link list in data strcture

link list in data strcture using c programming

link list in data structure

link list in data structure using c programming

structure in c programming

Pointers to structures.
Array of structures.

int or float arrays. two dimensional int or float arrays. char arrays. char multidimentional arrays.

Array in c programming

Friday 4 January 2008

c programming quiz with solution

C programming language quiz questions and answers for  beginners 

Time: 6 minute



(1)

void main(){


float a=30.3f;


int y=5;


clrscr();


printf("%d",a%y);


getch();


}



What will be output when you will compile above code?


(a) 6


(b) 6.0


(c) 7


(d) Compiler error


(e) None of these




(2)


void main(){


int x=5;


float r=5.0;


clrscr();


question of c programming with solution

1. Point out error, if any, in the following program
main()
{


int i=1;


switch(i)


{


case 1:


printf("\nRadioactive
cats have 18 half-lives");


break;


case 1*2+4:


printf("\nBottle for
rent -inquire within");


break;


}


}

Ans. No
error. Constant expression like 1*2+4 are acceptable
in cases of a switch.

2. Point out the error, if any, in the following program


main()


{


int a

SUN MICRO SYSTEM PLACEMENT QUESTION ON C


Sun micro
system placement interview question on c



(1) Give the output of the following program

main() {

char *s;

s="hot java"; 

strcpy(s,"solarrs java")


}



(2) Give the output of the following program

main() {

printf("hot java");

fork()

exit(0);

}



(i). When redirected to a screen what will be printed. (ii).
When redirected to file what will be printed.



(3). Give the

sun microsystem placement queston on c

23. Regarding the scope of the variables, identify the incorrect statement:

(a) automatic variables are automatically initialized to 0 (b) static variables are areautomatically initialized to 0

(c) the address of a register variable is not accessible (d) static variables cannot be initialized with any expression
24.

IBM placement question with solution on c

(1) Output of the following program isvoid main()

{int i=0;

for(i=0;i<20;i++)

{switch(i)

case 0:i+=5;

case 1:i+=2;

case 5:i+=5;

default i+=4;

break;}

printf("%d,",i);

}

}0,5,9,13,17

b) 5,9,13,17

c) 12,17,22

d) 16,21

e) Syntax errorAns. (d)(2) What is the output in the following programmain()

{char c=-64;

HOW can TAKE a paragraph at time USING scanf FUNCTION?

void main()
{
char a[30];
clrscr();
scanf("%[^\t]",a);
printf("%s",a);
getch();
}

Note: Paragraph will end when you will press tab key.

SATYAM PLACEMENT QUESTION on c and c++

(1)Which of following operator can't be overloaded.
a)==b) ++ c) ?! d) <= 2. For the following C program
#includevoid main(){printf("Hello World");}
3. For the following C program:
swap(int x,y){int temp;temp=x;x=y;y=temp;}
main(){intx=2;y=3;swap(x,y);}
After calling swap, what are the values x & y?
4. For the following C program
struct base {int a,b;base();int virtual function1();}
struct derv1:

C programming language questions

1.For the following program.struct XXX

{int a;

float b;

char *s;

}X;
If optimization :X not used in compiler then unused
bits_________________.

Give your assumption_______________.
2. Give the output of the following program
struct XXX

{int a:6;

float b:4;

char s;

}structure;
size of (structure);3.Class used for the multiple inheritance in JAVA_________________
anonymous class

(b) inner

Thursday 3 January 2008

Mouse programming in c


(1) Write a c program which restricts the movement of pointer?
Answer:




//restrict the x and y coordinate

#include

#include

void main()

{

union REGS i,o;

//show mouse pointer

i.x.ax=1;

int86(0x33,&i,&o);

//x coordinate restriction

i.x.ax=7;

i.x.cx=20;

i.x.dx=300;

int86(0x33,&i,&o);

//y coordinate restriction

i.x.ax=8;

i.x.cx=50;

i.x.dx=250;

int86(0x33,&i,&o

CREATE A FILE AND STORE DATA IN IT IN C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}











C program to create a file


C program to write to a file




C program to open a file








#include

int main(){

FILE *fp;

char ch;

fp=fopen("file.txt","w");

TO PASSING 2-DIMENSIONAL ARRAY TO A FUNCTION BY C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}








To
passing 2-dimensional (two dimensional) array to a function by c program


#include

#define M 3

#define N 5

void fstore2D(int a[][N]);

void fretrieve2D(int a[][N]);

WRITING OF ENTIRE ARRAY TO A FILE USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








Writing of
entire array to a file using c program




#include

int main(){

 
FILE *p

CONCATENATE MANY FILES AND STORE THEM IN A FILE NAMED FILES USING C PROGRAM

#include"stdio.h"
void concatenate(FILE *fp1,FILE *fp2,char *argv[],int argc);
void main(int argc,char *argv[])
{
FILE *fp1,*fp2;
concatenate(fp1,fp2,argv,argc);
getch();
}
void concatenate(FILE *fp1,FILE *fp2,char **argv,int argc)
{
int i,ch;
fp2=fopen("files","a");
for(i=1;i
{
fp1=fopen(argv[i],"r");
while((ch=getc(fp1))!=EOF)
putc(ch,fp2);
}
}

SWAP TWO VARIABLES WITHOUT USING THIRD USING C PROGRAM VARIABLE


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








Swapping in
c without temporary variable


Swap 2 numbers without using third variable in c


FIND PRIME FACTORS OF A NUMBER USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}










Prime
factor of a number in c




#include

int main(){

 
int num,i=1,j,k;

 
printf("\nEnter a number:");

 
scanf("%d",&num);

 
while(i<=num){

      k=0;

      if(

TO FIND MULTIPLICATION TABLE USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








1. Multiplication
tables in c program

2. Write a
c program to print multiplication table

3.

TO FIND FACTORIAL OF A NUMBER USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








Code 1:

1. C code for factorial
of a number

2. C program to find the
factorial of a given

TO FIND FIBONACCI SERIES USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








Code 1:

1. Write a program to generate the Fibonacci series in c

2. Write a program to
print

PRINTING ASCII VALUE USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








Printing
ascii value using c program


C code for
ASCII table


C program to display ASCII

CHECKING LEAP YEAR USING C PROGRAM


Definition of
leap year:



Rule 1: A year is called leap year if it is divisible by 400.

For example: 1600, 2000 etc leap year while 1500, 1700 are not leap year.

Rule 2: If year is not divisible by 400 as
well as 100 but it is divisible by 4 then that year are also leap year.

For example: 
2004, 2008, 1012 are leap year.



Leap year
logic or Algorithm of leap year or Condition for leap

CONVERSION OF DECIMAL TO BINARY USING C PROGRAM











.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px

CONVERSION FROM UPPERCASE TO LOWER CASE USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}








Conversion
from uppercase to lower case using c program



#include
#include

int main(){

 
char str[20];

 
int i;

 
printf("Enter any string->");

 
scanf("%s

DELETE THE VOWELS FROM A STRING USING C PROGRAM

#include
int main(){    char str[20],s[20];    int i,j=0;    printf("Enter any string->");    scanf("%s",str);    printf("The string is->%s",str);   for(i=0;i<=strlen(str);i++) {  
        if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')
                str[i]=' ';
        else 
                s[j++]=str[i];
    } 
    s[j]='\0';
    printf("\nThe string without vowel

ADDITION OF TWO MATRICES USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








C program for addition of two
matrices using arrays source code. Matrix addition in c language:

COPY DATA FROM ONE FILE TO ANOTHER FILE USING C PROGRAM












.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px

FIND SUM OF THE SERIES 1+2+3+---------+n USING C PROGRAM

void main()
{
int r;
clrscr();
printf("\nEnter the number range: ");
scanf("%d",&r);
printf("\nSum of the series is: %d",(r*(r+1))/2);
getch();
}

ADDITION & SUBTRACTION OF TWO COMPLEX NUMBERS USING C PROGRAM


C code:
1. Adding two complex numbers in c

2. C program for addition of two complex numbers
3. C program to add two complex numbers

#include

int main(){

 
int a,b,c,d,x,y;

 
printf("\nEnter the first complex number:");

 
scanf("%d%d",&a,&b);

 
printf("\nEnter the second complex number:");

 
scanf("%d%d",&c,&d);

 
if(b<0)

      printf("%d-i\n",a-b);

 
else

      printf("d+i\n

FIND OUT LARGEST NUMBER IN AN ARRAY USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








C program to find the largest element in an array



#include

int main(){

 
int a[50

FIND OUT SECOND LARGEST NUMBER IN AN UNSORTED ARRAY USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}









C program to find the second largest element in an array



#include



int main(){

MULTIPLICATION OF TWO MATRICES USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}










1. C code for
matrix multiplication




2. C program for
matrix multiplication


3. Write a

FIND OUT SUM OF DIAGONAL ELEMENTS OF A MATRIX USING


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}











Sum of diagonal elements of a matrix in c





#include




int main(){



 
int a[

Find out the perfect number using c program


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}










Code 1:

1. C program to check perfect number



#include

int main(){

 
int n,i=1,

COUNTING DIFFERENT CHARACTERS IN A STRING USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}












#include

int isvowel(char chk);

int main(){

 
char text[1000], chk;

 
int

SORTING OF STRING USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}










Program
for sorting of string in c language




#include

int main(){

 
int i,j,n;

SELECTION SORT USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}








Source code of simple Selection sort implementation
using array ascending order in c

Program of insertion sort in c language


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}








#include

int main(){

 
int i,j,s,temp,a[20];

 
clrscr();

 
printf("\nEnter size of the array: ");

 
scanf("%d",&s);

 
printf("\nEnter %d elements in to the array:",s)

INSERTION SORT USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}








#include

int main(){

 
int i,j,s,temp,a[20];

 
clrscr();

 
printf("\nEnter size of the array: ");

 
scanf("%d",&s);

 
printf("\nEnter %d elements in to the array:",s)

DISPLAY SOURCE CODE AS OUTPUT IN C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}








#include

int main(){

    FILE
*p;

    char ch;

    p=fopen("raja.c","r");

    while((ch=getc(p))!=-1)

         putchar(ch);

    fclose(p);

    return 0;

}








FIND FACTORIAL OF A NUMBER USING RECURSION IN C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}










1. Factorial
program by recursion in c




2. Factorial
program in c using recursion



3. C
program to calculate factorial using recursion



4. Recursive
function for factorial

FIND GCD OF A NUMBER USING RECURSION IN C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}








Find gcd of a number using recursion in c program




#include

int main(){

 
int n1,n2,gcd;

 
printf("\nEnter two numbers: ");

 
scanf("%d %d",&n1,&n2);

 
gcd=findgcd(

FIND SUM OF DIGITS OF A NUMBER USING RECURSION USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}










Sum of digits in c using recursion







#include

int main(){

 
int num,x;

 
clrscr();

 
printf("\nEnter a number: ");

 
scanf("%d",&num);

 
x=findsum(num);

 

FIND POWER OF A NUMBER USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}










How to
calculate power of a number in c




How to
write power in c





#include

FIND POWER OF A NUMBER USING RECURSION USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}








Find
power of a number using recursion using c program



#include

int main(){

 
int pow,num;

 
long int res;

 
long int power(int,int);

 
printf("\nEnter a number: ")

CONCATENATION OF TWO STRINGS USING POINTER IN C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}










Concatenation
of two strings using pointer in
c programming language




#include

int main(){

 
int i=0,j=0;

 
char *str1,*str2,*str3;

 
puts("Enter first string");

CONCATENATION OF TWO STRINGS USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}
.explanation{
color:#800000;
font-size:25px;
font-weight:900;
letter-spacing:15
}










Concatenation
of two strings in c
programming language




#include

int main(){

 

ACHROMATIC STRING(PRINTING INITIALS)


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}









Achromatic string (printing initials)

C program to print initials of any name 




#include

int main(){

  
char str[20];

  
int i=0;

  
puts("Enter a string");

  

LINEAR SEARCH USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}









1. Write a simple code for linear
search in c programming language

2. Wap a c program to search an
element in an array using linear search



#include

int main(){



BINARY SEARCH USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}









1. Write a simple code for binary
search in c programming language

2. Wap a c program to search an
element in an array using binary search



#include

int main(){



C program for binary search using recursion


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}










Write a simple code for
binary search using function recursion in c programming language




#include

int main(){



    int a[10],i,n,m,c,l,u;



    printf("Enter
the

REMOVE DUPLICATE ELEMENTS IN AN ARRAY USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}









#include

int main(){

 
int arr[50];

 
int *p;

 
int i,j,k,size,n;

 
printf("\nEnter size of the array: ");

 
scanf("%d",&n);

 
printf("\nEnter %d elements into the

CONVERSION FROM DECIMAL TO OCTAL USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}











C code for decimal to octal converter








#include





int main(){





  long int decimalNumber,remainder,quotient;



  int octalNumber[100],i=1,j;





  printf(

QUICK SORT USING C PROGRAM


.fieldsetOut{
background:#1E90FF;
padding:0px 0px 0px 0px;
font-family: "courier new"
}
.fieldsetIn{
background:white;
margin:1px 1px 1px 1px;
padding:1px 1px 1px 1px;
border: 0px 0px 0px 0px

}










Source code of simple quick sort implementation
using array ascending order in c programming language




#include



void quicksort(int [10],int,int);



int main(){

 

DELETE ELEMENT FROM AN ARRAY AT DESIRED POSITION USING C PROGRAM





#include

int main(){

int
a[50],i,pos,size;

printf("\nEnter
size of the array: ");

scanf("%d",&size);

printf("\nEnter
%d elements in to the array: ",size);

for(i=0;i
scanf("%d",&a[i]);

printf("\nEnter
position where to delete: ");

scanf("%d",&pos);

i=0;

while(i!=pos-1)

i++;

while(i<10){

a[i]=a[i+1];

i++;

}

size--;

for(i=0;i
printf(" %d",a[i]);

FIND GREATEST AMONG 3 NUMBERS USING CONDITIONAL OPERATOR IN C PROGRAM














Find the greatest number in given
three numbers



#include

int main(){

int a,b,c,big;

printf("\nEnter
3 numbers:");

Find g.c.d of two number using c program



Definition
of HCF (Highest
common factor):



HFC is also called greatest
common divisor (gcd).
HCF of two numbers is a largest positive numbers which can divide both numbers
without any remainder.  For example HCF
of two numbers 4 and 8 is 2 since 2 is the largest positive number which can
dived 4 as well as 8 without a remainder. 



Logic
of HCF or GCD of any two numbers:



In HCF we try

Find sum of the digit of number using c program




C program to calculate or find sum
of each digits of a given number





#include


int main(){

int num,sum=0,r;

printf("\nEnter
a number:");

scanf("%d",&num);

while(num){

r=num%10;

num=num/10;

sum=sum+r;

}

printf("sum=%d",sum);

return 0;

}



If
you have any queries in above code find
sum of the digit of number using c program, please share us.

Reverse any number using c program







Code 1:

1. Write a c program to reverse a given number

2. C program to find reverse of a number


3. C program to reverse the digits of a number
4. Reverse of a number in c using while loop



#include

int main(){

    int num,r,reverse=0;



    printf("Enter any number: ");

    scanf("%d",&num);



    while(num){

         r=num%10;

         reverse=reverse*10+r;

        

Tuesday 1 January 2008

sql,pl/sql questions with solutions and explanations

C QUESTIONS WITH SOLUTIONS
C QUESTIONS WITH SOLUTIONS

JAVA QUESTIONS WITH SOLUTIONS
JAVA QUESTIONS WITH SOLUTIONS

SQL QUESTIONS WITH SOLUTIONS
SQL QUESTIONS WITH SOLUTIONS

PL/SQL QUESTIONS WITH SOLUTIONS
PL/SQL QUESTIONS WITH SOLUTIONS

Write an assembly language program in c program to find out factorial of given number?

Answer:
void main(){ int num; clrscr(); scanf("%d",&num); asm mov ax,1; asm mov bx,1; asm mov cx,num; come: asm mul bx; asm inc bx; asm dec cx; asm jnz come; printf("%d ",_AX); getch(); }More question

asm keyword in c programming language



asm keyword in c programming language



Keyword asm is used to write
assembly language code in c programming.



(1) What will be output of
following c program?



#include

int main(){



asm{

         mov ax,10;

         shl,2;

    }



printf("%d",_AX);

return 0;

}



Output: 40

Explanation: ax and bx is general
purpose register. Statement mov ax, 61 means value 61 is storing

Assembly language program in c programming language

Assembly language program in c programming language. (1) What will be output of following c program? void main() { clrscr(); asm{       mov ax,61;       mov bx,10;       add bx,ax;     }   printf("\n%d",_BX); getch(); } Output: 71 Explanation: ax and bx is general purpose register. Statement  mov ax,61 means value 61 is storing at register ax. Statement add bx,ax meand addition