29 : C Program to Convert Kb to Mb

Check out the complete list of c-programs : C Program List    



This program coverts entered Kilobyte value to Megabyte.

Variables :

1. kb : (Datatype long) : to hold measurement in kb entered by the user. Its maked unsigned as Kb is non-negative number

2. mb : (Datatype long) : to hold mb value computed. As Mb is non-negative value its marked unsigned





Functions :

printf() : is used to display something on the console/screen. Format specifier %lu in printf function is used to display a unsigned long variable on screen. \n is used to add a newline

scanf() : is used to fetch data inputted by the user on the console/screen using keyboard. %lu in scanf is indicates that inputted text is of type unsigned long.







Formula :

mb = kb/1024

/*
 * 1000+ C programs + tutorials
 *
 * 
 * 29_kb_to_mb_converter.c
 *
 *
 *  Created on: Oct 20, 2014
 *  Author: Code2care.org
 */

#include 
//#include 

void main() {

  unsigned long kb;
  unsigned long mb;
  

//    clrscr();

	printf(" Program to convert Kilobyte to Megabyte :  ");

	printf("\n\n Enter Length in Kilobyte  : ");
	scanf("%lu", &kb);
    
    mb = (kb/1024);
    
    printf("\n\n %lu Kb  =  %lu Mb  \n",kb,mb);



//	getch();


}









The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.