Answer to Question #16508 in C++ for Ashish

Question #16508
write a c program to ask the users to enter their first and last name and print the name and number of character in it.
1
Expert's answer
2012-10-17T09:32:04-0400
#include "stdafx.h"

#include <stdio.h>

using namespace std;

#define MAXNUM 100

int main()

{

char message [MAXNUM];

int numchar;

printf("Type in a your name: ");

gets(message);

for (int i = 0; i < MAXNUM; i++){

if (message[i] != ' '){

numchar++;

}

}

printf ("The number of characters entered is %d
", numchar);

return 0;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS