hello !! i want to ask that in below program if i want to change cin and cout into printf and scanf then how colud i?Becuse when iam changing my program in cin and cout it is not running :(

#include <iostream>			
#include <iomanip>

int main () { 

	long number; // the number to use to calculate its factorial
	long factor; // the factorial of the number
	long term; // next term to use in the calculation


	// prompt and get the first number
	std::cout << "Enter a number or -1 to quit: ";
	std::cin >> number;

	while (number >= 0 && std::cin) 
	{
		// calculate number factorial 
		factor = 1; 
		for (term=2; term <= number; term++) 
		{ 
			factor *= term; 
		} 
		
		// output number and its factorial
		if(number == 1)
		{
			std::cout << number << "! = 1*1=1" <<std::endl;
		}
		else
		{
			std::cout << number << "! = " ;
			for (int k=2; k<number+1; ++k)
			{
			     std::cout<<number+2-k<<"*";
			}
			std::cout <<"1 ="<< factor <<std::endl; 
		}

		// get another number to do 
		std::cout << "Enter a number or -1 to quit: "; 
		std::cin >> number; 
	} 
	
	return 0; 
}

Hi here it is:

//#include <iostream>	//c++

#include <stdio.h>		//the same in C

int main () { 

	long number; // the number to use to calculate its factorial
	long factor; // the factorial of the number
	long term; // next term to use in the calculation


	// prompt and get the first number
	//std::cout << "Enter a number or -1 to quit: ";//C++
	printf("Enter a number or -1 to quit: ");	//the same in C
	//std::cin >> number;				//C++
	scanf("%ld",&number);				//the same in C

	//while (number >= 0 && std::cin)
	while (number >= 0) 
	{
		// calculate number factorial 
		factor = 1; 
		for (term=2; term <= number; term++) 
		{ 
			factor *= term; 
		} 
		
		// output number and its factorial
		if(number == 1)
		{
			//std::cout << number << "! = 1*1=1" <<std::endl;//C++
			printf("%d!=1*1= 1\n",number);				//the same in C
		}
		else
		{
			//std::cout << number << "! = " ;		//C++
			printf("%d!=",number);				//the same in C
			for (int k=2; k<number+1; ++k)
			{
			//std::cout<<number+2-k<<"*";			//C++
			printf("%d*",number+2-k);				//the same in C
			}
			//std::cout <<"1 ="<< factor <<std::endl; 	//C++
			printf("1= %d\n",factor);				//the same in C
		}

		// get another number to do 
		//std::cout << "Enter a number or -1 to quit: ";	//C++ 
		printf("Enter a number or -1 to quit: ");	        //the same in C
		//std::cin >> number; 					//C++ 
		scanf("%ld",&number);					//the same in C

	} 
	
	return 0; 
}

printf("%c occurs %d times in the entered string.\n",c+'a',count[c]);
what is its cout statement

cout << (c + 'a') << " occurs " << count[c] << " times in the entered string.\n";
This article has been dead for over six months. Start a new discussion instead.