Showing posts with label maths. Show all posts
Showing posts with label maths. Show all posts

Monday, February 8, 2016

C++ Program to Check Whether a give number is Prime or Not

//Program to check whether the given number is Prime or Not.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int N,flag=0;
cout<<"\nEnter number to check whether it is prime or not:";
cin>>N;
for(int i=2;i<N;i++)
{
if(N%i==0)
flag=1;
}
if(flag==1)
cout<<"\nIt is not a prime number!";
else if(flag==0)
cout<<"\nThe given number is a prime number!";
getch();
}

Friday, April 11, 2014

C program for Addition

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,ans;
printf("Enter two numbers:");
scanf("%d%d",&a,&b);
ans=a+b;
printf("Solution is:%d",ans);
getch();
}

Pages