Skip to content

Commit 91b8c8f

Browse files
committed
new programs added
1 parent ff3dbff commit 91b8c8f

File tree

10 files changed

+161
-0
lines changed

10 files changed

+161
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Print hello world without semicolon
3+
Author : Krishna Teja G S
4+
Repository : github.com/packetprep/coding-questions
5+
Website : packetprep.com
6+
*/
7+
8+
#include<stdio.h>
9+
10+
int main(){
11+
12+
if(printf("Hello World\n")){
13+
return 0;
14+
}
15+
16+
}
17+
18+
19+
20+
21+
22+
23+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Find the Largest number without conditional operator
3+
Author : Krishna Teja G S
4+
Repository : github.com/packetprep/coding-questions
5+
Website : packetprep.com
6+
*/
7+
8+
#include<stdio.h>
9+
int findMax(int,int);
10+
11+
int main(){
12+
13+
int a,b,c,max;
14+
printf("Enter a first integer: ");
15+
scanf("%d",&a);
16+
17+
printf("Enter a second integer: ");
18+
scanf("%d",&b);
19+
20+
21+
max = findMax(a,b);
22+
23+
printf("The maximum number is %d",max);
24+
25+
26+
}
27+
28+
int findMax( int x, int y)
29+
{
30+
int z = x - y;
31+
int i = (z >> 31) & 0x1;
32+
int max = x - i * z;
33+
return max;
34+
}
35+
36+
37+
38+
39+

Basic Programs/13_AreaOfTriangle.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Find the area of Triangle when sides are given
3+
Author : Krishna Teja G S
4+
Repository : github.com/packetprep/coding-questions
5+
Website : packetprep.com
6+
*/
7+
8+
#include<stdio.h>
9+
#include<math.h>
10+
11+
int main(){
12+
13+
double a,b,c,s,area;
14+
15+
printf("Enter the 3 sides of the triangle: ");
16+
scanf("%lf %lf %lf",&a,&b,&c);
17+
18+
s = (a+b+c)/2;
19+
20+
area = sqrt(s*(s-a)*(s-b)*(s-c));
21+
22+
printf("Area of the triangle is %lf\n",area);
23+
return 0;
24+
25+
26+
}
27+
28+
29+
30+
31+
32+
33+

Basic Programs/14_VolumeOfSphere.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Find the volume of a Sphere
3+
Author : Krishna Teja G S
4+
Repository : github.com/packetprep/coding-questions
5+
Website : packetprep.com
6+
*/
7+
8+
#include<stdio.h>
9+
10+
int main(){
11+
12+
double radius,volume;
13+
14+
printf("Enter the Radius of the sphere: ");
15+
scanf("%lf",&radius);
16+
17+
volume = (4.0/3) * (22.0/7) * radius * radius * radius;
18+
19+
20+
printf("Volume of the Sphere is %.2lf\n",volume);
21+
22+
}
23+
24+
25+
26+
27+
28+
29+

Basic Programs/15_LeapYear.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Check if it is Leap Year
3+
Author : Krishna Teja G S
4+
Repository : github.com/packetprep/coding-questions
5+
Website : packetprep.com
6+
*/
7+
8+
#include<stdio.h>
9+
10+
int main(){
11+
12+
int number;
13+
14+
printf("Enter the year: ");
15+
scanf("%d",&number);
16+
17+
if(number % 4 == 0){
18+
19+
if( number % 100 == 0){
20+
if(number % 400 == 0){
21+
printf(" %d is a Leap year\n",number);
22+
}else
23+
printf(" %d is not Leap year\n",number);
24+
}else
25+
printf(" %d is a Leap year\n",number);
26+
}else
27+
printf(" %d is not Leap year\n",number);
28+
29+
30+
}
31+
32+
33+
34+
35+
36+
37+

Basic Programs/output/11

8.23 KB
Binary file not shown.

Basic Programs/output/12

8.31 KB
Binary file not shown.

Basic Programs/output/13

8.28 KB
Binary file not shown.

Basic Programs/output/14

8.28 KB
Binary file not shown.

Basic Programs/output/15

8.28 KB
Binary file not shown.

0 commit comments

Comments
 (0)