c fundamental programs

      2 Comments on c fundamental programs

c fundamental programs

c fundamental programs

c fundamental programs collection prepared by Adarsh Patel. This all C Language fundamental programs can be useful to build your logic. C is the only language which you can use to develop logic. All following c fundamental programs programs I have developed which I was doing MCA, Purpose of sharing this program is to built logic only. All C Language programs are tested using Turbo C++ Compiler so it may not work with other compilers.

C Language Program  1

// Written by Adarsh Patel      
// HelloWorld Program using C

#include 
#include 
void main()
{
	clrscr();

	printf("Adarsh Patel\n");
	printf("Indian Blogger");

	getch();
}

 

C Language Program  2

//Written by Adarsh Patel    
//C Program to demonstrate use of basic math operators  

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int a, b;


	printf("Enter No 1 :");
	scanf("%d",&a);

	printf("Enter No 2 :");
	scanf("%d",&b);

	printf("\n+ \tis :%d\n",a+b);
	printf("- \tis :%d\n",a-b);
	printf("* \tis :%d\n",a*b);
	printf("/ \tis :%d\n",a/b);

	getch();
}

 

C Language Program  3

//Written by Adarsh Patel      
//C Program to demonstrate use of some more complex math operation     

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float x,y,answer;

	printf("Enter Value of X :");
	scanf("%f",&x);

	printf("Enter Value of Y :");
	scanf("%f",&y);

	// A
	answer=(x+y)/(x-y);

	printf("\n\n A: (x+y)/(x-y)");
	printf("\n Answer is : %.2f",answer);

	// B
	answer=(x+y)/2.0;

	printf("\n\n B: (x+y)/2");
	printf("\n Answer is : %.2f",answer);

	//C
	answer=(x+y)*(x-y);

	printf("\n\n c:  (x+y)*(x-y)");
	printf("\n Answer is : %.2f",answer);

	getch();
}

 

C Language Program  4

//Written by Adarsh Patel      
//C Program to generate result of student     

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float m1,m2,m3,m4,m5,m6,m7,result,total,percentage;

	printf("Enter Marks of All Subject (7 Subject) :\n");
	scanf("%f %f %f %f %f %f %f",&m1,&m2,&m3,&m4,&m5,&m6,&m7);

	total=m1+m2+m3+m4+m5+m6+m7;
	percentage=total/7.0;

	if(m1>=36 && m2>=36 && m3>=36 && m4>=36 && m5>=36 && m6>=36 && m7>=36)
	{
		printf("\nTotal   \t : %.2f",total);
		printf("\nResult\t\t : Pass");
		printf("\nPercentage \t : %.2f",percentage);
	}
	else
		printf("\nResult\t : Fail");

	getch();
}

 

C Language Program  5

//Written by Adarsh Patel      
//C program to calculate Age based on Current year and birth year      

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();

	int dob,cy;

	printf("Enter Year of Birth (ex.1985) :");
	scanf("%d",&dob);

	printf("Enter Current Year            :");
	scanf("%d",&cy);

	printf("\n Your age is : %d",cy-dob);

	getch();
}

 

C Language Program  6

//Written by Adarsh Patel      
//c program for distance conversion     

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float km1,km2;

	printf("Enter KM 1:");
	scanf("%f",&km1);

	printf("Enter KM 2:");
	scanf("%f",&km2);

	printf("\nDifference in KM is         :%.2f",km2-km1);
	printf("\nDifference in Meter is      :%.2f",(km2-km1)*1000);
	printf("\nDifference in Feet is       :%.2f",(((km2-km1)*1000)/3.0));
	printf("\nDifference in Inch is       :%.2f",((((km2-km1)*1000)/3.0)/12));
	printf("\nDifference in Centimeter is :%.2f",(((km2-km1)*1000)/12.0));

	getch();
}

 

C Language Program  7

//Written by Adarsh Patel      
//C program for Simple Interest Calculator      

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int n;
	float p,r,si;

	printf("\nEnter Principal        :");
	scanf("%f",&p);

	printf("\nEnter Rate of Interest :");
	scanf("%f",&r);

	printf("\nEnter Number of Years  :");
	scanf("%d",&n);

	si=p*r*n/100.0;
	printf("============================");
	printf("\n\nSimple Interest is : %.2f",si);

	getch();
}

 

 

C Language Program  8

//Written by Adarsh Patel      
//c program to swap two numbers

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int a,b,c;

	printf("Enter Value of A :");
	scanf("%d",&a);
	printf("Enter Value of B :");
	scanf("%d",&b);

	c=a;
	a=b;
	b=c;

	printf("\nValue of A : %d",a);
	printf("\nValue of B : %d",b);

	getch();
}

 

C Language Program  9

//Written by Adarsh Patel      /
//Downloaded from http://adarshspatel.in/      
//c program to swap two numbers without using third variable
#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int a,b;

	printf("Enter Value of A :");
	scanf("%d",&a);
	printf("Enter Value of B :");
	scanf("%d",&b);

	b=a+b;
	a=b-a;
	b=b-a;

	printf("\nValue of A : %d",a);
	printf("\nValue of B : %d",b);

	getch();
}

 

C Language Program  10

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/      
//Find Square and Qube using C Language

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int a;

	printf("Enter Value :");
	scanf("%d",&a);

	printf("\nSquare is : %d",a*a);
	printf("\nQube is   : %d",a*a*a);

	getch();
}

 

C Language Program  11

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/      
// Decimal to Hexa
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
	clrscr();
	int temp,i=0,j;
	int oct[10];
	float digit,no;

	printf("Enter Decimal Number : ");
	scanf("%f",&no);

	temp=abs(no);

	while(temp>0)
	{
		oct[i]=temp%8;
		i++;
		temp=temp/8;
	}

	i--;

	for(j=i;j>=0;j--)
	{
			printf("%d",oct[j]);

	}


	no=no-abs(no);

	if(no>0)
	{
		printf(".");

		for(j=1;j<=4;j++)
		{
			digit=no*8;
			printf("%d",abs(digit));
			no=no-abs(digit);
		}
	}

	getch();
}

 

C Language Program  12

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/      
//C Program to find reminder

#include <stdio.h>
#include <conio.h>

void main()
{
	clrscr();
	long int userval,ans;

	printf("\t\tFind the reminder divide by 3");

	printf("\n\nEnter 6 Digit Number :");
	scanf("%ld",&userval);

	ans=userval%3;

	printf("\nReminder is : %ld",ans);

	getch();
}

 

C Language Program  13

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/      
//Convert float ruppees and paisa to different variables.
#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float val,paise;
	int rupees;

	printf("\nEnter Floting Point Value(Rupees & Paise) :");
	scanf("%f",&val);
	rupees=val;
	paise=(val-rupees)*100.0;

	printf("\n %d Rupees and %.0f Paise",rupees,paise);

	getch();
}

 

C Language Program  14

//Written by Adarsh Patel


#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float at,g,t,answer;

	printf("Enter Value of AT:");
	scanf("%f",&at);

	printf("Enter Value of G :");
	scanf("%f",&g);

	printf("Enter Value of T :");
	scanf("%f",&t);

	// A
	answer=(at+at)*(at+at);

	printf("\n\n A: at+at^2");
	printf("\n Answer is : %.2f",answer);

	// B
	answer=g*t;

	printf("\n\n B: G * T");
	printf("\n Answer is : %.2f",answer);

	//C
	answer=((g*t)*(g*t))/2.0;

	printf("\n\n c:  (g*t^2)/2");
	printf("\n Answer is : %.2f",answer);

	getch();
}

 

C Language Program  15

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/      
//Calculate net salary using C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	float basic_salary,da,hra,medical,deduction,insurance,pf,gross,net_s;

	printf("Enter Basic Salary :");
	scanf("%f",&basic_salary);

	da=0.45*basic_salary;
	hra=0.15*basic_salary;
	medical=0.05*basic_salary;
	gross=basic_salary+da+hra+medical;
	pf=0.04*gross;
	insurance=0.06*gross;
	deduction=insurance+pf;
	net_s=gross-deduction;

	printf("=================================");
	printf("\nNet Salary is      :%.2f",net_s);

getch();
}

 

Download All c fundamental programs

[sociallocker]Download[/sociallocker]

 

2 thoughts on “c fundamental programs

  1. Pingback: c if programs

  2. Pingback: c string programs

Comments are closed.