C :: Explain Use Of Question Mark

Feb 5, 2014

how the '?' works at the end of the "int luhn" function ( sum += odd ? digit : m[digit]; ) and at the end of main ( printf( "%s
", luhn( buf )? "Valid" : "Invalid" ); ).

I know it's determining what results to report, but the usage is not clear to me. I guess what I'm asking, since I'm not familiar with the use of '?' here, is what the if/else equivalent of these two lines would be.

Code:

#include <stdio.h>
#include <string.h>
int luhn(const char* cc)
{
const int m[]= { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9};

[Code]....

View 3 Replies


ADVERTISEMENT

C++ :: How To Put End Of String Mark At The End Of Each Line In Array

Oct 28, 2014

Basically I am writing a program that will ask the user to input some names and then I will sort the names. However, right now when I input the characters, it prints out everything, including the empty spaces. How do I put an end of string mark at the end of the line, when the user hits enter

void main() {
constintMaxNames(20);
constintMaxLetters(15);
charNames[MaxNames + 1] [MaxLetters + 1];
intNumRows;

[Code] .....

View 1 Replies View Related

C++ :: To Mark Both Smallest And Largest Element

Mar 13, 2013

This code, asking to mark both the smallest and the largest element. I just got largest, didn't get smallest number. Here is code:

#include <iostream>
using namespace std;
int main() {
const int CAPACITY = 1000;
double values[CAPACITY];
int current_size = 0;

[Code] .....

View 9 Replies View Related

C :: Display Average / Maximum And Minimum Mark

Sep 29, 2013

Program that reads 10 students marks and display the average, the maximum and the minimum marks.

Code] ....

#include <Stdio.h>
main(){
// Local Declarations
int marks[10];
int i; /*loop counter */
int avg;
int sum = 0;

[Code] ....

In this program i am able to get Average Marks and Minimum Marks But i am not able to get the Maximum Marks Output correct.

View 6 Replies View Related

C++ :: Program To Read In Sequence Of Examination Mark From Text File And Produce Mean

Jan 26, 2013

Write a program to read in a sequence of examination mark from a text file named as input.txt and produce the mean, and standard deviation of the marks. Your program should also produce a bar chart for each grade where the range of mark is given as below.

GradeMarks Range
A80-100
B70-79.9
C50-69.9
D40-49.9
F0-39.9

Output the result to another text file named as output.txt.

View 3 Replies View Related







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