Wednesday, August 31, 2011

C program to get last two digits of year


.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 extract last two digits of a given year
and print it



#include

int

Split number into digits in c programming


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







Extract digits from integer in c language



#include

int main(){

int num,temp,

C program to count number of digits in a 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:

Count
the number of digits in c programming language



#include

int main(){

Monday, August 29, 2011

Find out Factioral value


Ans.

#include<stdio.h>
#include<conio.h>
void main()
{
 int fact=1,num;
 clrscr();
 printf("\nEnter Number : ");
 scanf("%d",&num);
 while(num>=1)
 {
  fact=fact*num;
  num--;
 }
 printf("\nFactorial value of %d is %d",num,fact);
}

       Output of above program : 
Enter Number : 5
Factorial value of 5 is 120
 

operation's number(sum,reverse,store in other variable)

Q. Write a program to insert a number and do following tasks:
 a.Display in reverse order?
 b.Reverse in another variable and display it?
 c.Display sum of its all digit?

Ans.

#include<stdio.h>
#include<conio.h>
void main()
{
 int x,num,rem,sum=0,var=0;
 clrscr();
 printf("\nPress Number 1 for reverse number");
 printf("\nPress Number 2 for reverse number in another variable");
 printf("\nPress Number 3 for sum of entered number");
 scanf("%d",&x);
 switch(x)
 {
 case 1 :
  printf("\nEnter Number : ");
  scanf("%d",&num);
  while(num>=1)
  {
   rem=num%10;
   printf("Reverse number : %d",rem);
   num=num/10;
  }
  break;
 case 2 :
  printf("Enter Number : ");
  scanf("%d",&num);
  while(n>=1)
  {
   rem=n%10;
   var=var*10+rem;
   n=n/10;
  }
  printf("%d",var);
  break;
 case 3 :
  printf("\nEnter Number : ");
  scanf("%d",&num);
  while(num>=1)
  {
   rem=num%10;
   sum=sum+rem;
   num=num/10;
  }
  printf("Sum of %d is %d",num,sum);
  break;
 default :
   printf("You enter wrong number!!!");
   break;
 }
}

       Output of above program : 

Press Number 1 for reverse number
Press Number 2 for reverse number in another variable
Press Number 3 for sum of entered number

1
Enter Number : 4812
Reverse number : 2184
 

Print table in following format

Q. Write a program to printout following table:
 (where num=5)
       
         5*1=5
         5*2=10
         5*3=15
         5*4=20
         5*5=25
         5*6=30
         5*7=35
         5*8=40
         5*9=45
         5*10=50

Ans.
 
#include<stdio.h>
#include<conio.h>
int main()
{
 int x=1,num,res;
 printf("Enter Number : ");
 scanf("%d",&num);
 while(x<=10)
 {
   res=num*x;
   printf("\n%d*%d=%d",num,x,res);
   x++;
 }
 getch();
 return 0;
}

       Output of above program : 
Enter Number : 5

         5*1=5
         5*2=10
         5*3=15
         5*4=20
         5*5=25
         5*6=30
         5*7=35
         5*8=40
         5*9=45
         5*10=50

Sunday, August 28, 2011

Print one to ten using for loop

Q. Write a program to printout one to ten counting using for loop?

Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
  int x;
  for(x=1; x<=10; x++)
    printf("\n%d",x);
  getch();
  return 0;
}

     Output of above program : 
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10

Print one to ten program

Q. Write a program to printout one to ten counting using while loop?
Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 int x=1;
 while(x<=10)
 {
   printf("\n%d",x);
   x++;
 }
 getch();
 return 0;
}

       output of above program : 

  1
  2
  3
  4
  5
  6
  7
  8
  9
  10

comparison of three numbers

Q. Write a program to compare three numbers which is greatest,middle and lowest?

Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 int x,y,z;
 printf("Enter values of x, y and z : ");
 scnaf("%d%d%d",&x,&y,&z);
 if(x>=y && x>=z)
   printf("\nx=%d is greatest",a);
 else if(y>=z)
   printf("\ny=%d is greatest",y);
 else
   printf("\nz=%d is greatest",z);
 getch();
 return 0;
}

      Output of above program :
Enter values of x,y and z : 30
20
100

z=100 is greatest

C program without main function






Can
you write a c program without using main function?





We can write a c program without
using main function. We can compile it but we cannot execute a program without
a main function. Since in C execution of any program start from main function. Examples of c program without a main is all
the c library functions. Function printf
is an example of library function which has been written

find greatest number using conditional operator

Q. Using conditional operators write a program to find out in three Numbers which is greatest number?
Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 int n1,n2,n3;
 prinft("Enter Numbers n1, n2, n3 : ");
 scanf("%d"%d%d",n1,n2,n3);
 printf("Greatest=%d",n1>n2?n1>n3?x:z:y>z?y:z);
 getch();
 return 0;
}


       Output of above program : 
Enter Numbers n1, n2, n3 :10
20
30

Greatest=30

Simple Swapping C Program

Q. Write a simple program to insert two values through keyboard and interchange then values?
Example:if x=10
           y=20
        then after interchange
          x=20
          y=10
       
Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 int x,y,z;
 printf("Enter Values x and y : ");
 scnaf("%d%d",&x,&y);
 z=y;
 y=x;
 x=z;
 printf("\nValue of x=%d",x);
 printf("\nValue of y=%d",y);
 getch();
 return 0;
}

        Output of above program : 
Enter Values x and y : 25
35
Value of x= 35
Value of y= 25

Add two numbers

Q. Write a program to add two numbers?

Ans.

#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,sum;
 clrscr();
 printf("Enter Numbers a and b : ");
 scnaf("%d%d",&a,&b);
 sum=a+b;
 printf("\nsum(a+b)=%d",sum);
 getch();
}

     Output of above program : 

Enter Numbers a and b : 100
200

sum(a+b)=300

Sample C Program

Q. Write a simple C program,in which user entered his name,age through keyboard and display on console?

Ans.

/*c program to accept name & age from user and display it*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char nam[20];
 int age;
 printf("Enter Your Name : ");
 scnaf("%s",&nam); // gets(nam)
 printf("Enter Your Age : ");
 scanf("%d",&age);
 printf("\nUser Name is %s",nam); 
 /*You also use puts(nam)*/
 printf("\nAnd %s age is %d",nam,age);
 getch();
 return 0;
}

       Output of above program : 

Enter your name : JamesBond
Enter your age : 35

And JamesBond age is 35


c faqs with answers pdf



This PDF doc keeps faq or frequently asked questions and answers of c programming language. To free download the pdf doc go to the File -> Download Original

C in depth pdf




This PDF doc keeps c programming questions and answer with explanation in depth. To free download the pdf doc go to the File -> Download Original

C language questions and answers pdf


C Programming language questions and answers in PDF format free to download

This PDF doc keeps C language questions and answers with explanation. To free download the pdf doc go to the File -> Download Original

C language questions and answers with explanation

C multiple choice questions and answers pdf



C
programming language multiple choice questions and answers in pdf format for
interview free download






This PDF doc keeps mcq or multiple choice questions and answers with explanation of c programming language. To free download the pdf doc go to the File -> Download Original

C objective questions and answers pdf




Objective
c tutorial for beginners to learn objective type questions with answers in c
programming language in pdf format. C objective
questions and answers pdf Download free





This PDF doc keeps objective questions and answers with explanation of c programming language. To free download the pdf doc go to the File -> Download Original

c test questions and answers pdf



Online
written test questions and answers in c programming language in pdf form free
to download



This PDF doc keeps sample test questions and answers of c programming language. To free download this pdf doc go to File -> download Original

Test your C skills pdf


Test your C programming language skills for written test exam and interview pdf free download





This PDF documents keeps tricky questions and answers to test your c skills. To free download the pdf doc go to the File -> Download Original

Monday, August 15, 2011

Example of recursion in c programming



C
programs on recursion. Collections
of function recursion programs source code examples in c programming language
frequently asked in interview


Sum of n numbers using recursion in c

Matrix multiplication using recursion in c

Multiplication using recursion in c

Lcm using recursion in c

Using recursion in c find the largest element in an array

Prime number program in c using recursion

Saturday, August 13, 2011

Sum of n numbers using recursion 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;
border: 0px 0px 0px 0px

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












C
code to find the addition of n numbers by recursion:







#include



int main

Matrix multiplication using recursion 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;
border: 0px 0px 0px 0px

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








C
code to multiply two matrix by recursion:



#include

#define MAX 10



void

Multiplication using recursion 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;
border: 0px 0px 0px 0px

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








C
code to multiply two numbers by recursion:



#include



int multiply(int,int);



LCM using recursion 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;
border: 0px 0px 0px 0px

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








C
code to get LCM of two numbers by recursion:



#include



int lcm(int,int);



int

Using recursion in c find the largest element in an 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
code to get largest element of an array by recursion:




#include

#define MAX 100

Prime number program in c 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

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








C
code to check a number is prime number or not by recursion:



#include



int

Decimal to binary conversion in c 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

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








C
code to convert decimal number to binary number by recursion:



#include



long

C program for Fibonacci series 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

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




1. C
code to print Fibonacci series by recursion


2. Fibonacci
series in c by using recursion




Reverse a string using recursion 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;
border: 0px 0px 0px 0px

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







C code to reverse a string by recursion:



#include

#define MAX 100

char*

Tuesday, August 2, 2011

C program to convert currency into words


.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 to convert any number
to English word:



#include

#include



void

C program for unit conversion


.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 to convert one unit
to other unit:



#include

#include



int main(){

C program to convert digits to words


.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 to covert each digits of a number in English word






Convert
digits to words in c


C program for odd or even 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 check even or odd

2. C determine odd or even

3. How to check odd

C program to convert Roman 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 roman numbers to English
numbers



#include

#include



int

C program to convert decimal to roman 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
}








Convert
numbers to roman numerals in c


#include



void predigits(char c1,char c2);