jeudi 28 mai 2020

How to get rid of error c2061;syntax error cout?

hello i want to build a programme that display even and odd numbers from given numbers i get this message error which is error C2061: syntax error : identifier 'cout' i try again to look but i cant find any.i search online and says that i should using instead of which i did but it didnt work too. How to solve this

below is my code

    #include<stdio.h>
#include <iostream>
using namespace std;


int main(){

    int number;
    int firstNum,secondNum;
    int countOdd,countEven;

    cout << "Enter the first number: ";
    cin >> firstNum;

   cout << "Enter the second number: ";
    cin >> secondNum;

if (firstNum>secondNum )
    cout << "Sorry the first number must be less than second number";

else if

    cout << "Odd numbers in given range are: ";
    for(number = firstNum;number <= secondNum; number++)

         if(number % 2 !=0)
             cout << number<< " ";
     countOdd = number;
     cout << "\nTotal count of odd number is :" << countOdd << endl;

    printf("\nEven numbers in given range are: ");
    for(number = firstNum;number <= secondNum; number++)

         if(number % 2 ==0)
             cout << number << " ";
 countEven = number;
     cout << "\nTotal count of even number is :" << countEven << endl;

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire