Tuesday, 16 June 2015

C program to check leap year.

WAP to check whether the year entered by the user is leap year or not.
Program:
#include<stdio.h>
#include<conio.h>
int main()
{
    int year;    //Declaring Variable.
   
    printf("Enter any year: ");  //For printing
    scanf("%d",&year);  //For Input.

    if(((year%4==0)&&(year%100!=0))||(year%400==0))  //If Statement
         printf("%d is a leap year",year);  //For printing
    else
         printf("%d is not a leap year",year);  //For printing
    getch(); //Getting a character or waiting for key press
 return 0;
}

Output:

Video Explanation
Sorry Guys Explanation of this tutorial will be posted later this month.



C program to find a number is even or odd.

To find that given number is even or odd.

Program:

#include <stdio.h>
#include <conio.h>
int main()
 {
      int num;   //Declaring Variable.
   
   printf("Enter an integer you want to check: ");//For printing
      scanf("%d",&num);
     
      if((num%2)==0)      /* Checking whether remainder is 0 or not. */
        printf("%d is even.",num);   //For printing
      else
     printf("%d is odd.",num);   //For printing
      
  getch();   //Getting a chracter or waiting for key press.
  return 0;
}
Output:



Video Explanation
Sorry Guys Explanation of this tutorial will be posted later this month.

C program to check number is prime or not.

WAP to check whether number is prime or not.
Program:
#include<stdio.h>                   
#include<conio.h>

int main()
{
       int n,i,a=0;  //Declaring Variable.
      
       printf(" enter the number : "); //For printing
       scanf("%d",&n);   //For Input.
        for(i=2; i<n/2; i++)  //For Loop.
        {
                if(n%i==0)
                {
                    a=1;
                    break;
                }
        }
    if(a==0)
       printf("%d is a prime number.",n); //For printing
    else
       printf("%d is not a prime number.",n);  //For printing
   getch();  //Getting a chracter or waiting for key press.
  return 0;
}

Output:

Video Explanation
Sorry Guys Explanation of this tutorial will be posted later this month.

Monday, 15 June 2015

C program using sizeof() operator

WAP to display the size of integer,float and char using sizeof() operator
    Program:
#include<stdio.h>
#include<conio.h>


int main()
{
int x;    //Declaring Variable.

float y;   //Declaring Variable.
double z;   //Declaring Variable.
char ch;    //Declaring Variable.



printf("Size of integer variable x:%d\n",sizeof(x));  //For printing
printf("Size of float variable y:%d\n",sizeof(y));  //For printing
printf("Size of double variable z:%d\n",sizeof(z));   //For printing
printf("Size of character variable char:%d\n",sizeof(char));   //For printing


getch();   //Getting a chracter or waiting for key press.
return 0;




Output:


Video Explanation
Sorry Guys Explanation of this tutorial will be posted later this month.

C program for Calculating Simple interest

WAP that will take principal,rate and time as input and display   the simple interest.
   Program:

#include <stdio.h>
#include <conio.h>
int main()
{
   float p, r, si;  //Declaring Variable.
   int t;  
//Declaring Variable.


   printf("Enter the values of p,r and t\n");   //For printing
   scanf ("%f %f %d", &p, &r, &t);  
 //For Input.
     si = (p * r * t)/ 100.0;  //Calculation
   
   printf ("Rate   = Rs. %5.2f%\n", r); //For printing
   printf ("Time   = %d years\n", t);  //For printing
   printf ("Simple interest  = %5.2f\n", si); 
//For printing

     getch();   //Getting a chracter or waiting for key press.
  return 0;
}
Output:
Video Explanation
Sorry Guys Explanation of this tutorial will be posted later this month.


Finding quotient and remainder.

WAP that will take dividend and divisor and display the quotient and remainder.


#include <stdio.h>

#include<conio.h>

int  main()

{

   int dividend,divisor,remainder;  //Declaring Variable.

   float quotient;   //Declaring Variable.

   printf("enter any dividend and divisor \n");   //Printing Message on Screen

   scanf(“%d%d”,&dividend,&divisor);     //For Input.



   quotient=dividend/divisor;  //Calculation

   remainder=dividend%divisor;

   printf(“\n The quotient is %f and remainder is %d” ,quotient,remainder); //Printing 
   getch();  //Getting a chracter or waiting for key press.
   return 0;
}


Video Explanation

Sorry Guys Explanation of this tutorial will be posted later this month.

Friday, 12 June 2015

Printing in C

To print message on the screen.
  
 #include <stdio.h>
 #include <conio.h>

 void main() 
 {  clrscr();  //For Clearing the Screen.
     printf("Hello world\n")//For printing
     getch();  //Getting a chracter or waiting for key press.
 }



Video Explanation
Sorry Guys Explanation of this tutorial will be posted later this month.