This is a two part program that I i had someone help me do but I need it transfered to simple c (printf and scanf ). If someone could help that would be great.

1)

//Header file section
#include<iostream>
#include<cctype>
using namespace std;
void main()
{
     char character[6],ch;
     int count=0;
     while(count<5)
     {
          fflush(stdin);
          //inputting character
          cout<<"Enter character:";
          ch=getchar();
          //validating input
          if(!isalpha(ch))
          {
              cout<<"Error Input again:";
            ch=getchar();
          }
          else
          {
          character[count]=ch;
          count++;
          }
     }//loop ends
     //displaying charcters with ascii values
     for(int i=0;i<5;i++)
          cout<<character[i]<<" "<<int(character[i])<<endl;
     //pause system for a while
     system("pause");
}//end main

2.

//Header file section
#include<iostream>
#include<cctype>
using namespace std;
void main()
{
     int numbers[5],num;
     int count=0;
     while(count<5)
     {

          //inputting number
          cout<<"Enter number:";
          cin>>num;

          //validating input
          if(num>31&&num<256)
          {
           numbers[count]=num;
           count++;
          }
          else{
              cout<<"Error Renter:";
                             cin>>num;}
     }//loop ends
     //displaying number with ascii values
     for(int i=0;i<5;i++)
          cout<< numbers[i]<<" "<<char( numbers[i])<<endl;
     //pause system for a while
     system("pause");
}//end main

Change cout to printf
Change cin to scanf
Change to the proper headers for C
Post using CODE Tags.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.