Saturday 19 June 2010

Write a c program to find out second smallest element of an unsorted array


.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
smallest element in an array






#include

int main()

Write a c program to find out the size and drive where file has stored of any given file?

#include "time.h"

#include "sys\stat.h"

#include "stdio.h"

int main(){

    struct stat status;

    FILE *fp;

    fp=fopen("test.txt","r");

    fstat(fileno(fp),&status);



    printf("Size of file : %d",status.st_size);

    printf("Drive name   : %c",65+status.st_dev);

    return 0;

}



Explanation:


Function int fstat (char *, struct stat *) store the information of open file in

Write a c program to know the last date of modification of any file


#include "time.h"

#include "sys\stat.h"

#include "stdio.h"

int main(){

    struct stat status;

    FILE *fp;

    fp=fopen("test.txt","r");

    fstat(fileno(fp),&status);

    

    printf("Last date of modification : %s",ctime(&status.st_ctime));

    return 0;

}


Explanation:


Function int fstat(char *, struct stat *) store the  information of open file in form of  structure struct

Write a c program to find out transport of a matrix


.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 transpose of a matrix
C program to find transpose of given matrix



#include<

Write a c program to print the string from given character


.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

#include

int main(){

 
char *p;

 
char s[20],s1[1];

 

Write a c program which prints initial of any name


.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 code which prints initial of any name


#include

int main(){

  
char str[20];

  

Write a c program to convert the string from lower case to upper case


.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
}









Write
a c program to convert the string from lower case to upper case




#include

Write a c program to convert binary number to decimal number


.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 code for binary to decimal conversion:








#include





int main(){



   


Write a c program for swapping of two arrays


.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
}








Write a c
program for swapping of two arrays




#include

int main(){

  int a[10],b

Write a c program to find out L.C.M. of two numbers.


.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
}








LCM program in c with two numbers : 



#include

int main(){

 
int n1,n2,x,y;

 

Write a c program to find out NCR factor of given number


.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
}





Write
a c program to find out NCR factor of given number Or
C program to find the ncr value by

Write a c program to print Pascal triangle.


.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. Pascal
triangle in c without using array




2. C code
to print Pascal triangle



3.

Write a c program for Floyd’s triangle.


.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. Write a
c program to print Floyd’s triangle




2. C
program to display Floyd’s triangle

Friday 18 June 2010

Write a c program which passes two dimension array to function


.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 pass two dimensional array to a function in c




#include

#define M 3

#

Write a c program to find largest among three numbers using conditional operator


.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
}









Write
a c program to find largest among three numbers using conditional operator




#include<

Write a c program to find largest among three numbers using binary minus operator


.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 main(){

    int a,b,c;

    printf("\nEnter
3 numbers: ");

   

Write a c program to check given string is palindrome number or not


.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

#include

int main(){

 
char *str,*rev;

 
int i,j;

 
printf("\

Write a c program to find out sum of digit of given number


.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 add digits of a number

2. C
program for sum of digits of a
number

3.

Write a c program to check given number is strong number or not.


.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 c program to check whether a
number is strong or not



#include

Saturday 12 June 2010

Array questions with explanation in c











C programming technical questions and answers with
explanation



Technical c
interview questions



1.

What will be output when you will execute following c code?

#include

void main(){

     int check=2;

     switch(check){

        case 1: printf("D.W.Steyn");

        case 2: printf("

Monday 7 June 2010

How to read a text file 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

How to pass one dimensional array to function in c









.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

Sunday 6 June 2010

INSERT AN ELMENT IN AN ARRAY AT DESIRED POSITION USING C PROGRAM




How
to insert or add an element in the array at specific or desired posting by
using c programming language? Source code is as follow:



#include

int main(){

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

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

scanf("%d",&size);

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

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

printf("\nEnter position and number to insert: ");

FIND OUT GENERIC ROOT OF A NUMBER By C PROGRAM




C program for generic root



#include

int main(){



long int num,sum,r;

printf("\nEnter
a number:-");

scanf("%ld",&num);



while(num>10){

sum=0;

while(num){

r=num%10;

num=num/10;

sum+=r;

}

if(sum>10)

num=sum;

else

break;

}

printf("\nSum of
the digits in single digit is: %ld",sum);

return 0;

}





C code for calculation of generic root in one line



#include <

Check the given number is armstrong number or not using c program




Code 1:

1. Warp
to check a number is Armstrong

2. C program to check whether a number is Armstrong or not

3. Simple
c program for Armstrong number

4. Armstrong
number in c with output



#include

int main(){

    int num,r,sum=0,temp;



    printf("Enter a
number: ");

    scanf("%d",&num);



    temp=num;

    while(num!=0){

         r=num%10;

         num=num/10;

        

C questions