// Write a programe to print odd and even numbers,using array //
#include<stdio.h>
#include<conio.h>
#define MAX 100 // User define function //
void main()
{
int a[MAX],i,l;
clrscr();
printf("Enter the size\n");
scanf("%d",&l);
printf("Enter the values\n");
for(i=1;i<=l;i++)
{
scanf("%d",&a[i]);
}
printf("Even numbers are\n");
for(i=1;i<=l;i++)
{
if(a[i]%2==0)
{
printf("%d\n",a[i]);
}
}
printf("Odd number\n");
for(i=1;i<=l;i++)
{
if(a[i]%2!=0)
{
printf("%d\n",a[i]);
}
}
getch();
}
C programming
Friday, July 23, 2010
Thursday, July 22, 2010
Write a programe to check the number is even or odd
//Write a programe to check the number is even or odd//
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("Enter the number ");
scanf("%d",&a);
if(a%2==0)
{
printf("%d is even number",a);
}
else
{
printf("%d is a odd number",a);
}
getch ();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("Enter the number ");
scanf("%d",&a);
if(a%2==0)
{
printf("%d is even number",a);
}
else
{
printf("%d is a odd number",a);
}
getch ();
}
Write a programe to check whether the number is divisible by 7 or not
//Write a programe to check whether the number is divisible by 7 or not//
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr ();
printf("Enter the number ");
scanf("%d",&a);
if(a%7==0)
{
printf("%d is divisible by 7",a);
}
else
{
printf("%d is not divisible by 7",a);
}
getch ();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr ();
printf("Enter the number ");
scanf("%d",&a);
if(a%7==0)
{
printf("%d is divisible by 7",a);
}
else
{
printf("%d is not divisible by 7",a);
}
getch ();
}
Write a programe to print reverse of a given word/string
//Write a programe to print reverse of a given word/string //
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main ()
{
int i,n;
char name[10];
clrscr();
printf("Enter the name\n");
scanf("%s",name);
n=strlen(name);
for(i=n-1;i>=0;i--)
{
printf("%c",name[i]);
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main ()
{
int i,n;
char name[10];
clrscr();
printf("Enter the name\n");
scanf("%s",name);
n=strlen(name);
for(i=n-1;i>=0;i--)
{
printf("%c",name[i]);
}
getch();
}
Write a programe to print addition and subtraction of the given number
// Write a programe to print addition and subtraction of the given number //
#include<stdio.h>
#include<conio.h>
void main ()
{
clrscr ();
int a,b,c,d;
printf("Enter the number\n");
scanf("%d%d",&a,&b);
c=a+b;
printf("Add is %d\n",c);
d=a-b;
printf("Sub is %d",d);
getch ();
}
#include<stdio.h>
#include<conio.h>
void main ()
{
clrscr ();
int a,b,c,d;
printf("Enter the number\n");
scanf("%d%d",&a,&b);
c=a+b;
printf("Add is %d\n",c);
d=a-b;
printf("Sub is %d",d);
getch ();
}
Write a programe to print half value of enter number
//Write a programe to print half value of enter number //
#include<stdio.h>
#include<conio.h>
void main ()
{
float a,b;
clrscr();
printf("Enter the number\n");
scanf("%f",&a);
b=a/2;
printf("Answere =%.2f",b);
getch ();
}
#include<stdio.h>
#include<conio.h>
void main ()
{
float a,b;
clrscr();
printf("Enter the number\n");
scanf("%f",&a);
b=a/2;
printf("Answere =%.2f",b);
getch ();
}
Write a programe to to add two float digits.
//Write a programe to to add two float digits//
#include<stdio.h>
#include<conio.h>
void main ()
{
float a,b,c;
clrscr ();
printf("Enter the number\n"); //For eg. 2.5 + 2.4//
scanf("%f%f",&a,&b);
c=(float)a+b;
printf("Answere is %.2f",c); //Answer is 5.10 //
getch ();
}
#include<stdio.h>
#include<conio.h>
void main ()
{
float a,b,c;
clrscr ();
printf("Enter the number\n"); //For eg. 2.5 + 2.4//
scanf("%f%f",&a,&b);
c=(float)a+b;
printf("Answere is %.2f",c); //Answer is 5.10 //
getch ();
}
Subscribe to:
Posts (Atom)