Ibm Programs
Ibm Programs
#include<bits/stdc++.h>
using namespace std;
// Driver code
int main()
{
float a = 5, b = 4;
findArea(a, b);
return 0;
}
Area of triangle
#include <stdio.h>
int main()
{
float base, height, area;
return 0;
}
1. #include<stdio.h>
2. #include<math.h>
3.
4. int main()
5. {
6. double a, b, c, s, area;
7.
8. printf("Enter the sides of
triangle\n");
9.
10. scanf("%lf%lf%lf", &a, &b, &c);
11.
12. s = (a+b+c)/2;
13.
14. area = sqrt(s*(s-a)*(s-b)*(s-c));
15.
16. printf("Area of the triangle =
%.2lf\n", area);
17.
18. return 0;
19. }
Volume of a cone
#include <stdio.h>
#include <conio.h>
#define PI 3.14159
int main(){
float radius, height, volume;
printf("Enter base radius and height of a
Cone\n");
scanf("%f %f", &radius, &height);
getch();
return 0;
}
Integer to Roman
#include<stdio.h>
int main()
{
printf("250 -> ");
decimal2roman(250);
return 0;
}
Java program
class Roman{
public static String IntegerToRoman(int n){
String roman="";
int repeat;
int magnitude[]={1000,900, 500, 400, 100, 90, 50,
40, 10, 9, 5, 4, 1};
String symbol[]={"M","CM", "D", "CD", "C", "XC",
"L", "XL", "X", "IX", "V", "IV", "I"};
}
Arithmetic series
}
}
// Driver code
public static void main(String[] args)
{
// starting number
int a = 2;
// Common difference
int d = 1;
// N th term to be find
int n = 5;
printAP(a, d, n);
}
}
Triangular sequence
#include <stdio.h>
#include<stdlib.h>
return 0;
}
// Driver code
int main()
{
int n,a[n],i,flag=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(isTriangular(a[i]))
{
continue;
}
else
{
flag=1;
}
}
if(flag==1)
printf("Not a triangular sequence");
else
printf("Trinagular sequence");
}
Pig latin
class Main {
static boolean isVowel(char c) {
return (c == 'A' || c == 'E' || c == 'I' || c == 'O'
|| c == 'U' ||
c == 'a' || c == 'e' || c == 'i' || c == 'o'
|| c == 'u');
}
// Driver code
public static void main(String[] args) {
String str = pigLatin("graphic");
if (str == "-1")
System.out.print("No vowels found." +
"Pig Latin not possible");
else
System.out.print(str);
}
}
if(decimal==dec)
{
printf("Equal");
}
else
{
printf("Not equal");
}
return 0;
}