//Hello World program
#include <stdio.h>
int main()
{
printf("Hello World");
return 0;
}
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello World");
end Hello;
with Ada.Text_IO;
use Ada.Text_IO;
procedure Hello is
begin
Put_Line("Hello World");
end Hello;
//prime or not
//c
#include<stdio.h>
int factorial(int n);
int main(void)
{
int n, i, count=0;
n=15;
for(i=1; i<=n; i++)
{
if(n%i==0)
{
count++;
}
}
if(count==2)
{
printf("%d is prime\n", n);
}
else
{
printf("%d is not a prime\n", n);
}
return 0;
}
//using functions
#include<stdio.h>
int prime(int n);
int main(void)
{
int n, r;
n=15;
r = prime(n);
if(r==1)
{
printf("%d is prime\n", n);
}
else
{
printf("%d is not a prime\n", n);
}
return 0;
}
int prime(int n)
{
int i, count=0;
for(i=1; i<=n; i++)
{
if(n%i==0)
{
count++;
}
}
if(count==2)
{
return 1; //prime
}
else
{
return 0; //not a prime
}
}
// ada
with Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
procedure Hello is
n : integer;
c : integer := 0;
begin
n := 15;
for count in 1 .. n loop
if n rem count = 0 then
c := c + 1;
end if;
end loop;
if c=2 then
put(n);put_line(" is prime");
else
put(n);put_line(" is not a prime");
end if;
end Hello;
//using function
with Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
procedure Hello is
function prime (n: in integer) return integer is
c : integer := 0;
begin
for count in 1 .. n loop
if n rem count = 0 then
c := c + 1;
end if;
end loop;
if c=2 then
return 1; --prime
else
return 0; --not a prime
end if;
end prime;
n,r : integer;
begin
n := 15;
r := prime(n);
if r=1 then
put(n);put_line(" is prime");
else
put(n);put_line(" is not a prime");
end if;
end Hello;