#include<iostream>
using namespace std;
void main() {
int odd,even,number;
odd=0;
even=0;
for(int x=1;x<=10;x=x+1){
cout<<"enter a number\n";
cin>>number;
if(number%2==0){
even++;
}
else {
odd++;
}
}
cout<<"even number has:"<<even;
cout<<"odd number has:"<<odd;
}
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
1. Read in 'n'2. Output n*(n+1)/2> Check the no. in odd or even?Both possible, has no significance.
if (n%2==0) sum=n/2*(n+1); else sum=(n+1)/2*n;
// HI THIS IS MAYANK PATEL /*C Program to find Maximum of 3 nos. using Nested if*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; // clrscr(); printf("Enter three number\n\n"); scanf("d%d",&a,&b,&c); if(a>b) { if(a>c) { printf("\n a is maximum"); } else { printf("\n c is maximum"); } } else { if(b>c) { printf("\n b is maximum"); } else { printf("\n c is maximum"); } } getch(); }
... int number_to_check = 0;...cin >> number_to_check;if ((number_to_check % 2)){printf("The number %d is even\n", number_to_check);}else{printf("The number %d is odd\n", number_to_check);}...
10
Write a c program to print the 100 to 1 nos
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
#include <stdio.h> main() { int n, odd=0, even=0; while (scanf("%d",&n)&&(n!=0)) (n%2)?++odd:++even; printf("odd: %d even: %d\n",odd,even); }
nos vemos
10,000,000
Write (to) us
//sum and product of 3 nos #include #include void main() { int a,b,c; printf("enter the 3 nos"); scanf("%d%d%d",&a,&b,&c); printf("sum of 3 nos",a+b+c); printf("product of 3 nos",a*b*c); getch(); }
even
there cannot be any nos like that.. product of 2 odd nos is odd.. sum of two even nos is even.. that multiplied by six is even too.. subtracting 2 from that also gives an even no.. let x and y be the odd integers. according to the given question xy=6(x+y)-2..here we r actually equatin an odd no and an even no.. which is wrong.. so there cant be any two consecutive odd nos that fit in the question
Each one of them can be expressed as a sum of two primes.
No most are odd nos.