C PROGRAMS CONVERT TEMPERATURE FROM DEGREE CELSIUS TO DEGREE FAHRENHEIT

C PROGRAMS CONVERT TEMPERATURE FROM DEGREE CELSIUS TO DEGREE FAHRENHEIT


#include
#include
main()
{
int c;
float f;
clrscr();
printf("Enter temp in degree Celsius");
scanf("%d",&c);
f=(float)9/5*c+ 32;
printf("\n temp in deg. Celsius=%d C and in deg. fah =%fF",c,f);
getch();
}



Related Links :

C PROGRAMS TO FIND EFFICIENCY AND OUTLET TEMP OF COMPRESSOR


#include
#include
#include
main()
{
float ti,to,pi,po,e,g=1.4;
clrscr();
printf("enter ti,pi,and po Values...");
scanf("%f%f%f",&ti,&pi,&po);
to=ti *pow(po/pi,(g-1)/ g);
e=l-pow(pi/po,(g-1 )/g);
printf("outlet temp=%f efficiency=%f" ,to,e);
getch();
}



Related Links :

C program to convert Days into Year months, weeks and leftover days

C program to convert Days into Year months, weeks and leftover days



#include
#include
main()
{
int days,month,week,year;
clrscr();
year=0;
printf("enter days");
scanf("%d" ,&days);
month=days/30;
days%=30;
week=days/7;
days%=7;
year=month/12;
printf("equivalent months=%d weeks=%d and·
leftoverdays=%d" ,month,week,days);
if (year>0)
{
printf("\n The Years are %d",year);
}
getch();
}



Related Links :

C PROGRAM TO CREATE Triangle USING FOR LOOP TO OBTAIN THE Triangle

C PROGRAM TO CREATE Triangle USING FOR LOOP TO OBTAIN THE Triangle


#include



main()
{
int i,j;
for(i=7;i>0;i–)
{

for(j=i;j>0;j–)



{

printf(“*\t”);

}

printf(“\n\v”);

}

}





Related Links :

C Program to RECURSIVE FUNCTION FIND FACTORIAL OF A NUMBER

C Program RECURSIVE FUNCTION TO FIND FACTORIAL OF A NUMBER


#include

int fact(int n)
{
int factor=1;
if(n==1)
{
return 1;
}
else
{
factor=n*fact(n-1);
return factor;
}
}
main()
{
int n;
printf(“Enter a number\n”);
scanf(“%d”,&n);
printf(“Factorial of %d = %d\n”,n,fact(n));
}



Related Links :

C Program to create Tower Of Hanoi


#include
#include
class hanoi
{
int disk;
char beg[4],end[4],aux[4];
public:
void move(int,char[],char[],char[]);
};

void hanoi::move(int disk,char frmtwr[4],char totwr[4],char auxtwr[4])
{
if (disk==1)
{
cout<<”\nMove disk 1 from tower “<<frmtwr<<” to tower “<<totwr;
return;
}
move(disk-1,frmtwr,auxtwr,totwr);
cout<<”\nMove disk “<<disk<<” from tower “<<frmtwr<<” to tower “<<totwr;
move(disk-1,auxtwr,totwr,frmtwr);
return;
}

void main()
{
int n;
hanoi object;
clrscr();
cout<<”Tower Of Hanoi\n”;
cout<<”Let the towers be BEG,AUX & END\n”;
cout<<”Enter the number of disks: “;
cin>>n;
object.move(n,”BEG”,”END”,”AUX”);
getch();
}



Related Links :

Important Question On C Language Asked in Interview or Viva

Important Question On C Language Asked in Interview or Viva


Well following are the commonly asked interview question which you may have to face in your interview or Campus interview Selection rounds ....


1.Define friend function.
A: A friend function is a non-member function of a class which has access to the private members of that class.

2.How is they declared and defined?
A: A friend function is declared in a class using the keyword friend. It is defined outside the class like any other normal functions.

3.How is a friend function invoked?

A: A friend function is invoked like a normal function in C++.

4.What are reference variables and what is their use?

A: A reference variable acts as alias to the another variable.

5.What are the features of OOP?

A: 1:Class,2.Object,3.Data abstraction and encapsulation,4.Polymorphism,5.Dynamic binding,6.Message passing.

6.What is dynamic binding?

A: The linkage between a procedure call and the code to be executed is known at run time is called dynamic binding. It’s related to polymorphism.

7.Define polymorphism.


8.What are two types of polymorphisms? Give example for both.

A: Compile time polymorphism and run-time polymorphism,eg: function overloading and virtual functions respectively.

9.What is a do nothing function?

A: A function declared in a base class and does not do any operations and is redefined in sub classes is called a do nothing function.

10.Define pointers.

A: Pointers are used to store address of memory locations.


Best of Luck Friends.... :)

Related Links :

C Program to SORT A LIST OF n POSITIVE INTEGERS IN ASCENDING ORDER

C Program to SORT A LIST OF n POSITIVE INTEGERS IN ASCENDING ORDER


#include

main()
{
int arr[20],i,j,temp;
printf(“Enter Ant 20 Numbers\n”);
for(i=0;i<20;i++)
{
scanf(“%d”,&arr[i]);
}
for(i=0;i<19;i++)
{
for(j=i;j<20;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
printf(“Sorted array…\n”);
for(i=0;i<20;i++)
{
printf(“%d\n”,arr[i]);
}
}






Keywords : Sort positive numbers, C Program to sort positive numbers, sort sending +ve numbers in C, c assignments to sort numbers, C Program to sort ascending numbers

Related Links :

C Program to show SEQUENTIAL SEARCH

C Program to show SEQUENTIAL SEARCH



#include

main()
{
int arr[50],k,i,l,pos=0;
printf(“Enter limit For SEQUENTIAL SEARCH\n”);
scanf(“%d”,&l);
printf(“Enter %d elements\n”,l);
for(i=0;i<l;i++)
{
scanf(“%d”,&arr[i]);
}
printf(“Enter a number to be search\n”);
scanf(“%d”,&k);
for(i=0;i<l;i++)
{
if(arr[i]==k)
{
pos=i+1;
break;
}
}
if(pos!=0)
printf(“%d is found in the list, at position %d\n”,k,pos);
else
printf(“%d is not in the list\n”,k);

}





OUTPUT:



Enter limit For SEQUENTIAL SEARCH

10

Enter 10 elements

11

23

58

31

56

77

43

12

65

19

Enter a number to be search

31

31 is found in the list, at position 4

Related Links :

C Program FOR MATRIX MULTIPLICATION

C Program FOR MATRIX MULTIPLICATION



#include
main()
{
int a[20][20],b[20][20],c[20][20],r1,c1,c2,r2,i,j,k;
printf(“\tEnter the row and coloumn size For matrix1\n”);
scanf(“%d%d”,&r1,&c1);
printf(“\tEnter the row and coloumn size For matrix2\n”);
scanf(“%d%d”,&r2,&c2);
if (c1!=r2)
{
printf(“\tOppssss...The Coloumn size of Matrix1 not equal to row size of Matrix2\n\tMultiplication impossible/n”);
}
else
{
printf(“\tEnter elemnts of matrix1\n”);
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“\tEnter elements of matrix2\n”);
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
c[i][j]=0;
for(k=0;k<c1;k++)
{
c[i][j]+=a[i][k]*b[k][j];
}
}
}
printf(“\tYes...!! Product Matrix…\n”);
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
printf(“\t%d\t”,c[i][j]);
}
printf(“\n”);
}
}
}






OUTPUT:



Enter the row and coloumn size of matrix1
3
3
Enter the row and coloumn size of matrix2
3
3
Enter elemnts of matrix1
1
2
3
4
5
6
7
8
9

Enter elemnts of matrix2
9
8
7
6
5
4
3
2
1

Product Matrix…

30 24 18

84 69 54

138 114 90

Related Links :

C Program TO REPLACE A PARTICULAR WORD BY ANOTHER WORD IN GIVEN STRING

C Program TO REPLACE A PARTICULAR WORD BY ANOTHER WORD IN GIVEN STRING


#include
#include
main()
{
int lr,m,x,t,l,ll,ls,i,j,k,flag,count=0;
char line[200],str[20],rep[20];
printf(“Enter line of text\n”);
gets(line);
printf(“Enter the word to replace\n”);
scanf(“%s”,str);
printf(“Enter the word to replace with\n”);
scanf(“%s”,rep);
ll=strlen(line);
ls=strlen(str);
lr=strlen(rep);
for(i=0;i<ll;i++)
{
if(line[i]==str[0]&&((line[i-1]==’ ‘||i==0)&&(line[i+ls]==’ ‘||line[i+ls]==’\0′)))
{
for(flag=0,k=i,j=0;j{
if(line[k]==str[j])
{
flag++;
}
}
if(flag==ls)
{
if(lr>ls)
{
for(m=lr-ls;m>0;m–)
{
ll=strlen(line);
for(l=ll;l>i;l–)
{
line[l+1]=line[l];
}
}
}
else if(lr{
for(m=ls-lr;m>0;m–)
{
ll=strlen(line);
for(l=i;l<ll;l++)
{
line[l]=line[l+1];
}
}
}
else
{
}
for(x=0,t=i;x<lr;x++,t++)
{
line[t]=rep[x];
}
}
}
}
printf(“Text\n”);
puts(line);
}





Output :


Enter line of text

Snehal IS A GOOD GIRL

Enter the word to replace

GIRL

Enter the word to replace with

BOY

Text

Snehal IS A GOOD BOY

Related Links :

C Program using RECURSIVE FUNCTION TO FIND FACTORIAL OF A NUMBER


#include

int fact(int n)
{
int factor=1;
if(n==1)
{
return 1;
}
else
{
factor=n*fact(n-1);
return factor;
}
}

main()
{
int n;
printf(“Enter a number\n”);
scanf(“%d”,&n);
printf(“Factorial of %d = %d\n”,n,fact(n));
}




OUTPUT:



Enter a number

7

Factorial of 7 = 5040

Related Links :

C Program to Convert Lowercase Letters to Upper Case, Small to capital Letters in C

C Program to Convert Lowercase Letters to Upper Case, Small to capital Letters in C


#include

#include

void convert(char strng[])
{
int i,l;
l=strlen(strng);
for(i=0;i{
if(strng[i]>=97&&strng[i]<=122)
{
strng[i]=strng[i]-32;
}
}
printf(“Please Entered Any string\n%s\n”,strng);
}
main()
{
char strng[20];
printf(“Enter a string\n”);
gets(strng);
convert(strng);
}



Related Links :

C Program to print Fibonacci numbers Series

C Program to print Fibonacci numbers Series


#include

main()

{

int a=1,b=1,c=0,m,i=0;

printf(“Enter limit\n”);

scanf(“%d”,&m);

do
{

printf(“%d\t”,a);

i++;

c=a+b;

a=b;

b=c;

}while(i<m);

printf(“\n”);

}





OUTPUT:




Enter limit

8

1 1 2 3 5 8 13 21

Related Links :

C++ Program to find given String is Palindrome or Not

C++ Program to find given String is Palindrome or Not


#include
#include
#include
void main()
{
char a[10],b[10];
clrscr();
cout<<"Please Enter Any String";
cin>>a;
strcpy(b,a);
strrev(b);
if(strcmp(a,b)==0)
{
cout<<"Enter String is Palindrome";
}
else
{
cout<<"Enter String is not Palindrome";
}
getch();
}


Related Links :

C++ Program to find Sum of Given Digits

C++ Program to find Sum of Given Digits



#include
#include
void main()
{
int d1,ori,add;
add=0;
cout<<"enter the number";
cin>>ori;
while(ori!=0)
{
d1=ori%10;
ori=ori/10;
add=add+d1;
}
cout<<"sum of digit"<<add;
getch();
}



Related Links :

C++ Program to Find roots are imaginary

C++ Program to Find roots are imaginary


#include
#include
#include
void main()
{
int a,b,c;
clrscr();
cout<<"enter the values of a,b,c";
cin>>a>>b>>c;
int d=(b*b)-4ac ;
if (d<0)
cout<<"\n\t roots are imaginary";
if(d==0)
{
float x;
x=-b/2*a;
cout<<"\n\t X="< < x;
}
if(d>0)
{
float x1,x2;
x1=-b+sqrt(d)/2*a;
x2=-b-sqrt(d)/2*a;
cout<<"\n\t x1="< < x1;
cout<<"\n\t x2="< < x2;
}
getch();
}





Related Links :

C++ Program to find given number is Prime or Not

C++ Program to find given number is Prime or Not


#include e
#include
void main()
{
int num=0,k=0,i;
clrscr();
cout<<"Enter the value of num";
cin>>num;
for(i=2;i<=num-1;i++)
{
k=num%i;
if(k==0)
{
break;
}
else
{
continue;
}
}
if(k==1)
{
cout<<"Given num is prime" ;
}
else
{
cout<<"Given num is not prime";
}
getch();
}






Related Links :

C++ Program to Reverse the given array values

C++ Program to Reverse the given array values


#include
int main()
{
int a[10],i;
cout<<"enter the array:";
for(i=0;i<10;i++)
{
cin>>a[i];
}
cout<<"reverce array is:";
for(i=9;i>=0;i--)
{
cout<<a[i]<<"\n";
}
return0
}



Related Links :

Overloading Program in C++

Overloading Program in C++



#include
#include
double sum(double,int);
long sum(long,int,int);
void main()
{
clrscr();
cout<<"\n\t +" <<sum(70,34);
cout<<"\n\t +" <<sum(100,76,98);
getch();
}
double sum(double a,int b)
{
return(a+b);
}
long sum(long c,int d,int e)
{
int f;
f=c+d+e;
return(f);
}



Related Links :


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!