Write your question here.
Hi all, Hope everyone is doing great, i just need to confirm that i've been given assignment from my college, and i've made that specific syntax, just need to verify if its giving the complete result or not... Please find below.
Question : Write a code that generates a random integer in the range of 0-10. The code performs the following operations.
• If number is 0, the system prints “The number 0 is randomly generated”
• If the number is even, the system prints “The randomly generated number is an even number”
• If number is odd, the system prints “The randomly generated number is an odd number”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include<stdio.h>
#include< iostream.h>
#include<conio.h>
void main{
Int n;
For(int i=0;i<10;i++){
cout<<”enter an inter number”<<endl;
cin>>n;
}
If(n==0)
Cout<<”integer is zero”<<endl;
else if(n%2==0)
cout<<”number is even”<<endl;
else if(n%2==1)
cout<<”number is odd”<<endl;
else
cout<<”enter inviled number”<<endl;
getch();
}
|