C++ :: Receive Integer X And Print Alternating Alphabetic Characters

Feb 6, 2015

Q1. Recursive function that receives an integer x and prints the alternating alphabetic characters.

Write a main function to test the function;

ENTER NUMBER : 4

A C E G

Q2. Define a void function that finds the smallest value in the array and number of its occurrences. Also, it finds the largest value in the array and number of its occurrences.

ENTER 4 NUMBERS:
1 12 5 41 41

THE BIGGEST IS 41 AND IT OCCURS 2 TIME
THE SMALLEST IS 1 AND IT OCCURS 1 TIME

View 17 Replies


ADVERTISEMENT

C++ :: Program To Verify That Name Only Contains Alphabetic Characters?

Dec 1, 2013

I am working on a program where i prompt the user for his/her name and i have to verify that the name only contains alphabetic characters.

here is my coding. It works to an extent i just can't get it to work the way it is supposed to.

#include <iostream>
#include <cstring>
using namespace std;
const int SIZE = 50;
int main()
{
char name[SIZE];
cout << "What's your first name?" << endl;

[Code]...

when someone types in a name with only alphabetic characters it outputs valid name for how long the name is. For Ex: bob is three characters so it would output valid name three times. also when you put in a name with a number or character at the end it outputs valid name for the correct characters but also outputs the invalid character and invalid name which its supposed to do. the valid name should not be showing up though.

View 2 Replies View Related

C :: How To Print Characters But No String Just Array Of Characters

Mar 20, 2014

so my question is i want to print characters,no string just an array of characters,i do this but it s not working,maybe i have to put the '' at the end?

Code:

int main() {
int i;
char ch[5];
for(i = 0; i < 5; i++) {
scanf("%c",&ch[i]);

[Code]...

View 6 Replies View Related

C :: Cannot Print Characters In The End

Feb 7, 2014

I cant print the characters in the end.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE *arquivo1,*arquivo2,*arquivo3;//files i will open//
char texto;//texto= character i will read.

[Code]...

View 5 Replies View Related

C :: Possible To Mix Characters And Integer Values In A Text Document

Jul 23, 2013

I was just wondering whether or not it is possible to "mix" characters and integer values in a text document that is to be read by C.

I am to read and use values for length around the hip, neck and such, however, most of the tutoring examples I am finding online seem to strictly deal with either integers or characters alone.

Basically my text file looks a bit like:

Abdominal length: 90.000
Neck length: 26.500
and so on

So, before I move further into this subject, is it possible at all to isolate and use only the double values or will I have to format my text file differently?

View 9 Replies View Related

C++ :: Printing Even And Odd Numbers In Alternating Pattern?

Nov 23, 2014

We never really had a thorough discussion yet about if-else statements and while.. but our teacher already gave us a difficult assignment..

We should write a program the accepts a number , n, and displays the first n values of the number series:

the pattern to be print was like this 1 1 2 3 4 5 8 7 16 9 32 11 64 13...

alternating odd and even numbers using while and if-else statements

if you input n, the output will print only until 1 1 2 3 4 5 8 7

View 2 Replies View Related

C++ :: Reverse Alternating Words In A String

Nov 24, 2014

I'm trying to create a small program to reverse every alternate words in a string.

OUTPUT: The esoum was thgauc in a peg.

#include<iostream>
#include<string>
using namespace std;
int main() {
string sentence, reversed_sentence, buffer;

[code].....

View 6 Replies View Related

C :: Print String With Escape Characters

Mar 7, 2013

is there any function to print a string with all the escape characters in it?

For example, instead of printing:
This is a string.

It would print:
This is a string.

Or in Windows:
This is a string.

I know that you can debug the code to find the variable contents, but is there any way to accomplish this with some standard library function?

View 6 Replies View Related

C :: Compare 2 Strings And Print Out 1 If Characters Match And 0 If Not

Oct 29, 2014

This program is supposed to compare 2 strings and print out a 1 if the characters match and a 0 if they dont. It compiles but doesnt give me the correct output.

Code:
#include <stdio.h>
#include <string.h>
void func();
int main () {
func();
return 0;

[Code] ....

View 11 Replies View Related

C++ :: Print ASCII Characters - Limit In For Loop

May 1, 2015

#include<iostream>
#include<conio.h>
using namespace std;
int main(void){
clrscr();

[Code] ....

I am trying to print ascii characters but problem is If i put a limit in for loop to 255 or more than 126 the output don't stop it keeps on going

I know there is another way to this program but what i want to know this why this happen in this logic....it doesn't happen if a<=125 or less then 125.

View 7 Replies View Related

C :: Print Multiple Characters To Same File Using Fprintf Function

Nov 5, 2014

I'm new to C and was wondering if it was possible to print multiple characters to the same file using the fprintf function provided in one of the C standard libraries?

View 1 Replies View Related

C :: How To Scan And Print Integer

Jan 28, 2013

This is my code:

int main() {
int num;
printf("Please enter a number: ");
scanf("%d", num);
printf("%d", num);
return 0;
}

when i compile and run it, it stops working and doesn't printf the integer.

View 3 Replies View Related

C++ :: Option To Display All Items Have Entered In Alphabetic Order

Jan 14, 2014

i need one more option which it can display all the items i have entered in alphabetic order in my program..this is my coding......

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define capacity 1000
void cal_item(struct item[capacity]);
void input(struct item[capacity]);
}

[code]....

View 1 Replies View Related

C++ :: Print Out Integers Between 2 And 256 That Are Integer Powers Of 2

Nov 5, 2013

Using a do-while loop, for loop, or while loop. This is what I have so far but i don't know what to do after that.

#include <iostream>
using namespace std;
int main() {
int num;
int min = 2;
int max = 256;
}

Also the results should be printed out with 10 integers per line, right justified in a 5 byte field.

View 1 Replies View Related

C/C++ :: Array To Sort Strings In Alphabetic Order And Read From Stdin

Mar 20, 2014

I have a pre-declared array which sorts strings to it's alphabetic order and want to change it so it reads from stdin.

char *array[] = {"aaa", "ccc", "bbb", "ddd"}

I tried doing something like this:

for (i = 0; i < length; i++)
scanf("%s", &array[i]);

I just can't bring it to work. Another thing is, the input is a a bunch of strings separated by commas and ends with a period. Since I have to make a working C model which gets translated to assembly language later on I can't use functions like strtok.

View 6 Replies View Related

C++ :: How To Make A Program That Print Out Factors Of Integer

Oct 26, 2013

I want to make a simple program that will print out the factors of an integer. My program right now only outputs "The prime factors of 221 are 221, 221, 221, 221"... Where it should be "The prime factors of 221 are 1, 13, 17, 221"

#include <cstdio>
int factorsOf(int x);
//function
int main() {
int x = 221;
printf("The factors of 221 are ");

[Code]...

View 3 Replies View Related

C++ :: Separate Input Integer Into Its Individual Digits And Print

Apr 18, 2013

Write a full C++ program that inputs three-digit integer, separates the integer into its individual digits and prints the digits separated from one another. For example, if the user types 549, the program should print;

5 4 9

View 5 Replies View Related

C++ :: 3 Integer Numbers - Find And Print Mean / Maximum And Second Minimum

Oct 25, 2014

The question is: Write a program that reads 3 integer numbers, then finds and prints the: Mean - Maximum & Second Minimum.

#include <iostream>
using namespace std;
int main () {
double a, b, c;
cout<< "Please enter three values"<<endl;

[Code] .....

View 6 Replies View Related

C/C++ :: For Loop To Print Given Character Number Of Times Specified By Integer

Feb 11, 2014

The function uses a "for" loop to print the given character the number of times specified by the integer.

How can I make a for loop to do that?

So.. my code looks like this:

// cpp : Defines the entry point for the console application
//
#include "stdafx.h"
#include <iostream>
using namespace std;
void printMyInteger(int myInteger, char myChar) {

[Code] ....

So.. here is my error:

Error1error C2143: syntax error : missing ';' before ')'d:workspaceuniversity ools for games and animationworkshopsweek 6week 6week 6week 6.cpp101Week 6
Error2error C2143: syntax error : missing ';' before ')'d:workspaceuniversity ools for games and animationworkshopsweek 6week 6week 6week 6.cpp101Week 6
3IntelliSense: expected an expressiond:workspaceuniversity ools for games and animationworkshopsweek 6week 6week 6week 6.cpp107Week 6

View 3 Replies View Related

C/C++ :: Print Pascal Triangle Based On Integer N Inputted

Nov 7, 2014

void Pascal(int n){
int i,j;
int a[100], b[100];
a[0]= 1;

[Code] ....

I've been trying to make a function that prints a pascal triangle based on an integer n inputted.

View 3 Replies View Related

Visual C++ :: Pythagorean Triples - Read Integer N And Print

Sep 27, 2014

I need to create a code in c fits the description below,

Description : A positive integer triple (a, b, c) with 0 < a < b < c and a^2 + b^2 = c^2 is called a Pythagorean triple. Write a program in C which reads an integer N and prints

1. the total number of Pythagorean triples (a, b, c) with c < N,
2. every such Pythagorean triple, and
3. the triple that has the largest value of c.

Hint: you can enumerate all possible pairs (a, b) with 0 < a < b < N and check if they satisfy a

2+b
2 < N2
.

Example Input/Output

- Enter a positive integer: [3]
There is no Pythagorean triple in this range.

- Enter a positive integer: [15]
There are 3 Pythagorean triples in this range:
(3, 4, 5)
(5, 12, 13)
(6, 8, 10)
The triple with the largest value of c is (5, 12, 13).

- Enter a positive integer: [6]
There are 1 Pythagorean triples in this range:
(3, 4, 5)
The triple with the largest value of c is (3, 4, 5).

View 1 Replies View Related

C++ :: Read Unknown Number Of Integer Values And Then Print Count Sum And Average Of Odd Values

Apr 9, 2014

write a c++ program that reads an unknown number of integer values and then print count, sum and average of odd values, even values, positive values, negative values!!

View 1 Replies View Related

C :: Can't Seem To Receive UDP Packets

Jun 2, 2013

I'm trying to get a UDP server working and just can't seem to get it to read in any UDP packets. I can see the packet coming in on the correct interface and port from tcpdump, but my program never logs that it got the data.

I just keep getting a log showing that my recvfrom timed out. I'm pretty sure I'm setting everything up correctly.

Code:
int create_listen_socket() {
struct sockaddr_in si_me;
int sock_fd;
struct ifaddrs * ifAddrStruct=NULL;
struct ifaddrs * ifa=NULL;
void * tmpAddrPtr=NULL;
struct timeval tv;

[Code] ....

View 1 Replies View Related

C# :: Socket TCP Send / Receive

Jun 28, 2014

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace test {

[Code] ....

I don't know if this is a bug in Winsock or the .NET Framework but i need to fix this or workaround. Recently I was working on a networking class and this error is breaking everything.

If you add Thread.Sleep(1) after Send() call then "TCP Bug detected" doesnt get executed but its not a reliable fix.

View 7 Replies View Related

C/C++ :: Find The Common Characters Between Two String Characters

Jul 6, 2014

Im supposed to find the common characters between two string characters, assuming that the user wont input duplicate letters like ddog. When I run my code I get an output of a question mark upside down. Here is my code with comments on what each part is supposed to do

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char str1[20], str2[20],remp = '';
int size1,i,j,temp;
printf ("Input the first string");

[Code]...

View 6 Replies View Related

C++ :: Winsock - Receive / Send Sequences

Oct 25, 2013

I'm trying to understand winsock with c++. Let's assume I have a 2 working applications, one is the client and one the server:

Client: I can enter a command, for example chat or filetransfer, it will then switch into this specific mode where I can enter commands like uploading a file, send a message etc.

Client
Code: ....
while (rc != SOCKET_ERROR) {
printf("
#");
gets(buf);
if (strcmp(buf, "CHAT") == 0){
// start chat mode

[Code] .....

I'm in a recv/send loop and I'm using streams...so basically all the data is being sent/received there. Now, if I want to upload a file, I send a FILETRANSFER String to the server. Then I will probably need another loop that receives file requests from the client. The server will need more details about the file, like the path, name, size...

Now, my question is, what's the best practise for something like that? I'm having problems understand how I can send 3 different values from the server to the client and how he will receive them in the right order store them in variables. And also, after sending something to the server, in some cases, the client will have to wait for the server to answer.

Is there a good example of a similar application?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved