0% found this document useful (0 votes)
46 views19 pages

Manisha

The document contains 20 code snippets written in C programming language that demonstrate simple programs to calculate simple interest, print text, take user input, perform basic mathematical operations, if-else conditional statements, and determine leap years or insurance eligibility. Each code snippet includes comments to describe its purpose and outputs the results.

Uploaded by

nirmala4273
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views19 pages

Manisha

The document contains 20 code snippets written in C programming language that demonstrate simple programs to calculate simple interest, print text, take user input, perform basic mathematical operations, if-else conditional statements, and determine leap years or insurance eligibility. Each code snippet includes comments to describe its purpose and outputs the results.

Uploaded by

nirmala4273
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Ans1- #include<stdio.

h>
int main(){
float simpleinterest,p,r,t;
printf("enter the value of p");
scanf("%f" , &p);
printf("enter the value of r");
scanf("%f" , &r);
printf("enter the value of t");
scanf("%f" , &t);
simpleinterest=(p*r*t)/100;
printf("simpleinterest=
%f" ,simpleinterest);
return 0;
}
Ans2-#include<stdio.h>
int main(){
printf("hello world");
return 0;
}

Ans3-#include<stdio.h>
int main(){
int integer;
printf("enter the integer:");
scanf("%d" , &integer);
printf("the integer is :%d" , integer);
return 0;
}

Ans4- #include<stdio.h>
int main(){
int a,b,sum;
printf("enter first integer");
scanf("%d" , &a);
printf("enter second integer");
scanf("%d" , &b);
sum=a+b;
printf("sum=%d" , sum);
return 0;
}
Ans5-
#include<stdio.h>
int main(){
int a,b,diffrence;
printf("enter first integer");
scanf("%d" , &a);
printf("enter second integer");
scanf("%d" , &b);
diffrence=a-b;
printf("diffrence=%d" , diffrence);

return 0;
}
Ans6- #include<stdio.h>
int main(){
int l,b,area;
printf("enter the length:");
scanf("%d", &l);
printf("enter the breadth:");
scanf("%d", &b);
area=(l*b);
printf("area=%d" , area);
return 0;
}
Ans6-
printf("enter the distance in km");
scanf("%f" , &km);
met=km*1000;
cm=km*100000;
inch=km*39370.1;
feet=km*3280.84;
printf("distance in met=%f\n" , met);
printf("distance in cm=%f\n", cm);
printf("distance in inch=%f\n",inch);
printf("distance in feet=%f\n", feet);
return 0;
}
Ans8= #include<stdio.h>
int main (){
float a,da,ha,gross_salary;
printf("enter the baisc salary ");
scanf("%f" , &a);
da=(0.4*a);
ha=(0.2*a);
gross_salary=a+ha+da;
printf("mohan gross salary =%f",
gross_salary);
return 0;
}

Ans9- #include<stdio.h>
int main (){
float
maths,science,sst,hindi,english,aggeregate,pe
rcentage;
printf("enter the marks of maths");
scanf("%f" , &maths);
printf("enter the marks of science");
scanf("%f" , &science);
printf("enter the marks of sst");
scanf("%f" , &sst);
printf("enter the marks of hindi");
scanf("%f" , &hindi);
printf("enter the marks of english");
scanf("%f" , &english);

aggeregate=(maths+english+sst+science+hind
i);
printf("aggeregate = %f" , aggeregate);
percentage=(aggeregate/500)*100;
printf("percentage= %f" , percentage);
return 0;
}

Ams10- #include<stdio.h>
int main() {
float radius,area;
printf("enter the radius of circle");
scanf("%f" , &radius);
area=(3.14*radius*radius);
printf("area=%f" , area);
return 0;
}
Ans11- #include<stdio.h>
int main() {
float a,b,c,s,area;
printf("enter the first side of triangle");
scanf("%f" , &a);
printf("enter the second side of triangle");
scanf("%f" , &b);
printf("enter the third side of triangle");
scanf("%f" , &c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("area=%f" , area);
return 0;
}

Ans12-#include<stdio.h>
int main(){
int a,b,c,d,e;
printf("enter the 5 digits");
scanf("%d %d %d %d %d" ,
&a,&b,&c,&d,&e);
printf("reversed number=%d %d %d %d
%d" , e,d,c,b,a);
return 0;
}
Ans13- #include<stdio.h>
#include<math.h>
int main() {
float a,s,c,t,cosec,sec,cot,angle;
printf("enter the value of a in degree");
scanf("%f" , &a);
angle=a*3.14/180;
s=sin(a);
c=cos(a);
t=tan(a);
cosec=1/s;
sec=1/c;
cot=1/t;
printf("sin(a)=%f cos(a)=%f tan(a)=%f
cosec=%f sec=%f tan=%f" ,
s,c,t,cosec,sec,tan);
return 0;
}

Ans 14- #include<stdio.h>


int main() {
float quan,price,total,discount;
printf("enter the quantity perchased:");
scanf("%f" , &quan);
printf("enter the price per item:");
scanf("%f" , &price);
if (quan>1000)
discount=0.1*(quan*price);
else
discount=0;
total=(price*quan)-discount;
printf("total=%f" , total);
return 0;
}

Ans15- #include<stdio.h>
int main(){
float HRA , DA, gross,salary;
printf("enter the salary ");
scanf("%f" , &salary);
if (salary<1500)
{HRA=0.1*salary;
DA=0.9*salary;}
else
{HRA=500;
DA=0.98*salary;}
gross=HRA+DA+salary;
printf("gross =%f" , gross);
return 0;
}

Ans16- #include<stdio.h>
int main () {
int cp,sp,profit,loss,difference;
printf("enter the cp of the item");
scanf("%d" , &cp);
printf("enter the sp of the item");
scanf("%d" , &sp);
difference=cp-sp;
if(cp>sp)
{printf("profit");
}
else
{printf("loss");}
printf("difference=%d\n" , difference);
return 0;
}

Ans17- #include<stdio.h>
int main() {
int a;
printf("enter the integer");
scanf("%d" , &a);
if (a%2==0)
{printf("the number is even");
}
else
printf("the number is odd");
return 0;
}

Ans18- #include<stdio.h>
int main() {
int year;
printf("enter the year");
scanf("%d" , &year);
if (year%4==0)
{printf("the year is leap year");
}
else
{printf("the year is not a leap year");
}
return 0;
}

Ans20-#include<stdio.h>
int main()
{
char MS,gender;
int age;
/*Y for married and n for not married*/
printf("Enter marital status(y/n) and
gender(m/f): ");
scanf("%c %c",&MS,&gender);
/*M for male and f for female*/
printf("Enter age: ");
scanf("%d",&age);
if((MS=='y')||(MS=='n' && gender=='m'
&& age>30)||(MS=='n' && gender=='f' &&
age>25))
printf("Driver should be insured");
else
printf("Driver should not be insured");
return 0;
}

You might also like