Go Back   ManagementParadise.com | Management & Business Education Learning Platform Resolve Your Query - Get Help and discuss Projects > Basics of Computers

pc

Discuss pc within the Basics of Computers forums, part of the Resolve Your Query - Get Help and discuss Projects category; 1. /*To find sum,difference,product,quotient*/ main() { float a,b,sum,difference,product,quotient; printf("<Enter the value 1:"); scanf("%f",&a); printf("<Enter the value 2:"); scanf("%f",&b); sum=a+b; printf("Sum=%f",sum); ...

Reply

 

Thread Tools Display Modes
C programming
Old
 (1 (permalink))
pramod
pramod is an unknown quantity at this point
 
pramod
Status: Offline
Posts: 2
Join Date: Dec 2004
C programming - December 29th, 2004

1. /*To find sum,difference,product,quotient*/

main()
{
float a,b,sum,difference,product,quotient;
printf("<Enter the value 1:");
scanf("%f",&a);
printf("<Enter the value 2:");
scanf("%f",&b);
sum=a+b;
printf("Sum=%f",sum);
difference=a-b;
printf("\nDifference=%f",difference);
product=a*b;
printf("\nProduct=%f",product);
quotient=a/b;
printf("\nQuotient=%f",quotient);
return 0;
}



2. /*To ask 5 numbers & finding their sum & average*/

main()
{
int a,i,sum;
float average;
sum=0,i=1;
while (i<=5)
{
printf("Enter value number %d:",i);
scanf("%d",&a);
sum=sum+a;
average=sum/5;
i++;
}
printf("The sum of the five numbers =%d",sum);
printf("\nThe average of the five numbers is =%f",average);
return 0;
}





3. /*To find simple interest*/

main()
{
int p,n;
float r,interest;
printf("<enterp>");
scanf("%d",&p);
printf("<entern>");
scanf("%d",&n);
printf("<enterr>");
scanf("%f",&r);
interest=0;
interest=p*n*r/100;
printf("The simple interest=%f",interest);
return 0;
}

4. /*To find area & circumference of circle*/

main()
{
float r,pie,area,circumference;
printf("Enter radius:");
scanf("%f",&r);
pie=3.14;
area=pie*r*r;
printf("\nThe area of circle=%f",area);
circumference=2*pie*r;
printf("\nThe circumference of the circle=%f",circumference);
return 0;
}

5. /*To get the answer in Centigrade*/

main()
{
float F,c;
printf("<enterF>");
scanf("%f",&F);
c=(F-32)*5/9;
printf("The centigrade value =%f",c);
return 0;
}


6. /*To find the difference between post operator & pre operator*/

main()
{
float a,b;
printf("Enter the value a:");
scanf("%f",&a);
printf("<nter the value b:");
scanf("%f",&b);
b=a++;
printf("a=%f",a);
printf("\nb=%f",b);
printf("\nTHIS IS THE EXAMPLE OF POST-OPERATOR");
b=++a;
printf("\na=%f",a);
printf("\nb=%f",b);
printf("\nTHIS IS THE EXAMPLE OF PRE OPEERATOR");
return 0;
}



7. /*To find whether the number entered is even or odd*/

main()
{
int a;
printf("Enter the value a:");
scanf("%d",&a);
if (a%2==0)
{
printf("The number is even");
}
printf("The number is odd");
return 0;
}










8./*To find whether the numbers entered by user are divisible by another*/

main()
{
int a,b;
printf("Enter the value a:");
scanf("%d",&a);
printf("Enter the value b:");
scanf("%d",&b);
if (a%b==0)
printf("The number is divisible");
else
printf("The number is not divisible");
return 0;
}



9. /*To find larger out of the 2 numbers entered*/

main()
{
int a,b,big;
printf("Enter the value a:");
scanf("%d",&a);
printf("Enter the value b:");
scanf("%d",&b);
big=a;
if (a<b)
big=b;
printf("The larger number is %d",big);
return 0;
}














10. /*To find the largest among the three numbers entered*/

main()
{
int a,b,c,big;
printf("Enter the value a:");
scanf("%d",&a);
printf("Enter the value b:");
scanf("%d",&b);
printf("Enter the value c:");
scanf("%d",&c);
big=a;
(b>a)&&(b>c);
big=b;
(c>a)&&(c>b);
big=c;
printf("big=%d",big);
return 0;
}





11. /*To find largest among n numbers entered*/

main()
{
int a,s,n,i;
printf("Enter the size s:");
scanf("%d",&s);
a=0,i=0;
for(i=1;i<=s;i++)
{
printf("Enter the value %d",i;
scanf("%d",&n);
if(n>a)
a=n;
}
printf("Largest value=%d",a);
return 0;
}








12. /*To display first n natural numbers*/

main()
{
int s,i;
printf("Enter the size s:");
scanf("%d",&s);
i=1;
do
{
printf("%d\n",i);
i++;
}
while (i<=s);
return 0;
}
OR
for(i=1;i<=s;i++)
{
printf("%d\n",i);
}





13. /*To find sum & average of n numbers*/

main()
{
int i,s;
float n,sum,average;
sum=0,average=0;
printf("Enter the size:");
scanf("%d",&s);
for(i=1;i<=s;i++)
{
printf("Enter the number:");
scanf("%f",&n);
sum=sum+n;
average=sum/s;
}
printf("The sum is %f",sum);
printf("\nThe average is %f",average);
return 0;
}



14. /*To find the area of n circles*/

main()
{
int s,i=1;
float r,pie,area;
pie=3.14;
printf("Enter the size s:");
scanf("%d",&s);
do
{
printf("\nEnter the radius:");
scanf("%f",&r);
area=pie*r*r;
printf("\nThe area of the circle is =%f",area);
i++;
}
while(i<=s);
return 0;
}





15. /*To find the area & perimeter of n triangles*/


main()
{
int i,l;
float a,b,c,s,area,perimeter;
printf("Enter the size:");
scanf("%d",&l);
area=0,perimeter=0;
for(i=1;i<=l;i++)
{
printf("\nEnter Side a:");
scanf("%f",&a);
printf("Enter Side b:");
scanf("%f",&b);
printf("Enter Side c:");
scanf("%f",&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
perimeter=a+b+c;
printf("THE AREA IS %f" ,area);
printf("\nTHE PERIMETER IS %f",perimeter);




16. /*To display day of the week according to the number entered*/

main()
{
int n;
printf("Enter the number:");
scanf("%d",&n);
switch(n)
{
case 1:
printf("MONDAY");
break;
case 2:
printf("TUESDAY");
break;
case 3:
printf("WEDNESDAY");
break;
case 4:
printf("THURSDAY");
break;
case 5:
printf("FRIDAY");
break;
case 6:
printf("SATURDAY");
break;
case 7:
printf("SUNDAY");
break;
default:
printf("The number is invalid");
}
return 0;
}







17. /*To find the squares of first n natural numbers*/
#include<stdio.h>
main()
{
int s,i,a;
a=0;
printf("Enter the size:");
scanf("%d",&s);
for(i=1;i<=s;i++)
{
a=i*i;
printf("\n%d",a);
}
return 0;
}





18. /*To find the squares of first n even or odd numbers*/

main()
{
int n,i,a;a=1;
printf("Enter the size:");
scanf("%d",&n);
n=n*2;
printf("\n\nThe squares of first n even numbers are as follows:");
for(i=2;i<=n;i++)
{
a=i*i;
i++;
printf("\n%d",a);
}
printf("\n\nThe squares of first n odd numbers are as follows:");
for(i=1;i<=n;i++)
{
a=i*i;
i++;
printf("\n%d",a);
}
return 0;
}






19. /*To find the factorial of the given number*/

main()
{
int i,n;
float fact;
fact=1;
printf("Enter the number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
fact=fact*i;
}
printf("\nThe factorial of ths given number is %f",fact);
return 0;
}








21. /*Finonacci series*/

main()
{
int a,b,c,n,i;
a=0,b=1,c=0;
printf("Enter size:");
scanf("%d",&n);
printf("\n%d",a);
printf("%d",b);
for(i=3;i<=n;i++)
{
c=a+b;
a=b;
b=c;
printf("%d",c);
}
return 0;
}




22. /*To display a particular pattern*/

main()
{
int i,n,j;
printf("Please insert the size:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("*");
printf("\n");
}
return 0;
}











23. /*To find the result of sum of squares of first n natural numbers*/

main()
{
int n,i,sum,a;
sum=0,a=0;
printf("Enter the size:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
a=i*i;
sum=sum+a;
}
printf("Sum is %d",sum);
return 0;
}





24. /*To display a particular pattern*/

main()
{
int i,n,j;
printf("Please insert the size:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
return 0;
}














25. /*To find the division obtained by a student*/

main()
{
float a,b,c,d,e,p;
printf("Enter the marks of 1st subject:");
scanf("%f",&a);
printf("\nEnter the marks of 2nd subject:");
scanf("%f",&b);
printf("\nEnter the marks of 3rd subject:");
scanf("%f",&c);
printf("\nEnter the marks of 4th subject:");
scanf("%f",&d);
printf("\nEnter the marks of 5th subject:");
scanf("%f",&e);
p=((a+b+c+d+e)*100)/500;
printf("\nYour score is %f%",p);
if (p>=80)
printf("\nCongratulation,you have obtained distinction");
else if(p>=60)
printf("\nWell Done,You have obtained 1st class");
else if(p>=40)
printf("\nNeed more practice,You have obtained 2nd class");
else if(p<40)
printf("\nYou have failed");
return 0;
}
Advertisements

Friends: (0)
Reply With Quote
C programming 2
Old
 (2 (permalink))
pramod
pramod is an unknown quantity at this point
 
pramod
Status: Offline
Posts: 2
Join Date: Dec 2004
C programming 2 - December 29th, 2004

1./*To take a set if numbers form the user & print them in row & then the largest & the smallest value in the list*/

main()
{
int number[10],i,j,l3,s;
clrscr();
for(i=0;i<10;i++)
{
printf(" Enter the list of any 10 number:",i+1);
scanf("%d",&number[i]);
}
for(j=0;j<10;j++)
{
printf("\t%d",number[j]);
}
l=number[0];
for(i=0;i<10;i++)
{
if(l<number[i])
l=number[i];
}
printf("\nThe largest number in the list is %d",l);
s=number[0];
for(i=0;i<10;i++)
{
if(s>number[i])
s=number[i];
}
printf("\nThe smallest number in the list is %d",s);
getch();
return 0;
}


2. /*To get the numbers in ascending order*/

main()
{
int a[10],i,j,k,temp;
for(i=0;i<10;i++)
{
printf("Enter the list:",i+1);
scanf("%d",&a[i]);
}
for(j=0;j<10;j++)
{
for(k=j+1;k<10;k++)
{
if (a[j]>a[k])
{
temp=a[j];
a[j]=a[k];
a[k]=temp;
}
}
}
printf("The number is sorted in ascending order:");
for(i=0;i<10;i++)
{
printf("\n%d",a[i]);
}
return 0;
}

3. /*To take namesof 3 students & their marks in 4 subjects*/

main()
{
char name[3][25];
int marks[3][4],i,j,k,l,sum;
for(i=0;i<3;i++)
{
printf(" Enter the name %d:",i+1);
scanf("%s",&name[i]);
for(j=0;j<4;j++)
{
printf("Name of the student: %s and his marks in subject %d:",name[i],j+1);
scanf("%d",&marks[i][j]);
}
}

for(k=0;k<3;k++)
{
sum=0;
printf("\n%s",&name[k]);
for(l=0;l<4;l++)
{
printf("\t%d",marks[k][l]);
sum=sum+marks[k][l];
}
printf("\t%d",sum);
}
return 0;
}


4. /*To find the square of n natural numbers using a function with a return statement*/

void square(x,y,z)
int x,*y,*z;
{
*y=x*x;
*z=x*x*x;
}

main()
{
int n,s,c,i;
printf("Enter the size:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
square(i,&s,&c);
printf("\n%d\t%d\t%d",i,s,c);
}
return 0;
}

5. /*To find factorial of a given number*/

void fact (int max);
void main()
{
int max;
printf("\n enter the number");
scanf("%d",&max);
fact(max);
}
void fact(int max)
{
int ctr,prod=1,no=0;
for(ctr=0;ctr<max;ctr++)
{
no ++;
prod=prod*no;
}
printf("\nfactorial of a number %d",prod);
}



8. /*To find factorial of a given number*/

void fact (int max);
void main()
{
int max;
printf("\n enter the number");
scanf("%d",&max);
fact(max);
}
void fact(int max)
{
int ctr,prod=1,no=0;
for(ctr=0;ctr<max;ctr++)
{
no ++;
prod=prod*no;
}
printf("\nfactorial of a number %d",prod);
}

9. /*To find factorial of a given number*/

void fact (int max);
void main()
{
int max;
printf("\n enter the number");
scanf("%d",&max);
fact(max);
}
void fact(int max)
{
int ctr,prod=1,no=0;
for(ctr=0;ctr<max;ctr++)
{
no ++;
prod=prod*no;
}
printf("\nfactorial of a number %d",prod);
}


11. /*To find the GCD of 2 numbers entered by the user*/

main()
{
int a,b,i,g,x;
printf("eNTER THE FIRST VALUE");
scanf("%d",&a);
printf("ENTER THE SECOND VALUE:");
scanf("%d",&b);
a>b?x=b:x=a;
for(i=0;i<=x;i++)
{
if(a%i==0 && b%i==0)
g=i;
}
printf("The GCD of the number is: %d",g);
return 0;
}


12. /*To find sum of a particular series*/

main()
{
float x,n,d=1,i,f,p,z,s=0;

float fact(float);
float power(float,float);
printf("Enter x:");
scanf("%f",&x);
printf("Enter n:");
scanf("%f",&n);
for (i=1;i<=n;i+=2)
{
f=fact(i);
p=power(x,i);
z=d*(p/f);
s=s+z;
d=d*(-1);
}
printf("THE FINAL VALUE:%f",s);
return 0;
}
float fact(x)
float x;
{
float y=1,i;
for(i=1;i<=x;i++)
{
y=y*i;
}
return y;
}
float power (a,b)
float a,b;
{
float i,j=1;
for(i=1;i<=b;i++)
j=j*a;
return j;
}

Sorry had to edit d mistakes - Kartik.
Friends: (0)
Reply With Quote
The Following User Says Thank You to For This Useful Post:
Computers
Old
 (3 (permalink))
Kartik Raichura
kartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond reputekartik has a reputation beyond repute
 
kartik
Founder & CEO at Management Paradise
Founder & CEO
Management Paradise Guru
 
Status: Offline
Posts: 4,434
Join Date: Nov 2004
Age: 34
Computers - March 25th, 2005

Post your questions and queries for Computers or help others by replying to this topic


Help Others -> Help Yourself !


Want to work with us and revolutionize management world ? send in a small writeup of what you will do and how with your cv on careers at managementparadise.com


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Friends: (92)
Reply With Quote
Re: pc
Old
 (4 (permalink))
Vinay Dubey
6.vinay has a spectacular aura about6.vinay has a spectacular aura about
 
6.vinay
Student of MBA at university of wales
Newcastle, Wales
Management Paradise Newbie
 
Status: Offline
Posts: 454
Join Date: Aug 2006
Location: Newcastle, Wales
Re: pc - October 29th, 2006

hey guys this forum is for the problems so post ur queries so that we can help ull or just try to help others as kartik said in any section


thank you
Friends: (0)
Reply With Quote
Reply

Bookmarks


« - | website »
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


ManagementParadise.com is not responsible for the views and opinion of the posters. The posters and only posters shall be liable for any copyright infringement.



Search Engine Optimization by vBSEO ©2011, Crawlability, Inc.