Luv Pps

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 22

Gateway Institute of Engineering and Technology (GIET)

GATEWAY INSTITUTE OF ENGINEERING


& TECHNOLOGY (GIET), SONEPAT

Computer Science & Engineering


(CSE) Department

PROGRAMS FOR PROBLEM SOLVING


(CSE 103C)

Submitted by: Submitted To:


Name: Luv Name: Mr. Anil Sir
Rollno: 22010001029 Asst. Prof. CSE, GIET

Luv 1 22010001029
Gateway Institute of Engineering and Technology (GIET)

INDEX
S. NO. Program List Signature
1. Write a program to compute the average of three numbers ?
2. Write a program to find the area of circle ?
3. Write a program to find the simple interest ?
4. Write a program to find volume of cylinder ?
5. Write a program check weather a number is even or odd ?
6. Write a program to check the entered year is a leap year or not ?
7. Write a program to find greater of three numbers ?
8. Write a program to check weather a number is positive, negative
or zero ?
9. Write a program to check a number is divisible by both 3 and 5 ?
10. Write a program to find sum of squares upto user’s input ?
11. Write a program to find sum of series (1+3+5+……….+19) ?
12. Write a program to find sum of series (1+4+7+………..+25) ?
13. Write a program to find cube of even numbers upto user’s input ?
14. Write a program to find factorial of the given number ?
15. Write a program to find sum of two matrix ?

Luv 2 22010001029
Gateway Institute of Engineering and Technology (GIET)

PROGRAM – 1
1. Write a program to compute the average of three numbers ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a,b,c;

float average;

printf("\nenter 3 no to get average\n");

scanf("%d%d%d",&a,&b,&c);

average=(a+b+c)/3;

printf("average of no is %f",average);

getch();

return0;

OUTPUT :

Luv 3 22010001029
Gateway Institute of Engineering and Technology (GIET)

PROGRAM – 2
2. Write a program to find the area of circle ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int r;

float area;

printf("\nenter radius of circle\n");

scanf("%d",&r);

area=3.14*r*r;

printf("area of circle is %f",area);

Luv 4 22010001029
Gateway Institute of Engineering and Technology (GIET)

getch();

return 0;

OUTPUT :

PROGRAM – 3
3. Write a program to find the simple interest ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int p,r,t;

float simple_interest;

printf("\nenter principle\n");

scanf("%d",&p);

Luv 5 22010001029
Gateway Institute of Engineering and Technology (GIET)

printf("enter rate\n");

scanf("%d",&r);

printf("enter time\n");

scanf("%d",&t);

simple_interest=(p*r*t)/100;

printf("simple interest is %f",simple_interest);

getch();

return 0;

OUTPUT :

PROGRAM – 4
4. Write a program to find volume of cylinder ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

Luv 6 22010001029
Gateway Institute of Engineering and Technology (GIET)

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int r;

float volume;

printf("\nenter radius of cylinder\n");

scanf("%d",&r);

volume=4/3*3.14*r*r*r;

printf("volume of cylinder is %f",volume);

getch();

return 0;

OUTPUT :

PROGRAM – 5
5. Write a program check weather a number is even or odd ?

SOURCE CODE :

#include<stdio.h>

Luv 7 22010001029
Gateway Institute of Engineering and Technology (GIET)

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a,i;

printf("\nenter a no to know it is even or odd \n");

scanf("%d",&a);

i=a%2;

if(i==0){

printf("the no is even");}

else{

printf("the no is odd");}

getch();

return 0;}

OUTPUT :

PROGRAM – 6

Luv 8 22010001029
Gateway Institute of Engineering and Technology (GIET)

6. Write a program to check the entered year is a leap year or not ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a,b;

printf("\nenter a year\n");

scanf("%d",&a);

b=a%4;

if(b==0){

printf("your year is leap year");}

else{

printf("not a leap yaer");}

getch();

return 0;}

OUTPUT :

Luv 9 22010001029
Gateway Institute of Engineering and Technology (GIET)

PROGRAM – 7
7. Write a program to find greater of three numbers ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a,b,c;

printf("\nenter 3 no \n");

scanf("%d%d%d",&a,&b,&c);

if(a>b && a>c){

printf("a is grater");}

if(b>a && b>c){

printf("b is grater ");}

if (c>a && c>b){

printf("c is grater ");}

Luv 10 22010001029
Gateway Institute of Engineering and Technology (GIET)

else{

printf("wrong choice");}

getch();

return 0;

OUTPUT :

PROGRAM – 8
8. Write a program to check weather a number is positive, negative or zero ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a;

printf("\nenter a no \n");

Luv 11 22010001029
Gateway Institute of Engineering and Technology (GIET)

scanf("%d",&a);

if(a>0){

printf("the no is +ve");

if(a<0){

printf("the no is -ve");

if(a==0){

printf("the no is zero");}

getch();

return 0;

OUTPUT :

PROGRAM – 9
9. Write a program to check a number is divisible by both 3 and 5 ?

Luv 12 22010001029
Gateway Institute of Engineering and Technology (GIET)

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a;

printf("\nenter a no \n");

scanf("%d",&a);

if(a%3==0 && a%5==0){

printf("divisible by both 3 and 5");}

else{

printf("not divisible by 3 and 5");}

getch();

return 0;}

OUTPUT :

PROGRAM – 10

Luv 13 22010001029
Gateway Institute of Engineering and Technology (GIET)

10. Write a program to find sum of squares upto user’s input ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a,i,j,k;

k=0;

i=1;

printf("\nsum of square of no.'s upto \n");

scanf("%d",&a);

while(i<=a){

j=i*i;

printf("square of no %d is %d\n",i,j);

k=k+j;

i=i+1;

printf("sum of squares upto %d is %d",a,k);

getch();

return 0;

OUTPUT :

Luv 14 22010001029
Gateway Institute of Engineering and Technology (GIET)

PROGRAM – 11
11. Write a program to find sum of series (1+3+5+……….+19) ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a,i,s;

s=0;

i=1;

printf("\nsum of series (1+3+5+7+……+19)\n");

while(i<=20){

s=s+i;

i=i+2;}

printf("is %d",s);

Luv 15 22010001029
Gateway Institute of Engineering and Technology (GIET)

getch();

return 0;}

OUTPUT :

PROGRAM – 12
12. Write a program to find sum of series (1+4+7+………..+25) ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a,i,s;

s=0;

i=1;

printf("\nsum of series (1+4+7+10+……..+25) \n");

Luv 16 22010001029
Gateway Institute of Engineering and Technology (GIET)

while(i<=25){

s=s+i;

i=i+3;}

printf("is %d",s);

getch();

return 0;}

OUTPUT :

PROGRAM – 13
13. Write a program to find cube of even numbers upto user’s input ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int a,i,j,k;

k=0;

Luv 17 22010001029
Gateway Institute of Engineering and Technology (GIET)

i=0;

printf("\nsum of cube of even no.'s upto \n");

scanf("%d",&a);

while(i<=a){

j=i*i*i;

printf("cube of even no %d is %d\n",i,j);

k=k+j;

i=i+2;

printf("sum of cube of even no upto %d is %d",a,k);

getch();

return 0;

OUTPUT :

Luv 18 22010001029
Gateway Institute of Engineering and Technology (GIET)

PROGRAM – 14
14.Write a program to find the factorial of a number ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int i,a,factorial;

factorial=1;

printf("\nfactorial of number\n");

scanf("%d",&a);

for(i=a;i>=1;i--){

factorial=factorial*i;

printf("%d",factorial);

getch();

return 0;

OUTPUT :

Luv 19 22010001029
Gateway Institute of Engineering and Technology (GIET)

PROGRAM – 15
15.Write a program find the sum of two matrix ?

SOURCE CODE :

#include<stdio.h>

#include<conio.h>

int main()

{ printf("\tname= luv\n\tclass=btech\n\troll no= 22010001029");

int i,j,matrix1[20][20],a,b,matrix2[20][20],matrix3[20][20];

printf(“\nenter no of rows\n”);

scanf(“%d”,&a);

printf(“enter no of columns\n”);

scanf(“%d”,&b);

printf(“enter values of matrix 1\n”);

for(i=1;i<=a;i++){

for(j=1;j<=b;j++){

printf(“enter value of row%d column%d=” ,i,j);

Luv 20 22010001029
Gateway Institute of Engineering and Technology (GIET)

scanf(“%d”,&matrix1[i][j]);

printf(“\n”);

printf(“enter values of matrix 2\n”);

for(i=1;i<=a;i++){

for(j=1;j<=b;j++){

printf(“enter value of row%d column%d= ”,i,j);

scanf(“%d”,&matrix2[i][j]);

printf(“\n”);

printf(“sum of matrix1 and matrix2 is\n”);

for(i=1;i<=a;i++){

for(j=1;j<=b;j++){

matrix3[i][j]=matrix1[i][j]+matrix2[i][j];

printf(“%d\t”,matrix3[i][j]);

printf(“\n”);

getch();

return 0;

OUTPUT :

Luv 21 22010001029
Gateway Institute of Engineering and Technology (GIET)

Luv 22 22010001029

You might also like