PropellerAds

Showing posts with label even. Show all posts

Arithmetic Operators, Largest & Smallest Value And Odd & Even Numbers

//Arithmetic operation on three numbers
#include<stdio.h>;
#include<conio.h>;

//executing main program
void main()
{
//creating var for storing values
int i;
int j;
int k;

//take input from user
printf("Input three different integers \n");
scanf("%d %d %d", &i, &j, &k);

//calculating and displaying results of
//Adition
printf("\nThe sum is %d \n", i + j + k);
//average
printf("The average is %d \n", (i + j + k)/3);
//product
printf("The product is %d", i * j * k);

//smallest and largest no.
//first number
if (i < j & j<= k)
{
printf("\n \nThe smallest is %d", i);
} /*end if*/

if (j > i & j > k)
{
printf("\n \nThe largest is %d", i);
} /*end if*/

//2nd number
if (j < k & j <= i)
{
printf("\nThe smallest is %d", j);
} /*end if*/

if (j > k & j >= i)
{
printf("\nThe Largest is %d", j);
} /*end if*/

//3rd number
if (k < j & j<= i)
{
printf("\nThe smallest is %d", k);
} /*end if*/


if (k > j & j >= i)
{
printf("\nThe Largest is %d", k);
} /*end if*/

//chk and display even and odd no
//first no.
if ((i%2) == 0)
{
printf("\n \n%d is even", i);
}
else
{
printf("\n \n%d is odd", i);
}

//2nd no.
if (j%2 == 0)
{
printf("\n \n%d is even", j);
}
else
{
printf("\n \n%d is odd", j);
}

//3rd no.
if (k%2 == 0)
{
printf("\n \n%d is even", k);
}
else
{
printf("\n \n%d is odd", k);
}

//for disabling automatic close off of program after execution of program
_getch();
}//end

Diamond with even number in c++

#include<stdio.h>;
#include<conio.h>;

void main(){
int i;
int k;
int j;
int l;
int m;
int n;
int o;


printf("Write an even no: ");
scanf("%d", &i);

while(i%2 == 1) {
printf("\n please write an Even No: ");
scanf("%d", &i);
}

k = i/2 -1;
j = 0;
l = 1;
m = 0;
n = 0;
o = i/2;


while(o > n){

while (k > j){
printf("-");
j++;
}

while(l > m){
printf("*");
m++;
}


if (k == j){
j = 0;
k--;
}

if( l == m){
printf("\n");
n++;
m = 0;
l++;
l++;
}
}


k = j = 0;
l = i-1;
m = 0;
n = 0;
o = i/2;


while(o > n){

while(k > j) {
printf("-");
j++;
}


while(l > m){
printf("*");
m++;
}


if (k == j){
j = 0;
k++;
}


if (l == m) {
printf("\n");
n++;
l--;
l--;
m = 0;
}
}

_getch ();
}



Sunday, 28 September 2014
Posted by Unknown

Assigment lab-3 task-3

Creating a diamond with even number

click here to download
Download at SpeedyShare
PropellerAds
PropellerAds

Popular Post

Powered by Blogger.

- Copyright © BSCS -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -